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

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; ?>
  • Loading the product model within a loop will not be good for performance. I don't recommend this solution. – BlueC Jun 17 at 14:44
  • I tried your solution and it didn't work, this did. – totneschap Jun 17 at 15:11

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.