コード例 #1
0
ファイル: Builder.php プロジェクト: Doability/magento2dev
 private function saveAttributeSet()
 {
     if ($this->attributeSetObj->getId()) {
         return array('result' => true, 'obj' => $this->attributeSetObj);
     }
     $this->attributeSetObj->setEntityTypeId($this->entityTypeId)->setAttributeSetName($this->setName);
     try {
         $this->attributeSetObj->validate();
         $this->attributeSetObj->save();
         $this->attributeSetObj->initFromSkeleton($this->skeletonId)->save();
     } catch (\Exception $e) {
         return array('result' => false, 'error' => $e->getMessage());
     }
     return array('result' => true, 'obj' => $this->attributeSetObj);
 }
コード例 #2
0
ファイル: AttributeSet.php プロジェクト: aiesh/magento2
 /**
  * Invalidate EAV indexer if attribute set has indexable attributes changes
  *
  * @param \Magento\Eav\Model\Entity\Attribute\Set $subject
  * @param callable $proceed
  *
  * @return \Magento\Eav\Model\Entity\Attribute\Set
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(\Magento\Eav\Model\Entity\Attribute\Set $subject, \Closure $proceed)
 {
     $requiresReindex = false;
     if ($subject->getId()) {
         /** @var \Magento\Eav\Model\Entity\Attribute\Set $originalSet */
         $originalSet = clone $subject;
         $originalSet->initFromSkeleton($subject->getId());
         $originalAttributeCodes = array_flip($this->_attributeFilter->filter($originalSet));
         $subjectAttributeCodes = array_flip($this->_attributeFilter->filter($subject));
         $requiresReindex = (bool) count(array_merge(array_diff_key($subjectAttributeCodes, $originalAttributeCodes), array_diff_key($originalAttributeCodes, $subjectAttributeCodes)));
     }
     $result = $proceed();
     if ($requiresReindex) {
         $this->_indexerEavProcessor->markIndexerAsInvalid();
     }
     return $result;
 }
コード例 #3
0
ファイル: Relation.php プロジェクト: Doability/magento2dev
 public function setAttributeSetObj(\Magento\Eav\Model\Entity\Attribute\Set $obj)
 {
     $this->attributeSetObj = $obj;
     $this->setId = $obj->getId();
     return $this;
 }
コード例 #4
0
ファイル: Set.php プロジェクト: shabbirvividads/magento2
 /**
  * Validate attribute set name
  *
  * @param \Magento\Eav\Model\Entity\Attribute\Set $object
  * @param string $attributeSetName
  * @return bool
  */
 public function validate($object, $attributeSetName)
 {
     $adapter = $this->_getReadAdapter();
     $bind = ['attribute_set_name' => trim($attributeSetName), 'entity_type_id' => $object->getEntityTypeId()];
     $select = $adapter->select()->from($this->getMainTable())->where('attribute_set_name = :attribute_set_name')->where('entity_type_id = :entity_type_id');
     if ($object->getId()) {
         $bind['attribute_set_id'] = $object->getId();
         $select->where('attribute_set_id != :attribute_set_id');
     }
     return !$adapter->fetchOne($select, $bind) ? true : false;
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function getId()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getId');
     if (!$pluginInfo) {
         return parent::getId();
     } else {
         return $this->___callPlugins('getId', func_get_args(), $pluginInfo);
     }
 }