本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}