0
votes

I have been trying to rewrite a class in Magento and I be doing all the correct procedures, however I am not getting.

I'm trying to rewrite app\code\core\Mage\Catalog\Model\Product\Attribute\Media\Api.php

Thanks in advance to anyone who can help me.

<config>
    <modules>
        <Namespace_Catalog>
            <version>1.6.0.0.14</version>
        </Namespace_Catalog>
    </modules>
    <global>
        <models>
            <catalog>
                <rewrite>    
                    <product_attribute_media_api>Namespace_Catalog_Model_Product_Attribute_Media_Api</product_attribute_media_api>
                </rewrite>
            </catalog>
        </models>
    </global>
</config>

Yeah I forgot to say that part In the app/etc/modules/ I have with depends tag. I've tried with and without the tag depends and it never worked. I think I'm really doing everything right.

<?xml version="1.0"?>
<config>
<modules>
    <Namespace_Catalog>
        <active>true</active>
        <codePool>local</codePool>
        <depends>
            <Mage_Catalog />
        </depends>
    </Namespace_Catalog>
</modules>
</config>

In the app\code\local\Namespace\Catalog\Model\Product\Attribute\Media\Api.php I have class Namespace_Catalog_Model_Product_Attribute_Media_Api extends Mage_Catalog_Model_Product_Attribute_Media_Api

I rewrote the function removes and let it equal to the original, but with Mage::log('rewrote', null, 'rewrote.log'), to know that he had successfully rewritten.

I cleared my cache.

I corrected codePool tag for case sensitive. I checked /var/log/ and not found any error inside exception.log and system.log. My Index.php is set as developer mode and ini_set('display_errors', 1); uncommented.

I followed a tutorial on Magento here

This describes the state of your Magento system. It lists all modules, models, classes, event listeners or almost anything else you could think of. For example, consider the config.xml file you created above. If you search the XML file in your browser for the text Namespace_Catalog_Model_Product_Attribute_Media_Api you'll find your class listed. Every module's config.xml file is parsed by Magento and included in the global config.

Here is my class to write. It seems okay. What can I be missing?

<catalog>
    <class>Mage_Catalog_Model</class>
    <resourceModel>catalog_resource</resourceModel>
    <rewrite>
        <product_attribute_media_api>Namespace_Catalog_Model_Product_Attribute_Media_Api</product_attribute_media_api>
    </rewrite>
</catalog>
3
Your code looks ok. Make sure you cleared the cache. also check if your config file is valid. See var/log for errors. Tunr on developer mode to see any errors that might appear.Marius

3 Answers

0
votes

Your code seems to be right. Have you created an XML-file in app/etc/modules/?

It should look like:

Namespace_Catalog.xml

< ?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Catalog>
            <active>true</active>
            <codepool>local</codepool>
        </Namespace_Catalog>
    </modules>
</config>
0
votes

i think you missed something

 <version>1.6.0.0.14</version>

should be same with

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Catalog>
            <active>true</active>
            <codepool>local</codepool>
            <version>1.6.0.0.14</version>
        </Namespace_Catalog>
    </modules>

0
votes

"Codepool" is case sensitiv.

Try:

<codePool>local</codePool>

instead of

<codepool>local</codepool>