3

For some reason, my theme is missing the crosssell.phtml file that shows cross-sell products in the cart.

I found out from my Magento2 system.log file;

[2017-03-26 21:21:11] main.CRITICAL: Invalid template file: 'Magento_Catalog::product/list/crosssell.phtml' in module: 'Magento_Checkout' block's name: 'checkout.cart.crosssell' [] []

I tried to search in other templates for the crosssell.phtml file, but could not find it. Does anybody know what code I should put in the crosssell file to make it show the crosssell products in cart?

I'm using Magento 2.1.5

1
  • Hi remove checkout.cart.crossse this block from the checkout_cart_index.xml which is available in theme/any custom module. It will take the default Magento XML file.
    – Nits
    Nov 13 '20 at 17:21
0

What are you trying to achieve?

FYI, the file which creates the cross sell section is module-catalog/view/frontend/templates/product/list/items.phtml

0

Thanks for your reply! Sorry if I wasn't clear. I want to show the cross-sell items in the shopping cart (url checkout/cart/).

It used to work in Magento 1, all the items you mark as cross-sell for a product show up in the shopping cart. I believe it should also work in magento2 but it's not showing and I get the error in my exception log

0

In the file /vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml

you may verify you find a block definition like below:

<block class="Magento\Checkout\Block\Cart\Crosssell" name="checkout.cart.crosssell" template="Magento_Catalog::product/list/items.phtml" after="-" ifconfig="checkout/cart/crosssell_enabled">
                    <arguments>
                        <argument name="type" xsi:type="string">crosssell</argument>
                    </arguments>
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="crosssell.product.addto" as="addto">
                        <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
                               name="crosssell.product.addto.compare" as="compare"
                               template="Magento_Catalog::product/list/addto/compare.phtml"/>
                    </block>
                </block>

this tells you the default location in Magento installed version of your template is: Magento_Catalog::product/list/items.phtml

However, if you look into this file, you will see it does get reused for related products, upsells and in general any products listing that have no toolbar navigation.

If you intend to implement your M1 template in this template, you have to bear this in mind.

The options you have that I can see may be to check how related products or upsells products have been integrated in your site. If you find something, then, it should make sense to reuse these for crossells.

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.