1
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">

This will return all the products. But I want to pass category id and get that category product. I have also tried category_id="3" in a block like

<block class="Magento\Catalog\Block\Product\ListProduct" category_id="3" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml"> 

But this has no effect. Any solution?

2
1

We can pass id in argument tag. seen the code sniped below

<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
         <arguments>
                <argument name="category_id" xsi:type="string">4</argument>
         </arguments>
    </block> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.