我希望在接口中使用magento创建新表,而不继承安装类。我试图获得设置的资源模型。这不起作用:
require_once 'app/Mage.php';
Mage::init();
$setup = Mage::getResourceModel('catalog/setup');
我也在考虑Mage::getResourceModel('core/resource_setup')
,但我有一个错误:Fatal error: Call to a member function startSetup() on a non-object in C:\xampp\
htdocs\LPP_MAGENTO_EE_CUSTOM\app\code\core\Mage\Core\Model\Resource\Setup.php on
line 944
答案 0 :(得分:1)
我使用$setup = Mage::getModel('eav/entity_setup', 'core_setup')
示例在我的代码中为Category创建新属性:
require_once 'app/Mage.php';
Mage::init();
$setup = Mage::getModel('eav/entity_setup', 'core_setup');
$setup->addAttribute('catalog_category', 'xxx', array(
...
));