New answers tagged

0 votes

Magento 2 : Redirect product if out stock

You can achieve this functionality by following below code. I have used plugin for this functionality. Please follow below steps. Step 1:- Define plugin in Vendor/Module/etc/di.xml <?xml version=&...
0 votes

Magento2: Get category product count which is show in admin after the category name

Admin panel uses: Magento\Catalog\Model\ResourceModel\Category\Collection::setLoadProductCount(true) This flag adds products count to categories in collection. Use the flag before load(). It counts ...
1 vote

How to change layout of all category in magento to 1 column

For those which are searching this after Update to Magento >2.4.3 If the page builder (introduced in Magento CE 2.4.3) is active the page builder category layout has to get updated: app/design/...
  • 394
0 votes

Magento 2 : Redirect product if out stock

Why would you want to? If you redirect and a Search Bot picks up that redirect, they'll drop the initial URL - then when it comes back into stock, they'll never reindex that URL. Much safer to show an ...
0 votes

Magento 2 : Redirect product if out stock

Obviously seems pretty simple. On your product controller page, check his stock and depending on the result, either you continue as normal on the product page either you make the redirection. To ...
  • 954
1 vote

Show only active subcategories

Could you confirm the following code is redundant? foreach ($subCategories as $subCategory) { if ($subCategory->hasChildren()) { $this->getChildNames(); } } I've tested your ...
  • 2,563
0 votes

Route to Existing Layout

I recommend copy the content of catalog_category_view.xml to your layout in your custom module instead of modify the routing. Here you can use your own Block to send a specific collection to list....
  • 2,563

Top 50 recent answers are included