当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractAttribute::getEntityTypeId方法代码示例

本文整理汇总了PHP中Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getEntityTypeId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAttribute::getEntityTypeId方法的具体用法?PHP AbstractAttribute::getEntityTypeId怎么用?PHP AbstractAttribute::getEntityTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Eav\Model\Entity\Attribute\AbstractAttribute的用法示例。


在下文中一共展示了AbstractAttribute::getEntityTypeId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:30,代码来源:Option.php

示例2: 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;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:23,代码来源:Attribute.php

示例3: _insertAttribute

 /**
  * Insert entity attribute value
  *
  * @param \Magento\Framework\Object $object
  * @param AbstractAttribute $attribute
  * @param mixed $value
  * @return $this
  */
 protected function _insertAttribute($object, $attribute, $value)
 {
     /**
      * save required attributes in global scope every time if store id different from default
      */
     $storeId = (int) $this->_storeManager->getStore($object->getStoreId())->getId();
     if ($this->getDefaultStoreId() != $storeId) {
         if ($attribute->getIsRequired() || $attribute->getIsRequiredInAdminStore()) {
             $table = $attribute->getBackend()->getTable();
             $select = $this->_getReadAdapter()->select()->from($table)->where('entity_type_id = ?', $attribute->getEntityTypeId())->where('attribute_id = ?', $attribute->getAttributeId())->where('store_id = ?', $this->getDefaultStoreId())->where('entity_id = ?', $object->getEntityId());
             $row = $this->_getReadAdapter()->fetchOne($select);
             if (!$row) {
                 $data = new \Magento\Framework\Object(array('entity_type_id' => $attribute->getEntityTypeId(), 'attribute_id' => $attribute->getAttributeId(), 'store_id' => $this->getDefaultStoreId(), 'entity_id' => $object->getEntityId(), 'value' => $this->_prepareValueForSave($value, $attribute)));
                 $bind = $this->_prepareDataForTable($data, $table);
                 $this->_getWriteAdapter()->insertOnDuplicate($table, $bind, array('value'));
             }
         }
     }
     return $this->_saveAttributeValue($object, $attribute, $value);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:28,代码来源:AbstractResource.php

示例4: 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;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:32,代码来源:Attribute.php

示例5: _getLastSimilarAttributeValueIncrement

 /**
  * Return increment needed for SKU uniqueness
  *
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @param Product $object
  * @return int
  */
 protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
 {
     $adapter = $this->getAttribute()->getEntity()->getReadConnection();
     $select = $adapter->select();
     $value = $object->getData($attribute->getAttributeCode());
     $bind = array('entity_type_id' => $attribute->getEntityTypeId(), 'attribute_code' => trim($value) . '-%');
     $select->from($this->getTable(), $attribute->getAttributeCode())->where('entity_type_id = :entity_type_id')->where($attribute->getAttributeCode() . ' LIKE :attribute_code')->order(array('entity_id DESC', $attribute->getAttributeCode() . ' ASC'))->limit(1);
     $data = $adapter->fetchOne($select, $bind);
     return abs((int) str_replace($value, '', $data));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Sku.php


注:本文中的Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getEntityTypeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。