2

At the moment tier prices are running perfectly at single products. But when I'm trying to print tier price at cross-sell products, the price does not shows up. It just don't echo anything out.

The php code I am trying to use is the following.

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

Am I missing something maybe? :)

Regards

2

getTierPriceHtml is not a method of the product model class. That's why you get an empty result. Try it like this:

<?php foreach ($_crossSellProducts as $_item): ?>
    <?php $_item = Mage::getModel('catalog/product')->load($_item->getId()); ?>
    <?php $_block = Mage::app()->getLayout()->createBlock('catalog/product_view')->setProduct($_item);?>
    <?php echo $_block->getTierPriceHtml(); ?>
<?php endforeach; ?>

or you can try this to avoid instantiating the same block each time.

<?php $_block = Mage::app()->getLayout()->createBlock('catalog/product_view');?>
<?php foreach ($_crossSellProducts as $_item): ?>
    <?php $_item = Mage::getModel('catalog/product')->load($_item->getId()); ?>
    <?php echo $_block->setProduct($_item)->getTierPriceHtml(); ?>
<?php endforeach; ?>
  • Thank you for your suggestions. However, there's some problems. If i use your examples, it only prints out the single product price in cross sell. So if the current viewed product's price is $4, all the crossell's products has the same price, $4. Any idea why? :) – simond Nov 11 '13 at 11:27
  • Actually, if i use following code, <?php echo '<pre>'; print_r($_item['tier_price']); echo '</pre>'; ?> I get the single tierprice for each crosssell products, but off-course since it's an printed array, it's not formatted :P – simond Nov 11 '13 at 11:29
  • @SimonDuun. Then you can use that value to style it as you want. – Marius Nov 11 '13 at 11:35
  • @SimonDuun. Try with the first option I suggested. – Marius Nov 11 '13 at 11:36

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.