Actually my module is overriding two files. My module is overriding the default search. Here's the code: -
& lt; Model & gt; & Lt; Catalogsearch & gt; & Lt; Rewrite & gt; & Lt; Indexer_fulltext & gt; WY_SearchIndex_Model_Catalogsearch_Indexer_Fulltext & lt; / Indexer_fulltext & gt; & Lt; Layer & gt; WY_SearchIndex_Model_Catalogsearch_Layer & lt; / Layer & gt; & Lt; / Rewrite & gt; & Lt; / Catalogsearch & gt; ...
Now what do I need to do is enable / disable my module admin & amp; Suppose it has been disabled from the administrator, it should not override those 2 files & amp; Thus the default search will run.
Now I can not correct ifconfig in this config.xml? By the way: -
& lt; Model & gt; & Lt; Catalogsearch ifconfig = "searchsphinx / general / enabledornot" & gt;
So what can be done? What I just did - put the condition in one of the files ie Layer.php file of my module -
if (! Mage :: getStoreConfig ('searchsphinx / general / enabledornot')) {// This will call the search of the default module ... there is no way within the square class WY_SearchIndex_Model_Catalogsearch_Layer WY_SearchIndex_Model_Catalogsearch_Layer_Extends {}} else {// This will call the search class of my module WY_SearchIndex_Model_Catalogsearch_LayerWY_SearchIndex_Model_Catalogsearch_Layer_Extends Expanded {...} }
I know that this is very bad, l What I am wondering whether the module is disabled by an administrator, should not override the above files.
How can I do this? Any suggestions please?
Thanks
There is a way to make a conditional rewrite, though I Not sure that this is a valid practice.
- Remove the rewrites from the configuration
-
Enter the following in your config.xml
& lt; Global & gt; ... & lt; Event & gt; & Lt; Controller_front_init_before & gt; & Lt; Supervisors & gt; & Lt; Wy_search_rewrite_classes & gt; & Lt; Type & gt; Model & lt; / Type & gt; & Lt; Classes & gt; Searchsphinx / supervisor & lt; / Square & gt; & Lt; Method & gt; RewriteClasses & lt; / Method & gt; & Lt; / Wy_search_rewrite_classes & gt; & Lt; / Supervisors & gt; & Lt; / Controller_front_init_before & gt; & Lt; / Events & gt; ... & lt; / Global & gt;
-
Observer in the model folder. Create a Php file (if you do not have one)
class WY_SearchIndex_Model_Observer {.. / ** * rewrite the required classes * * @company variable_regent_observar $ inspector * / public function rewrite classes ( Varien_Event_Observer $ Inspector) {$ isRewriteEnabled = Mage :: getStoreConfig ('searchsphinx / general / enabledornot'); If ($ isRewriteEnabled) {Mage :: getConfig () - & gt; SetNode ('global / model / catalog / search / rewrite / indexing_full text', 'WY_SearchIndex_Model_Catalogsearch_Indexer_Fulltext'); Dana :: getConfig () - & gt; SetNode ('global / model / catalog search / rewrite / layer', 'WY_SearchIndex_Model_Catalogsearch_Layer'); }}
No comments:
Post a Comment