-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: CatalogIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report
Description
If you try to add the crosssells block anywhere in the layout and use the product/list/items.phtml template, you will never see any output.
Preconditions
- PHP7.0
- Magento 2.1.2
Steps to reproduce
- Add crosssells block to product detail
<block class="Magento\Catalog\Block\Product\ProductList\Crosssell" name="product.info.crosssell" template="Magento_Catalog::product/list/items.phtml">
<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>
- output the childHtml on the frontend
Expected result
- Show crosssells on product detail
Actual result
- No crosssells are shown
I traced this back to the product/list/items.phtml template where $block->getItemCount() is called. This function will always return null
case 'crosssell':
/** @var \Magento\Catalog\Block\Product\ProductList\Crosssell $block */
if ($exist = $block->getItemCount()) {
$type = 'crosssell';
$class = $type;
$image = 'cart_cross_sell_products';
$title = __('More Choices:');
$items = $block->getItems();
$showAddTo = true;
$showCart = true;
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
$description = false;
$canItemsAddToCart = false;
}
break;
The line should be changed to similiar functionality as the upsells
if ($exist = count($block->getItems())) {
hostep and koenner01
Metadata
Metadata
Assignees
Labels
Component: CatalogIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report