Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn PhpStorm

How to load Javascript scripts in Magento 2

All assets file relate in frontend will be store in view/web of module structure Require lib from requirejs-config.js file var config = { map: { "*":{ "lightbox": "VES_Sociallogin/js/lightbox/lightbox.min" //This related to file lightbox/lightbox.min.js } } }; Order to call light box js In any js files you can call to like this. You should use define instead of require in stituation define([ "jquery", "jquery/ui", "lightbox", 'Magento_Ui/js/modal/alert', 'uiComponent' ], function($, lightbox, alert, uiComponent){ "use strict"; $(window).ready(function(){ //console.log('hello magento2! File js edited'); DO ANY CODE YOU WANT HERE }); }); Execute js in template mangeto can be done with script tag script tag with type="text/x-magento-init" { "*":{ &quo

Snippets for Magento 2 Developers

1 - Get ObjectManager Instance $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerCollection = $objectManager->create('Magento\Customer\Model\CollectionFactory')->getCollection(); 2 - Get BaseUrl //inject \Magento\Store\Model\StoreManagerInterface $storeManager in constructor $this->_storeManager = $storeManager; $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); //url in media directory 3 - Get Session Customer //inject \Magento\Customer\Model\Session $customerSession in constructor $this->_session = $customerSession; 4 - Get Featured Products Collection $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); //dirty way $productCollection = $objectManager->create('Magento\Catalog\Model\ProductFactory')->getCollection(); //filters $featuredProducts = $productCollection ->addAttributeToSelect('name')

Fix XML Validate of PhpStorm in magento 2

PhpStorm 9 with magento 2 dev-1.0.0beta Follow this steps Step1 Step2 Step3 Step4 Step5 Step6 Thanks for visit , share this post if you like