0

I'm trying to override Magento's functionality to create a sitemap.xml file (Catalog > Google Sitemap in the backend). The idea of my override is that not all product- and category-URLs should be included in the sitemap, I need the category-path of a product or category to determine whether to include it or not.

So this is what I did, I added this to my module's config.xml:

...
<global>
    ...
    <models>
        ...
        <sitemap>
            <rewrite>
                <sitemap>Company_Module_Model_Sitemap</sitemap>
            </rewrite>
        </sitemap>
        ...
    </models>
    ...
</global>
...

The class Company_Module_Model_Sitemap is overridden well, but it turned out I also need to override the resource model to be able to achieve my goal, so I added the following to the config.xml file (between the models-tag):

<sitemap_resource>
    <rewrite>
        <sitemap>Company_Module_Model_Sitemap_Resource_Catalog_Category</sitemap>
    </rewrite>
</sitemap_resource>

Now it starts to go wrong.. It somehow won't even load the backend grid anymore, navigating to the backend page of Google Sitemap yields the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sitemap_id' in 'order clause'

Curently, the only content of the Company_Module_Model_Sitemap_Resource_Catalog_Category class is the following:

class Company_Module_Model_Sitemap_Resource_Catalog_Category
     extends Mage_Sitemap_Model_Resource_Catalog_Category { }

So finally, my question: how to correctly override the Mage_Sitemap_Model_Resource_Catalog_Category class in Magento?

4

1 回答 1

1

啊! 没关系,我自己发现了错误。这个:

<sitemap_resource>
    <rewrite>
        <sitemap>Company_Module_Model_Sitemap_Resource_Catalog_Category</sitemap>
    </rewrite>
</sitemap_resource>

应该是这样的:

<sitemap_resource>
    <rewrite>
        <catalog_category>Company_Module_Model_Sitemap_Resource_Catalog_Category</catalog_category>
    </rewrite>
</sitemap_resource>
于 2013-04-26T14:23:35.270 回答