0

I try to overwrite the template app\design\frontend\venedor\custom\template\catalog\product\view\options\type\select.phtml with app\design\frontend\base\default\template\wr\catalog\product\view\options\type\select.phtml

So I have rewritten the constructor of the class Mage_Catalog_Block_Product_View_Options_Type_Select.

Hint: My Extensions Namespace is "WR" and the name of the Extension is "EPO".

class WR_EPO_Block_Catalog_Product_View_Options_Type_Select extends Mage_Catalog_Block_Product_View_Options_Type_Select
{

    public function __construct()
    {
        Mage::Log('my constructor was called', 7, "p.log");
        parent::__construct();

        $this->setTemplate('wr/catalog/product/view/options/type/select.phtml');
    }

The rewrite works fine, I get the log entry in p.log.

But the old template is still getting loaded. I already cleared the cache.

I successfully replaced another template in adminhtml the same way, so why does it not work in this case?

2 Answers 2

1

You just have to copy it from base to your current theme then, you clean a cache :

From :

app/design/frontend/base/default/template/catalog/product/view/options/type/select.phtml

to :

app/design/frontend/{current-theme}/{name}/template/catalog/product/view/options/type/select.phtml

Note : with your wr/ folder it will not work, in this case you should do it via xml. Magento know catalog/product/view/options/type/select.phtml and not wr/catalog/product/view/options/type/select.phtml

Update : If you want to change the architecture folders, you can do it via Xml like this :

app/design/frontend/{current-theme}/{name}/layout/local.xml

<catalog_product_view>
    <reference name="product.info.options.wrapper" >
        <block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
            <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>wr/catalog/product/view/options/type/select.phtml</template></action>
        </block>
    </reference>
</catalog_product_view>
2
  • Is this the only way? Can't I override it?
    – Black
    Commented Nov 20, 2018 at 17:52
  • Look my update.
    – PЯINCƎ
    Commented Nov 20, 2018 at 18:00
0

I think you should change the template inside a xml.

Indeed, the Mage_Catalog_Block_Product_View_Options_Type_Select class (or parents) does not have a setTemplate method in constructor.

The template of this class (catalog/product/view/options/type/select.phtml) is set in app/design/frontend/rwd/default/layout/catalog.xml:251 (I just looked in the native rwd theme but you can find it in base theme too) with

<action method="addOptionRenderer">
    <type>select</type>
    <block>catalog/product_view_options_type_select</block>
    <template>catalog/product/view/options/type/select.phtml</template>    
</action>

So you should override it with the xml way.

1
  • I tried to override it via my layout file which is in app/design/frontend/base/default but this did not worked too.
    – Black
    Commented Nov 20, 2018 at 17:31

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.