magento
Magento2 .gitignore reference
Magento include a base .gitignore
file with the Magento Open Source project repository. See the latest Magento .gitignore
file. If you need to add a file that is in the .gitignore
list, you can use the -f (force) option when staging a commit:
Nice and clean one
Magento2 caching a blocks in a page
Magento2 Indexing Change Mode programmatically
Magento2 Indexing Mode
You can set the mode via command line
php bin/magento indexer:set-mode {realtime|schedule} [indexer-name]
“realtime” is equal to “Update on Save” and “schedule” is equal to “Update by Schedule”.
Magento2 Checkout: remove sidebar ONLY in step 1
Add the following line to your CSS file:
.opc-summary-wrapper{
display:none;
}
Goto following directory
vendor/magento/module-checkout/view/frontend/web/js/model
And open the file step-navigator.js
Copy this file to your working theme directory.
Edit the function getActiveItemIndex in step-navigator.js You will get 0,1 etc when console.log(activeIndex);
How to remove index.php from url if we enter manually
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
How do I clear the cache in Magento 2 for a single product_id
the best way to do do this is using the below method
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productR = $objectManager ->create('\Magento\Catalog\Api\ProductRepositoryInterface'); $product = $productR->get('product_sku'); $product->cleanCache(); $this->_eventManager->dispatch('clean_cache_by_tags', ['object' => $product]);
you need of course to follow the DI to implement this code, I just used this quick way to make it easy to understand
Programmatically update customer data in Magento 2
Using Object Manager
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $websiteId = $storeManager->getStore()->getWebsiteId(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerRepository = $objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface'); // load customer info by email $customer = $customerRepository->get('[email protected]', $websiteId); // load customer info by id $customer = $customerRepository->getById(1); // Update customer Info $cust
How to enable Magento 2 profiler?
Magento profiler can help you with the store performance tuning before the store release or during the exploitation.
The old UI for enabling/disabling the profiler is not available in Magento 2 and the profiler is disabled by default.
To enable one of the profiler formats mentioned above, you can edit .htaccess (a configuration file for Apache Web Server software):
Choose one of the next expressions:
Magento2 Change Maintenance Page content
Most of us wanted or liked to change the Maintenance Page content, but it had difficulties doing that, now we will show you how easy is that can be
Some important command in Magento2 after you change the mode to production
From the Magento root directory, switch to production mode:
bin/magento deploy:mode:set production
Enable JavaScript bundling:
bin/magento config:set dev/js/enable_js_bundling 1
Optimize bundling by minifying JavaScript files:
bin/magento config:set dev/js/minify_files 1
Enable cache busting on static file URLs. This ensures users get the latest version of the assets anytime they update:
bin/magento config:set dev/static/sign 1