If you need only one product attribute value in Magento 2, you do not always need to load the entire product through a repository or collection. That can be wasteful in loops, cron jobs and imports. Using the Product Resource…
Product in Stock but Cannot Be Purchased? (Magento 2)
In Magento 2, a product can show available stock in the admin area yet appear as unavailable on the storefront. With MSI enabled, the entered quantity is not the whole story. Magento distinguishes the physical quantity held in a source…
Private Sections vs. cacheable=”false”: What’s the Difference? (Magento 2)
Dynamic content in Magento 2 does not automatically mean you must disable the Full Page Cache for the entire page. That is what Private Contentis designed to help avoid. A block with cacheable=”false” can make the whole page non-cacheable. With…
Page Is Not Served from Cache? (Magento 2)
If a product, category or CMS page is never cached despite an enabled Full Page Cache , the cause is not always Varnish, Redis or cache configuration. Sometimes a single layout XML block can exclude the entire page from full…
What Are X-Magento-Tags?
When investigating Magento caching in more detail, you may encounter X-Magento-Tags. Magento uses these tags to describe which entities contribute to a cached response, such as products, categories or CMS pages. Typical cache tags look like this:
|
1 2 3 |
cat_p_123 cat_c_42 cms_p_5 |
The structure…
Displaying the Active Layout Handles of a Page (Magento 2)
When a Magento 2 layout XML change does not take effect, first check the active Layout Handles. A layout XML file is processed only when its corresponding handle is active on the page. You can display the current handles directly…
Code Changes Are Not Applied (Magento 2)
If you change a PHP, XML or template file in Magento 2 and still see the old version after clearing the cache, it does not necessarily mean you edited the wrong file. Generated code, static assets, PHP OPcache, Varnish or…
Blocking recurring fake orders in Magento
When fake orders become a recurring problem Does someone keep placing fake orders in your Magento 2 store, perhaps using different email addresses or customer accounts each time? Apart from the unnecessary work involved, such orders can interfere with your…
Preloading Hyvä pages before a click using native Speculation Rules (Magento 2)
With Hyvä 1.4+ , browsers can begin loading destination pages before visitors click a link. Hyvä uses the browser’s native Speculation Rules API and defaults to prefetch. This preloads the HTML for likely navigation destinations in the background without fully…
Finding products without product images using SQL (Magento 2)
Sometimes you need to find all products without assigned images in Magento 2, for example to verify that a product import or data migration is complete. The following SQL query returns products without product images:
|
1 2 3 4 5 6 7 8 9 |
SELECT p.entity_id, p.sku, p.type_id FROM catalog_product_entity AS p LEFT JOIN catalog_product_entity_media_gallery_value_to_entity AS mg ON mg.entity_id = p.entity_id WHERE mg.value_id IS NULL ORDER BY p.entity_id; |