1

hello I have a problem again with my rewrite, I tried to rewrite the product view block

app/code/local/Lesson/Test/etc/config.xml

 <?xml version="1.0"?>
    <config>
        <modules>
            <Lesson_Test>
                <version>1.0.0</version>
            </Lesson_Test>
        </modules>
        <global>
            <blocks>
                <catalog>
                    <rewrite>
                        <product_view>Lesson_Test_Block_Catalog_Product_View</product_view>
                    </rewrite>
                </catalog>
            </blocks>
        </global>
    </config>

app/code/local/Lesson/Test/Block/Catalog/Product/View.php

<?php
Class Lesson_Test_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
{
    public function afficherLesInfos()
    {
        return 'les infos complementaires';
    }
}

app/etc/modules/Lesson.xml

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

I tried to access

http://127.0.0.1/magento/magento-tutorial/index.php/
http://127.0.0.1/magento/magento-tutorial/index.php/lesson
http://127.0.0.1/magento/magento-tutorial/index.php/lesson/product
http://127.0.0.1/magento/magento-tutorial/index.php/lesson/product/view
http://127.0.0.1/magento/magento-tutorial/index.php/product/view
http://127.0.0.1/magento/magento-tutorial/index.php/lesson/catalog/product/view

no one of that at work

  • 1
    your global configuration file name should be Lesson_Test.xml instead of Lesson.xml – Amit Bera Jun 7 '16 at 9:20
3

I'm confused by what you want to achieve here.

Rewriting a block does not involve changing the URLs.

In your case, you're rewriting the catalog product view block so you just need to access a normal product view page.

But the way you're rewriting the block and adding a new method afficherLesInfos won't do anything if you don't call that method in your template.

To get that working you need to edit app/design/<your_package>/<your_theme>/template/catalog/product/view.phtml and add the following line to the template:

<?php echo $this->afficherLesInfos(); ?>

Also app/code/local/Lesson/Test/etc/config.php must be an XML file and not a PHP file like you said.

On top of that, as Amit said, your global config should be renamed from Lesson.xml to Lesson_Test.xml

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.