1

I need to extend getPriceHtml method of Mage_Catalog_Block_Products class.

Why? I need to change template for price only for my custom extension of RSS (Aph_Rss > works fine!). This extension use getPriceHtlmRss($product,true) new method, now I want extend getPriceHtml > getPriceHtmlRss to add inline css into price-last / special-price tag for email-marketing automation in specific template > priceRss.phtml

I've created Aph/Catalog/etc -> config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product>Aph_Catalog_Block_Product</product>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

Then created Aph/Catalog/Block/Product.php

<?php

include('Mage/Catalog/Block/Product.php');

class Aph_Catalog_Block_Product extends Mage_Catalog_Block_Product
{
    protected $_finalPrice = array();

    public function getPriceHtmlRss($product)
    {
        $this->setTemplate('catalog/product/priceRss.phtml');
        $this->setProduct($product);
        return $this->toHtml();
    }
}

Then created: app/design/frontend/default/mytheme/template/catalog/product/priceRss.phtml

Last step: Created file app/etc/modules/Aph_Catalog.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Aph_Catalog>
            <active>true</active>
            <codePool>local</codePool>
        </Aph_Catalog>
    </modules>
</config>

Visiting http://www.mydomain.tld/rss/catalog/category/cid/193/store_id/2/ -> no price shown. priceRss.phtml not loaded. Why?

2 Answers 2

0

You have rewrite Mage_Catalog_Block_Product class properly.

As per as my knowledge ,on www.mydomain.tld/rss page Mage_Catalog_Block_Product block class does not rendered.

Basically, www.mydomain.tld/rss page Mage_Rss_Block_List rendered.

Please check at rss.xml file for understand the layout of rss page at your theme layout folder app/design/frontend/YourPackage/YourTheme/layout.

Hope you will be understand.

4
  • I think you need some additional information! Commented Oct 7, 2015 at 5:20
  • if you have then please add those on question
    – Amit Bera
    Commented Oct 7, 2015 at 5:20
  • I think you need some additional information! These modules (Aph_Rss and Aph_Catalog) allow to create newsletter via RSS by custom CSS for price box. Aph_Rss module render thumbnail 300x300px (default is 75x75px) and use new method getPriceHtmlRss to show price with inline CSS. getPriceHtmlRss is a new method that extends Mage_Catalog_Block_Product. Why do that? Because Google and Android Gmail App use a preprocessor to strip HTML / CSS in the body. By that I need to insert inline CSS into html and to do this I've created new template priceRss.phtml Commented Oct 7, 2015 at 5:28
  • Kindly. add this info to question thus any user can understand
    – Amit Bera
    Commented Oct 7, 2015 at 6:27
0

Your question seems bit unclear for me. However check below points.

  1. Your module should be depend upon Mage_Catalog module. You can do this via activation file of your module.

    File : app\etc\modules\Aph_Catalog.xml

    <config>
        <modules>
            <Aph_Catalog>
                <active>true</active>
                <codePool>local</codePool>
                <depends>
                    <Mage_Catalog/>
                </depends>
            </Aph_Catalog>
        </modules>
    </config>
    
  2. Make sure your module resides in local codepool.ie at app\code\local.

  3. You said you have a custom extension Aph_Rss. By it's name I assume it customized Magento's default RSS Module, ie Mage_Rss. You again said you have a problem with getPriceHtmlRss() which comes inside the custom extension Aph_Rss. If that is the case, you need to overwrite Aph_Rss block class not Mage_Catalog_Block_Product block class. If this is the case, then you need to provide more details on which block class in Aph_Rss holds the method getPriceHtmlRss() and give more details about that extension.

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.