I want change layout of catalaog_category_view.xml but i can't. I override block category.products and it's work but how can i add my own block to existing category.products block? Because i want add my own element above of category.products element. I was trying add block and move element, add to referenceContainer content and move before category.products and nothing happened. Still the same page exists. Can you help me how can i add block inside category.products or above category.products.
<block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml">
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
<container name="category.product.list.additional" as="additional" />
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
<block class="Magento\Framework\View\Element\Template" name="category.product.type.details.renderers.default" as="default"/>
</block>
<block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="category.product.addto" as="addto">
<block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
name="category.product.addto.compare" as="compare"
template="Magento_Catalog::product/list/addto/compare.phtml"/>
</block>
<block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml">
<block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName">
<argument name="name" xsi:type="string">product_list_toolbar</argument>
</action>
</block>
</block>
This is block category.products from Magento_Catalog. I want add my block above this one:
<block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml">
Or:
<block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml"><!-- Before category.products.list -->
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
Anyone can help me? I will be really grateful!
<referenceBlock name="category.products"> <action method="setTemplate"> <argument name="template" xsi:type="string">MGS_Landing::category/products.phtml</argument> </action> </referenceBlock>
- This code override standard category.products. I'm beginner developer of magento2. Where i must create additional block which will show above category.products? Inside referenceBlock or somewhere else?<block class="ModuleOwn\Landing\Block\Landing" name="landingown" template="ModuleOwn::category/landing/grid.phtml"/> <referenceBlock name="category.products"> <action method="setTemplate"> <argument name="template" xsi:type="string">ModuleOwn::category/products1.phtml</argument> </action> </referenceBlock> <move element="landingown" destination="content" before="category.products" />