Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
magento:覆盖Mage\u CatalogSearch\u Model\u查询以无效的方法prepareResult结束_Magento_Magento 1.9 - Fatal编程技术网

magento:覆盖Mage\u CatalogSearch\u Model\u查询以无效的方法prepareResult结束

magento:覆盖Mage\u CatalogSearch\u Model\u查询以无效的方法prepareResult结束,magento,magento-1.9,Magento,Magento 1.9,我试图覆盖Mage\u CatalogSearch\u Model\u查询 现在我试着尽可能少地做: 将重写块添加到config.xml <config> ... <global> <models> ... <catalogsearch> <rewrite> <fulltext>MyCompany_CatalogSearch_Model_Query<

我试图覆盖Mage\u CatalogSearch\u Model\u查询

现在我试着尽可能少地做:

将重写块添加到config.xml

<config>
...
  <global>
    <models>
      ...
      <catalogsearch>
        <rewrite>
          <fulltext>MyCompany_CatalogSearch_Model_Query</fulltext>
        </rewrite>
      </catalogsearch>
    </models>
  </global>
</config>

...
...
MyCompany\u目录搜索\u模型\u查询
添加我的类

    <?php

    class MyCompany_CatalogSearch_Model_Query extends Mage_CatalogSearch_Model_Query
    {
    }

看起来您正在尝试重写Mage\u CatalogSearch\u Model\u全文类,而不是Mage\u CatalogSearch\u Model\u查询类。这引发了这个问题

调用catalogsearch/fulltext时,应使用catalogsearch/query中缺少的prepareResult方法

如果您的目标是重写catalogsearch/query,请按以下方式重写配置:

  <catalogsearch>
    <rewrite>
      <query>MyCompany_CatalogSearch_Model_Query</query>
    </rewrite>
  </catalogsearch>
class MyCompany_CatalogSearch_Model_Query extends Mage_CatalogSearch_Model_Fulltext
    {
    }
希望有帮助。:)

非常感谢!它可以工作:)创建config.xmls时,复制和粘贴不是我的朋友。此外,我发现很难准确地知道哪些值是以特殊方式需要的,哪些值在这些xml文件中必须是唯一的(但可以组成)。这就是为什么我有时不太注意它们的原因。