本文整理汇总了PHP中Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAttribute::getId方法的具体用法?PHP AbstractAttribute::getId怎么用?PHP AbstractAttribute::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Eav\Model\Entity\Attribute\AbstractAttribute
的用法示例。
在下文中一共展示了AbstractAttribute::getId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteProductData
/**
* Delete product data
*
* @param \Magento\Catalog\Model\Product $product
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @return $this
*/
public function deleteProductData($product, $attribute)
{
$where = ['entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId()];
$connection = $this->getConnection();
if (!$attribute->isScopeGlobal()) {
$storeId = $product->getStoreId();
if ($storeId) {
$where['website_id IN(?)'] = [0, $this->_storeManager->getStore($storeId)->getWebsiteId()];
}
}
$connection->delete($this->getMainTable(), $where);
return $this;
}
示例2: deleteProductData
/**
* Delete product data
*
* @param \Magento\Catalog\Model\Product $product
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @return $this
*/
public function deleteProductData($product, $attribute)
{
$where = array('entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId());
$adapter = $this->_getWriteAdapter();
if (!$attribute->isScopeGlobal()) {
$storeId = $product->getStoreId();
if ($storeId) {
$where['website_id IN(?)'] = array(0, $this->_storeManager->getStore($storeId)->getWebsiteId());
}
}
$adapter->delete($this->getMainTable(), $where);
return $this;
}
示例3: getFlatUpdateSelect
/**
* Retrieve Select for update Flat data
*
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @param int $store
* @param bool $hasValueField flag which require option value
* @return \Magento\Framework\DB\Select
*/
public function getFlatUpdateSelect(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $store, $hasValueField = true)
{
$adapter = $this->_getReadAdapter();
$attributeTable = $attribute->getBackend()->getTable();
$attributeCode = $attribute->getAttributeCode();
$joinConditionTemplate = "%s.entity_id = %s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
$joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
if ($attribute->getFlatAddChildData()) {
$joinCondition .= ' AND e.child_id = t1.entity_id';
}
$valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
/** @var $select \Magento\Framework\DB\Select */
$select = $adapter->select()->joinLeft(['t1' => $attributeTable], $joinCondition, [])->joinLeft(['t2' => $attributeTable], sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $store), [$attributeCode => $valueExpr]);
if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
$valueIdExpr = $adapter->getCheckSql('to2.value_id > 0', 'to2.value', 'to1.value');
$select->joinLeft(['to1' => $this->getTable('eav_attribute_option_value')], "to1.option_id = {$valueExpr} AND to1.store_id = 0", [])->joinLeft(['to2' => $this->getTable('eav_attribute_option_value')], $adapter->quoteInto("to2.option_id = {$valueExpr} AND to2.store_id = ?", $store), [$attributeCode . '_value' => $valueIdExpr]);
}
if ($attribute->getFlatAddChildData()) {
$select->where('e.is_child = 0');
}
return $select;
}
示例4: _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;
}
示例5: getAttributeRow
/**
* Return attribute row to prepare where statement
*
* @param \Magento\Framework\Object $entity
* @param \Magento\Framework\Object $object
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @return array
*/
protected function getAttributeRow($entity, $object, $attribute)
{
$data = ['attribute_id' => $attribute->getId(), $entity->getEntityIdField() => $object->getData($entity->getEntityIdField())];
if (!$this->getEntityTable()) {
$data['entity_type_id'] = $entity->getTypeId();
}
return $data;
}
示例6: getFlatUpdateSelect
/**
* Retrieve Select For Flat Attribute update
*
* @param AbstractAttribute $attribute
* @param int $storeId
* @return Select
*/
public function getFlatUpdateSelect(AbstractAttribute $attribute, $storeId)
{
$connection = $this->getConnection();
$joinConditionTemplate = "%s.entity_id=%s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
$joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
if ($attribute->getFlatAddChildData()) {
$joinCondition .= ' AND e.child_id = t1.entity_id';
}
$valueExpr = $connection->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
/** @var $select Select */
$select = $connection->select()->joinLeft(['t1' => $attribute->getBackend()->getTable()], $joinCondition, [])->joinLeft(['t2' => $attribute->getBackend()->getTable()], sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $storeId), [$attribute->getAttributeCode() => $valueExpr]);
if ($attribute->getFlatAddChildData()) {
$select->where("e.is_child = ?", 0);
}
return $select;
}
示例7: duplicate
/**
* @param \Magento\Catalog\Model\Product $product
* @param AbstractAttribute $attribute
* @return $this
*/
protected function duplicate($product, $attribute)
{
$mediaGalleryData = $product->getData($attribute->getAttributeCode());
if (!isset($mediaGalleryData['images']) || !is_array($mediaGalleryData['images'])) {
return $this;
}
$this->getResource()->duplicate($attribute->getId(), isset($mediaGalleryData['duplicate']) ? $mediaGalleryData['duplicate'] : [], $product->getOriginalId(), $product->getId());
return $this;
}