【发布时间】:2016-04-21 00:28:44
【问题描述】:
我目前有以下创建新属性集的代码:
use Magento\Framework\ObjectManagerInterface;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class AttributeModel extends \Magento\Framework\Model\AbstractModel
{
const ENTITY_TYPE = \Magento\Catalog\Model\Product::ENTITY;
protected $_objectManager;
protected $_moduleDataSetup;
protected $_eavSetupFactory;
public function __construct(
ObjectManagerInterface $objectManager,
ModuleDataSetupInterface $moduleDataSetup,
EavSetupFactory $eavSetupFactory,
) {
$this->_objectManager = $objectManager;
$this->_moduleDataSetup = $moduleDataSetup;
$this->_eavSetupFactory = $eavSetupFactory;
}
public function createSet($name)
{
$eavSetup = $this->_eavSetupFactory->create([
'setup' => $this->_moduleDataSetup
]);
$eavSetup->addAttributeSet(self::ENTITY_TYPE, $name, 0);
}
}
但是该集合没有分配给它的属性。如何根据默认设置创建集合,以便预先填充基本属性?
非常感谢任何帮助。
【问题讨论】:
标签: php magento2 magento-2.0