Magento2
Power your online business with the most flexible and scalable ecommerce platform
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);
Sections that can be updated when using Ajax request Magento2
In Magento 2, a lot work has been done in improving the response time and Sections are a part of it. Magento sets customer related data in local storage of browser in key value pair. Each key is known as section. In this post we will what sections we can update
We can use all below sections in system.xml file
How to fix the «Invalid template file» / «require_js.phtml» failure of Magento 2.3.x in Windows?
go to this file
/Magento/Framework/View/Element/Template/File/Validator.php
replace this part
foreach ($directories as $directory) { if (0 === strpos($realPath, $directory)) {
with the following one:
$isWin = 'WIN' === strtoupper(substr(PHP_OS, 0, 3)); /** @var bool $isWin */ foreach ($directories as $directory) { if (0 === strpos($realPath, !$isWin ? $directory : $this->fileDriver->getRealPath($directory)) ) {
Original article
Magento 2 How to Add Admin User via Command Line
How to Add Admin User via Command Line
php bin/magento admin:user:create --admin-user=wikicode --admin-password=WiKiLoveMagento [email protected] --admin-firstname=Wiki --admin-lastname=Code
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
Quick Query to the see all products that do not have images in magento2
use this query to see all products that do not have images in magento2
SELECT sku FROM `catalog_product_entity` WHERE `entity_id` not in (SELECT `entity_id` FROM `catalog_product_entity_media_gallery_value` )
ignoring the "Not Visible Individually" products
add phtml file to Static Block or CMS Page Magenot2
you have to add this code to the block or to the page
{{block class="Magento\Framework\View\Element\Template" template="{Vendor}_{Module}::pages/example.phtml"}}
Example
{{block class="Magento\Catalog\Block\Product\ListProduct" category_id="50" name="home.products.list.custom" template="Magento_Catalog::product/list.phtml"}}
Link Category by ID
{{widget type="Magento\Catalog\Block\Category\Widget\Link" anchor_text="MY Custom category" title="Custom Category" template="category/widget/link/link_block.phtml" id_path="category/12"}}
there are three templates
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: