当前位置: 首页>>代码示例>>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;未经允许,请勿转载。