禁用模块时Magento错误

时间:2013-12-17 12:26:53

标签: magento module attributes

我创建了一个模块,然后使用升级脚本添加多选属性。该属性正在使用' source'动态获取它的值。代码如下:

添加属性:

$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');

$installer->startSetup();

$productEntityId = $installer->getEntityTypeId('catalog_product');

$allAttributeSetIds = $installer->getAllAttributeSetIds($productEntityId);

$installer->addAttribute('catalog_product', 'badge',array(
        'label' => 'Badge', 
        'type' => 'varchar', 
        'input' => 'multiselect', 
        'backend' => 'eav/entity_attribute_backend_array', 
        'frontend' => '', 
        'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
        'visible' => true, 
        'required' => false, 
        'user_defined' => false, 
        'searchable' => false, 
        'filterable' => false, 
        'comparable' => false, 
        'source'        => 'module/entity_attribute_source_superbadge_config',
        'visible_on_front' => false, 
        'visible_in_advanced_search' => false, 
        'unique' => false ));



$attributeId= $installer->getAttributeId($productEntityId, 'badge');

//add to General Group of all attribute sets
foreach($allAttributeSetIds as $attributeSetId) {
    $installer->addAttributeToSet($productEntityId, $attributeSetId, 'General',  $attributeId);
}

$installer->endSetup();

来源是:

class Module_Model_Entity_Attribute_Source_Superbadge_Config extends Mage_Eav_Model_Entity_Attribute_Source_Boolean
{
    /**
     * Retrieve all attribute options
     *
     * @return array
     */

     public function getAllOptions()
    {
        if (!$this->_options) {
            $superbadge = array();
            $badges = Mage::getModel('module/rule')->getCollection()->getSuperBadge();
            foreach ($badges as $badge){
                $superbadge[] = array('label' => $badge->getName(),
                        'value' =>  $badge->getId());
            }
            $this->_options = $superbadge;
        }
        return $this->_options;
    }

}

代码工作正常我可以动态检索值但是当模块被禁用时出现问题是在管理员创建新产品时无法找到错误目录。

错误:

Warning: include(Mage\Module\Model\Entity\Attribute\Source\Superbadge\Config.php) [function.include]: failed to open stream: No such file or directory  in C:\Sites\project\development\lib\Varien\Autoload.php on line 93

模块禁用时有没有办法防止出现此错误?我不想做卸载,因为我将丢失我的数据库中的所有数据。感谢您提供的任何指导或帮助..

1 个答案:

答案 0 :(得分:0)

首先,您是否在禁用模块后刷新缓存?

或者这可能是编译错误?试试this

尝试在mageDebugBacktrace()中调用/lib/Varien/Autoload.php on line 93来确定问题的确切位置。

如果以上某些内容对您有用,请告诉我们!