當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractModel::getEntityTypeId方法代碼示例

本文整理匯總了PHP中Magento\Framework\Model\AbstractModel::getEntityTypeId方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::getEntityTypeId方法的具體用法?PHP AbstractModel::getEntityTypeId怎麽用?PHP AbstractModel::getEntityTypeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::getEntityTypeId方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _afterLoad

 /**
  * Load additional attribute data.
  * Load label of current active store
  *
  * @param EntityAttribute|AbstractModel $object
  * @return $this
  */
 protected function _afterLoad(AbstractModel $object)
 {
     /** @var $entityType \Magento\Eav\Model\Entity\Type */
     $entityType = $object->getData('entity_type');
     if ($entityType) {
         $additionalTable = $entityType->getAdditionalAttributeTable();
     } else {
         $additionalTable = $this->getAdditionalAttributeTable($object->getEntityTypeId());
     }
     if ($additionalTable) {
         $connection = $this->getConnection();
         $bind = [':attribute_id' => $object->getId()];
         $select = $connection->select()->from($this->getTable($additionalTable))->where('attribute_id = :attribute_id');
         $result = $connection->fetchRow($select, $bind);
         if ($result) {
             $object->addData($result);
         }
     }
     return $this;
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:27,代碼來源:Attribute.php

示例2: _saveAttribute

 /**
  * Save entity attribute value
  *
  * Collect for mass save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @param AbstractAttribute $attribute
  * @param mixed $value
  * @return $this
  */
 protected function _saveAttribute($object, $attribute, $value)
 {
     $table = $attribute->getBackend()->getTable();
     if (!isset($this->_attributeValuesToSave[$table])) {
         $this->_attributeValuesToSave[$table] = array();
     }
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $data = array('entity_type_id' => $object->getEntityTypeId(), $entityIdField => $object->getId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute));
     $this->_attributeValuesToSave[$table][] = $data;
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:21,代碼來源:AbstractEntity.php

示例3: _clearUselessAttributeValues

 /**
  * Clear useless attribute values
  *
  * @param  \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _clearUselessAttributeValues(\Magento\Framework\Model\AbstractModel $object)
 {
     $origData = $object->getOrigData();
     if ($object->isScopeGlobal() && isset($origData['is_global']) && \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL != $origData['is_global']) {
         $attributeStoreIds = array_keys($this->_storeManager->getStores());
         if (!empty($attributeStoreIds)) {
             $delCondition = array('entity_type_id=?' => $object->getEntityTypeId(), 'attribute_id = ?' => $object->getId(), 'store_id IN(?)' => $attributeStoreIds);
             $this->_getWriteAdapter()->delete($object->getBackendTable(), $delCondition);
         }
     }
     return $this;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:18,代碼來源:Attribute.php

示例4: setEntity

 /**
  * Set entity instance
  *
  * @param \Magento\Framework\Model\AbstractModel $entity
  * @return $this
  */
 public function setEntity(\Magento\Framework\Model\AbstractModel $entity)
 {
     $this->_entity = $entity;
     if ($entity->getEntityTypeId()) {
         $this->setEntityType($entity->getEntityTypeId());
     }
     return $this;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:14,代碼來源:Form.php

示例5: _saveAttribute

 /**
  * Save entity attribute value
  *
  * Collect for mass save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @param AbstractAttribute $attribute
  * @param mixed $value
  * @return $this
  */
 protected function _saveAttribute($object, $attribute, $value)
 {
     $table = $attribute->getBackend()->getTable();
     if (!isset($this->_attributeValuesToSave[$table])) {
         $this->_attributeValuesToSave[$table] = [];
     }
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $data = [$entityIdField => $object->getId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute)];
     if (!$this->getEntityTable() || $this->getEntityTable() == \Magento\Eav\Model\Entity::DEFAULT_ENTITY_TABLE) {
         $data['entity_type_id'] = $object->getEntityTypeId();
     }
     $this->_attributeValuesToSave[$table][] = $data;
     return $this;
 }
開發者ID:koliaGI,項目名稱:magento2,代碼行數:24,代碼來源:AbstractEntity.php

示例6: _beforeDelete

 /**
  * Perform actions before object delete
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\StateException
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Eav\Api\Data\AttributeSetInterface $object */
     $defaultAttributeSetId = $this->eavConfig->getEntityType($object->getEntityTypeId())->getDefaultAttributeSetId();
     if ($object->getAttributeSetId() == $defaultAttributeSetId) {
         throw new \Magento\Framework\Exception\StateException(__('Default attribute set can not be deleted'));
     }
     return parent::_beforeDelete($object);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:17,代碼來源:Set.php

示例7: deleteEntity

 /**
  * Delete entity
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function deleteEntity(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getEntityAttributeId()) {
         return $this;
     }
     $result = $this->getEntityAttribute($object->getEntityAttributeId());
     if ($result) {
         $attribute = $this->_eavConfig->getAttribute($object->getEntityTypeId(), $result['attribute_id']);
         try {
             $this->attrLockValidator->validate($attribute, $result['attribute_set_id']);
         } catch (\Magento\Framework\Exception\LocalizedException $exception) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Attribute \'%1\' is locked. %2', $attribute->getAttributeCode(), $exception->getMessage()));
         }
         $backendTable = $attribute->getBackend()->getTable();
         if ($backendTable) {
             $linkField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
             $select = $this->getConnection()->select()->from($attribute->getEntity()->getEntityTable(), $linkField)->where('attribute_set_id = ?', $result['attribute_set_id']);
             $clearCondition = ['attribute_id =?' => $attribute->getId(), $linkField . ' IN (?)' => $select];
             $this->getConnection()->delete($backendTable, $clearCondition);
         }
     }
     $condition = ['entity_attribute_id = ?' => $object->getEntityAttributeId()];
     $this->getConnection()->delete($this->getTable('eav_entity_attribute'), $condition);
     return $this;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:32,代碼來源:Attribute.php


注:本文中的Magento\Framework\Model\AbstractModel::getEntityTypeId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。