0

I have at the moment in catalog.xml <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

and in view.phtml

<?php echo $this->getChildHtml('crosssell') ?>

I have double checked that this product has cross sell products, also I have set indexes (reindex on save) and cache disabled, also tried to reindex and purge cache.

However cross sell products are not showing

1
  • You'd be aware cross sell products depend by the current items in cart. If you want to show them in product page you'd modify that logic, to make it work as other product links based in product view (related, upsell) Jul 31, 2021 at 8:09

3 Answers 3

0

I have found this, of course right after posting my question (I did 30min++ search before posting).

Add Cross sell block on product page

However, this is having "bug", product images and prices are not showing, just default "no image" image and 0.00 price...

0

This functionality already exists in Magento 1.x by way of the Mage_Catalog_Block_Product_List_Crosssell block.

To implement this, just add the block to the product.info block in your theme's local.xml:

<!-- product -->
<catalog_product_view>
    <reference name="product.info">
        <block type="catalog/product_list_crosssell" name="crosssell" as="crosssell" template="catalog/product/list/crosssell.phtml" />
    </reference>
</catalog_product_view>

Then create an appropriate catalog/product/list/crosssell.phtml template, maybe see catalog/product/list/upsell.phtml for reference and guidance.

Then simply output this new block/template in your product view (usually view.phtml):

<?php echo $this->getChildHtml('crosssell') ?>
-1

It's not a bug, you just need to call in the code below. Hope that helps, if you're still looking a year after :)

<?php if($_crossSellProducts = $_product->getCrossSellProducts()): ?>

        <div class="topproducts_containter">
        <div class="topsellerTitle">TOP <?php echo strtoupper(Mage::getModel('catalog/layer')->getCurrentCategory()->getName()); ?> PRODUCTS</div>

        <?php foreach ($_crossSellProducts as $_item): ?>
            <?php $_item = Mage::getModel('catalog/product')->load($_item->getId()); ?>

            <div class="col-sx-12 col-sm-2 items">
                <div class="img">
                    <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>">
                        <img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(100, 150); ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
                    </a>
                </div>
                <div class="name">
                    <a href="<?php echo $_item->getProductUrl() ?>">
                            <?php echo $this->htmlEscape($_item->getName()) ?>
                    </a>
                </div>
                <div class="price">
                           <?php echo $this->getPriceHtml($_item, true) ?>
                </div>
           </div>
        <?php endforeach; ?>
        <div class="clearer"></div>
        </div>
    <?php endif; ?>
2
  • Loading the product model within a loop will not be good for performance. I don't recommend this solution.
    – BlueC
    Jun 17, 2019 at 14:44
  • I tried your solution and it didn't work, this did.
    – totneschap
    Jun 17, 2019 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.