0

I found Rajeev K Tomy's answer to this stackexchange question (Add Cross sell block on product page) very helpful to add a cross-sell block to my product page.

After implementing the solution, however, the cross-sell products on my product page do not load their thumbnail image, title, or price correctly. Instead, the magento placeholder thumbnail loads, the title is absent, and the price displays $0.00.

Interestingly, clicking on the thumbnail redirects to the proper cross-sell product page and the add-to-cart button also preserves functionality. Furthermore, if I add the original product to the cart, my shopping cart's cross-sell block displays with the proper images,titles, and prices.

Tracking the problem down to crossell.phtml:

app/design/frontend/my_package/default/template/checkout/cart/crossell.phtml

Why does some of the php (such as the following from crossell.phtml) not work when it is applied to the product page?

<img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(210); ?>" </img>

<h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>

<?php echo $this->getPriceHtml($_item, true) ?>

Any ideas how to resolve this problem?

1 Answer 1

1

I was able to gain the functionality that was missing by incorporating part of another stackexchange question (Cross-sell product is not showing in the product detail page) to the original solution I used (Add Cross sell block on product page).

Specifically, edit this file as follows: app\code\community\Rkt\CrossSell\Block\Catalog\Product\View\Crosssell.php

/**
 * Get crosssell items
 *
 * @return array
 */
public function getItems()
{
    $items = $this->getData('items');
    if (is_null($items)) {
        $items = $this->getProduct()->getCrossSellProductCollection()
    ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
    ->setPositionOrder()
    ->addStoreFilter();
        $this->setData('items', $items);
    }
    return $items;
}

Hope this helps anyone who runs into the same problem I had.

Your Answer

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

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