1
votes

I'm trying to override the Catalog Layer class of Magento 1.9 so that not working after longs times to find error :(

No errors in logs, module work correctly except model rewrite.

app/etc/modules/comx_fab.xml:

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

        <depends>
                <Mage_Catalog />
        </depends>
        </Comx_Fab>
    </modules>
</config>

app/code/local/Comx/Fab/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Comx_Fab>
            <version>0.2.0</version>
        </Comx_Fab>
    </modules>

    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product_list_toolbar>Comx_Fab_Catalog_Block_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        <page>
        <rewrite>
            <html_topmenu>Comx_Fab_Page_Block_Html_Topmenu</html_topmenu>
        </rewrite>
        </page>
        </blocks>
        <models>
        <catalog>
                <rewrite>
                    <layer>Comx_Fab_Catalog_Model_Layer</layer>
                </rewrite>
            </catalog>
        </models>
    </global>
</config>

app/code/local/Comx/Fab/Catalog/Model/Layer.php:

<?php
class Comx_Fab_Catalog_Model_Layer extends Mage_Catalog_Model_Layer {
/**
 * Initialize product collection
 *
 * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection
 * @return Mage_Catalog_Model_Layer
 */
public function prepareProductCollection($collection) {
    exit('Good!');
}
}

Already done:

  • cache refresh, "cache" folder deleted,
  • compare my magento code to current magento release (no diff)
  • check owner/chmod

Related: Magento: how to override a model in a local module

3

3 Answers

2
votes

Found! :)

It's extension conflicts!

How to resolve:

  1. Check extension are conflicted with this free magento module: https://marketplace.magento.com/alekseon-modules-conflict-detector.html
  2. Locate conflicted extension and use one solution for resolve (read bottom "How do I resolve conflicts?")
  3. Clear cache

In my case, a simply add extension order into the "depends" capability:

<depends>
    <Mage_Catalog />
    <Trego_Ajaxfilter />
</depends>

How do I resolve conflicts? You have 3 choices for resolving conflicts:

  1. Merge the code from one conflicting file into another and switch off the rewrite config.xml in one
  2. Switch off the rewrite in one config.xml and then make the conflicting extension PHP file extend the other extension
  3. Use the capability to make one extension depend on another. They will then rewrite in that order

Read more: http://www.webshopapps.com/blog/2010/11/resolving-magento-extension-conflicts/

1
votes

Others coming here might find this useful, especially if they can find the module being loaded in "Disable Module Outputs" list: Admin Panel > Configuration > Advanced > Advanced.

Depending on how you setup your local environment you may have copied in local.xml in app/etc/local.xml that contains: <disable_local_modules>false</disable_local_modules>

Which prevents anything from the local codePool from running, while it will still show up in the Disable Module Outputs list.

0
votes

Issue in your Module structure....

main issue in Cong=fig xml path and Model id path

app/code/local/Comx/Fab/Catalog/Model/Layer.php

Should be

app/code/local/Comx/Fab/Model/Catalog/Layer.php

Also change the path class according to file path

class Comx_Fab_Catalog_Model_Layer extends Mage_Catalog_Model_Layer {

to class Comx_Fab_Model_Catalog_Layer extends Mage_Catalog_Model_Layer {

All the Path structure modules are wrong and class paths.Modify all Block file path

Here the modified config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Comx_Fab>
            <version>0.2.0</version>
        </Comx_Fab>
    </modules>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product_list_toolbar>Comx_Fab_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
        <page>
        <rewrite>
            <html_topmenu>Comx_Fab_Block_Page_Html_Topmenu</html_topmenu>
        </rewrite>
        </page>
        </blocks>
        <models>
        <catalog>
                <rewrite>
                    <layer>Comx_Fab_Model_Catalog_Layer</layer>
                </rewrite>
            </catalog>
        </models>
    </global>
</config>

More details of Magento module structure

http://www.insync.co.in/creating-custom-module-magento/
https://mementia.com/creating-custom-magento-module/
http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table