Błąd Magento podczas wyłączania modułu
Stworzyłem moduł, a następnie użyłem skryptu aktualizacji, aby dodać atrybut multiselect. atrybut używa „source”, aby uzyskać wartości dynamicznie. kod jest następujący:
Dodaj atrybut:
$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();
Źródłem jest:
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;
}
}
Kod działa poprawnie Mogę pobrać wartość dynamicznie, ale problem, gdy moduł jest wyłączony, rzuca katalog błędów, nie można go znaleźć podczas tworzenia nowego produktu w admin.
błąd:
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
Czy istnieje sposób, aby zapobiec temu błędowi, gdy moduł jest wyłączony? Nie chcę odinstalować, ponieważ stracę wszystkie dane w mojej db. Dziękujemy za przewodnik lub pomoc, którą możesz mi zapewnić.