5

I want to show price exclude and include in custom product slider in Magento home page. For this, I have tried almost all things but could not success below is my approach

In XML part I have added code:

<block type="catalog/product_view" name="product.tierprices" template="productslider/best-seller.phtml">
    <action method="setTierPriceTemplate">
        <template>catalog/product/view/tierprices.phtml</template>
    </action>
</block>  

And in code I have echo:

$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->sku);
$price = $_product->getPrice();
$prices = $this->getTierPrices($_product);

or:

$this->getPriceHtml($_product, true);

But it doesn't show right price ex.vat and incl.vat

Please help me

  • Please show layout xml code for slider. – Amit Bera Mar 20 '15 at 9:36
1

Edited:

All the old solution is deleted.

Below solution,will works.

  1. In other show tier prices at anywhere,you need to first add tier price to that collection. So just add addTierPriceData() to that collection.

  2. Then inside foreach loop of that collection add below code:

    $this->getLayout()->createBlock('catalog/product_price')
        ->setTemplate('catalog/product/view/tierprices.phtml')
        ->setProduct($_product)
        ->setName('tier_' . $_product->getId())
        ->setInGrouped($_product->isGrouped())
        ->setParent(null)
        ->callParentToHtml();
    

This is show tier price like product details page.

Example:

Suppose, you want to show tier price at category & Catalog Search Page, then first add addTierPriceData() at _getProductCollection function's return value ( return $this->_productCollection->addTierPriceData();)

Then at list.phtml inside foreach loop add below code:

$this->getLayout()->createBlock('catalog/product_price')
    ->setTemplate('catalog/product/view/tierprices.phtml')
    ->setProduct($_product)
    ->setName('tier_' . $_product->getId())
    ->setInGrouped($_product->isGrouped())
    ->setParent(null)
    ->callParentToHtml();
  • There is error : Call to a member function setProductClassId() on a non-object in – Sandeep Mar 20 '15 at 8:59
  • have you try with issue1 and issue2 – Amit Bera Mar 20 '15 at 9:19
  • I have use full code. Ok let me try there is any thing write in xml file ? <block type="catalog/product_view" name="product.tierprices" template="productslider/best-seller.phtml"> <action method="setTierPriceTemplate><template>catalog/product/view/tierprices.phtml</template></action> </block> – Sandeep Mar 20 '15 at 9:24
  • wait .. i will give you details which is not need the xml code – Amit Bera Mar 20 '15 at 9:25
  • please try $this->getTierPriceHtml($_product). It is work if your slider block class is extend from Mage_Catalog_Block_Product_Abstract.No need the xml code.. – Amit Bera Mar 20 '15 at 9:31
1

To simply get all the tier prices you could try the following:

$prices = $product->getFormatedTierPrice();

The reason your call for $this->getTierPrices($_product); is not working, because your block is not of a type that extends Mage_Catalog_Block_Product_Abstract which contains this getTierPrices function.

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.