Display Out Of Stock Product and custom sidebar

Display Out Of Stock Product:
Overwrite catalog_category_view.xml file. for this create a file in your module.
AP=>SoldOut=> view => frontend => layout => catalog_category_view.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Ap_SoldOut::css/soldout.css"/>
    </head>
    <body>
        <referenceBlock name="category.products.list">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Ap_SoldOut::list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>



Now Create Templete file . Copy and paste your existion theam file(..../vendor/magento/module-catalog/view/frontend/templates/product/list.phtml) in list.phtml .
Create phtml file in your module.
AP=>SoldOut=> view => frontend => templates => list.phtml

In it you will get product collection using $block->getLoadedProductCollection() . Now with the help of css, you can display Text Or Image of OUT OF STOCK.

Display Custom SideBar:
Create default.xml file. for this create a file in your module.
AP=>SideBar=> view => frontend => layout => default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
   <referenceContainer name="sidebar.additional">
     <block class="Magento\Framework\View\Element\Template" name="sidebar.custom" as="sidebar.custom" template="Ap_SideBar::left.phtml" after="-" />
   </referenceContainer> 
</body>
</page>


Create phtml file in your module.
AP=>SideBar=> view => frontend => templates => left.phtml
Now You can Display Any thing as You want.

Comments

Post a Comment