Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crosssells are never shown when using product/list/items.phtml template #7353

Closed
koenner01 opened this issue Nov 8, 2016 · 4 comments
Closed
Labels
bug report Component: Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@koenner01
Copy link
Contributor

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

  1. PHP7.0
  2. Magento 2.1.2

Steps to reproduce

  1. 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>
  1. output the childHtml on the frontend

Expected result

  1. Show crosssells on product detail

Actual result

  1. 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())) {

@koenner01 koenner01 changed the title Crosssells are never shown because when adding block to layout Crosssells are never shown when using product/list.items.phtml template Nov 8, 2016
@koenner01 koenner01 changed the title Crosssells are never shown when using product/list.items.phtml template Crosssells are never shown when using product/list/items.phtml template Nov 8, 2016
@naydav
Copy link
Contributor

naydav commented Jan 19, 2017

Thanks
We've created internal ticket MAGETWO-63367 to address this issue.

@miakusha miakusha added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jan 19, 2017
koenner01 added a commit to koenner01/magento2 that referenced this issue Feb 18, 2017
mmansoor-magento pushed a commit that referenced this issue Feb 25, 2017
 - Merge Pull Request #8602 from koenner01/magento2:fix-#7353
mmansoor-magento pushed a commit that referenced this issue Feb 25, 2017
 - Merge Pull Request #8602 from koenner01/magento2:fix-#7353
@okorshenko
Copy link
Contributor

Closing this issue. PR was delivered to develop branch: #8602

@magento-team magento-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Catalog labels Jul 31, 2017
@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-64999

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-64844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

6 participants