我正在尝试扩展:Mage_Catalog_Model_Product_Visibility
我正在修改 Visibility.php 文件中的以下内容:
public function getVisibleInSiteIds()
{
return array(self::VISIBILITY_IN_SEARCH, self::VISIBILITY_IN_CATALOG, self::VISIBILITY_BOTH);
}
进入:
public function getVisibleInSiteIds()
{
return array(self::VISIBILITY_IN_SEARCH, self::VISIBILITY_IN_CATALOG, self::VISIBILITY_BOTH, self::VISIBILITY_NOT_VISIBLE);
}
设置为不可见的过时产品仍会从其直接 URL 显示(默认情况下,Magento 将显示 404)。
我通过修改核心文件对此进行了测试,它可以工作。但我想创建一个小扩展,到目前为止我无法让它工作。这是我到目前为止所做的:
应用程序/etc/modules/CustomCode_InvisibleProducts.xml
<?xml version="1.0"?>
<config>
<modules>
<CustomCode_InvisibleProducts>
<active>true</active>
<codePool>local</codePool>
</CustomCode_InvisibleProducts>
</modules>
</config>
app/code/local/CustomCode/InvisibleProducts/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<CustomCode_InvisibleProducts>
<version>0.1.0</version>
</CustomCode_InvisibleProducts>
</modules>
<global>
<models>
<customcode_invisibleproducts>
<class>CustomCode_InvisibleProducts_Model</class>
</customcode_invisibleproducts>
<catalog>
<rewrite>
<product_visibility>CustomCode_InvisibleProducts_Model_Catalog_Product_Visibility</product_visibility>
</rewrite>
</catalog>
</models>
</global>
</config>
app/code/local/CustomCode/InvisibleProducts/Model/Catalog/Product/Visibility.php
class CustomCode_InvisibleProducts_Model_Catalog_Product_Visibility extends Mage_Catalog_Model_Product_Visibility
{
.....
不知何故,我没有正确扩展模型,因为似乎没有任何事情发生/改变。
谢谢您的帮助!