コード例 #1
0
ファイル: Group.php プロジェクト: shabbirvividads/magento2
 /**
  * Checks if attribute group exists
  *
  * @param \Magento\Eav\Model\Entity\Attribute\Group $object
  * @return bool
  */
 public function itemExists($object)
 {
     $adapter = $this->_getReadAdapter();
     $bind = ['attribute_set_id' => $object->getAttributeSetId(), 'attribute_group_name' => $object->getAttributeGroupName()];
     $select = $adapter->select()->from($this->getMainTable())->where('attribute_set_id = :attribute_set_id')->where('attribute_group_name = :attribute_group_name');
     return $adapter->fetchRow($select, $bind) > 0;
 }
コード例 #2
0
ファイル: Group.php プロジェクト: Doability/magento2dev
 private function saveGroup()
 {
     if ($this->groupObj->getId()) {
         return array('result' => true);
     }
     if (!$this->attributeSetObj) {
         return array('result' => false, 'error' => "Attribute Set '{$this->attributeSetId}' is not found.");
     }
     $this->groupObj->setAttributeGroupName($this->name);
     $this->groupObj->setAttributeSetId($this->attributeSetId);
     try {
         $this->groupObj->save();
     } catch (\Exception $e) {
         return array('result' => false, 'error' => $e->getMessage());
     }
     return array('result' => true, 'obj' => $this->groupObj);
 }
コード例 #3
0
ファイル: Group.php プロジェクト: pradeep-wagento/magento2
 /**
  * Group constructor.
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  * @param AttributeValueFactory $customAttributeFactory
  * @param \Magento\Framework\Filter\Translit $translitFilter
  * @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeCollectionFactory
  * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
  * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
  * @param array $data
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Filter\Translit $translitFilter, \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
 {
     $this->_attributeCollectionFactory = $attributeCollectionFactory;
     parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $translitFilter, $resource, $resourceCollection, $data);
 }
コード例 #4
0
ファイル: Group.php プロジェクト: aiesh/magento2
 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory
  * @param \Magento\Framework\Model\Resource\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\Db $resourceCollection
  * @param array $data
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array())
 {
     $this->_attributeCollectionFactory = $attributeCollectionFactory;
     parent::__construct($context, $registry, $resource, $resourceCollection, $data);
 }
コード例 #5
0
 /**
  * @dataProvider attributeGroupCodeDataProvider
  * @param string $groupName
  * @param string $groupCode
  */
 public function testBeforeSaveGeneratesGroupCodeBasedOnGroupName($groupName, $groupCode)
 {
     $this->model->setAttributeGroupName($groupName);
     $this->model->beforeSave();
     $this->assertEquals($groupCode, $this->model->getAttributeGroupCode());
 }