0

I have a custom list.phtml file in

app\design\frontend\BSS\ContactUs\Magento_Catalog\templates\product\list.phtml

And I want to override it on

\vendor\magento\module-catalog\view\frontend\templates\product\list.phtml

How to make it work?

  • just want to clarify if BSS here your package and ContactUs is theme? – Shireen N Feb 5 '18 at 9:08
  • it's company and theme, yes but does it matter? – user63384 Feb 5 '18 at 9:09
  • Are all the other customization in this theme working?Is your theme being correctly configured to use in frontend? – Shireen N Feb 5 '18 at 9:13
  • yes it's, if i change the theme in vendor it's working, but somehow can't override it in app/design – user63384 Feb 5 '18 at 9:19
  • Did you applied your theme to be used as a theme from Content > design configuration in your Magento from your Magento admin? if yes then try to refresh your cache & then see the changes – Abhishek Tripathi Feb 10 '18 at 5:04
4

For override list.phtml via custom module

Create view/frontend/layout/catalog_category_view.xml and put this code.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="category.products.list">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Magetest_Test::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Next create new file view/frontend/templates/product/list.phtml set your code.

  • 1
    This is not required when overriding is done through theme, this is useful when you are overriding in the custom module. – Shireen N Feb 5 '18 at 9:12
1

Create a below file in mention path with below code.

app\design\frontend\BSS\ContactUs\Magento_Catalog\layout\catalog_category_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="category.products.list"   >
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Magento_Catalog::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>
  • i have tried this too but it also not working at all – user63384 Feb 5 '18 at 9:31
  • Make sure your layout should be 2 column left. – Suresh Chikani Feb 5 '18 at 9:32
0

For override list.phtml

\vendor\magento\module-catalog\view\frontend\templates\product\list.phtml

Copy this file to your theme

app\design\frontend\BSS\ContactUs\Magento_Catalog\templates\product\list.phtml

And apply custimization as per your requirement

  • i did it, after that i flush cache but it still not work – user63384 Feb 5 '18 at 9:06
  • have you checked using path hint? which while is called now – Navin Bhudiya Feb 5 '18 at 9:10
  • Flush cache using ssh – Navin Bhudiya Feb 5 '18 at 9:10
  • still not working i have checked the path carefully but it still using the vendor/magento path not my path – user63384 Feb 5 '18 at 9:13
  • is your theme active perfectly? rest of other file are called form your theme – Navin Bhudiya Feb 5 '18 at 9:26
0

create block file and the file should extend ListProduct.

<?php
namespace Frontname\Modulename\Block\Crosssell;

class Autocrosssell extends \Magento\Catalog\Block\Product\ListProduct
{
  //your functions
}

?>

Create view/frontend/layout/checkout_cart_index.xml and put this code.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Magento_Swatches::css/swatches.css"/>
    </head>
    <body>
        <referenceContainer name="checkout.cart.items">
            <block class="Frontname\Modulename\Block\Crosssell\Autocrosssell" name="custom.products.list" as="product_list" template="Frontname_Modulename::checkout/cart/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" as="default"/>
                </block>
                <referenceBlock name="category.product.type.details.renderers">
                           <block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" />
                </referenceBlock>
            </block>
        </referenceContainer>
    </body>
</page>

Try this

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.