本文整理匯總了PHP中Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getEntityAttributeId方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractAttribute::getEntityAttributeId方法的具體用法?PHP AbstractAttribute::getEntityAttributeId怎麽用?PHP AbstractAttribute::getEntityAttributeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Eav\Model\Entity\Attribute\AbstractAttribute
的用法示例。
在下文中一共展示了AbstractAttribute::getEntityAttributeId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleteEntity
/**
* Delete entity
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $object
* @return $this
*/
public function deleteEntity(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $object)
{
if (!$object->getEntityAttributeId()) {
return $this;
}
$this->getConnection()->delete($this->getTable('eav_entity_attribute'), ['entity_attribute_id = ?' => $object->getEntityAttributeId()]);
return $this;
}
示例2: deleteEntity
/**
* Delete entity
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $object
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function deleteEntity(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $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->metadataPool->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;
}