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


PHP Object::getAttributeSetId方法代码示例

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


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

示例1: _getLoadAttributesSelect

 /**
  * Retrieve select object for loading entity attributes values
  * Join attribute store value
  *
  * @param \Magento\Framework\Object $object
  * @param string $table
  * @return \Magento\Framework\DB\Select
  */
 protected function _getLoadAttributesSelect($object, $table)
 {
     /**
      * This condition is applicable for all cases when we was work in not single
      * store mode, customize some value per specific store view and than back
      * to single store mode. We should load correct values
      */
     if ($this->_storeManager->hasSingleStore()) {
         $storeId = (int) $this->_storeManager->getStore(true)->getId();
     } else {
         $storeId = (int) $object->getStoreId();
     }
     $setId = $object->getAttributeSetId();
     $storeIds = array($this->getDefaultStoreId());
     if ($storeId != $this->getDefaultStoreId()) {
         $storeIds[] = $storeId;
     }
     $select = $this->_getReadAdapter()->select()->from(array('attr_table' => $table), array())->where("attr_table.{$this->getEntityIdField()} = ?", $object->getId())->where('attr_table.store_id IN (?)', $storeIds);
     if ($setId) {
         $select->join(array('set_table' => $this->getTable('eav_entity_attribute')), $this->_getReadAdapter()->quoteInto('attr_table.attribute_id = set_table.attribute_id' . ' AND set_table.attribute_set_id = ?', $setId), array());
     }
     return $select;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:31,代码来源:AbstractResource.php

示例2: getEntityAttributeCodes

 /**
  * Get codes of all entity type attributes
  *
  * @param  mixed $entityType
  * @param  \Magento\Framework\Object $object
  * @return array
  */
 public function getEntityAttributeCodes($entityType, $object = null)
 {
     $entityType = $this->getEntityType($entityType);
     $attributeSetId = 0;
     if ($object instanceof \Magento\Framework\Object && $object->getAttributeSetId()) {
         $attributeSetId = $object->getAttributeSetId();
     }
     $storeId = 0;
     if ($object instanceof \Magento\Framework\Object && $object->getStoreId()) {
         $storeId = $object->getStoreId();
     }
     $cacheKey = sprintf('%d-%d', $entityType->getId(), $attributeSetId);
     if (isset($this->_attributeCodes[$cacheKey])) {
         return $this->_attributeCodes[$cacheKey];
     }
     if ($attributeSetId) {
         $attributesInfo = $this->_universalFactory->create($entityType->getEntityAttributeCollection())->setEntityTypeFilter($entityType)->setAttributeSetFilter($attributeSetId)->addStoreLabel($storeId)->getData();
         $attributes = array();
         foreach ($attributesInfo as $attributeData) {
             $attributes[] = $attributeData['attribute_code'];
             $this->_createAttribute($entityType, $attributeData);
         }
     } else {
         $this->_initAttributes($entityType);
         $attributes = $this->getEntityType($entityType)->getAttributeCodes();
     }
     $this->_attributeCodes[$cacheKey] = $attributes;
     return $attributes;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:36,代码来源:Config.php

示例3: getEntityAttributeCodes

 /**
  * Get codes of all entity type attributes
  *
  * @param  mixed $entityType
  * @param  \Magento\Framework\Object $object
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function getEntityAttributeCodes($entityType, $object = null)
 {
     $entityType = $this->getEntityType($entityType);
     $attributeSetId = 0;
     $storeId = 0;
     if ($object instanceof \Magento\Framework\Object) {
         $attributeSetId = $object->getAttributeSetId() ?: $attributeSetId;
         $storeId = $object->getStoreId() ?: $storeId;
     }
     $cacheKey = self::ATTRIBUTES_CODES_CACHE_ID . $entityType->getId() . '-' . $storeId . '-' . $attributeSetId;
     if (isset($this->_attributeCodes[$cacheKey])) {
         return $this->_attributeCodes[$cacheKey];
     }
     if ($this->isCacheEnabled() && ($attributes = $this->_cache->load($cacheKey))) {
         $this->_attributeCodes[$cacheKey] = unserialize($attributes);
         return $this->_attributeCodes[$cacheKey];
     }
     if ($attributeSetId) {
         $attributesInfo = $this->_universalFactory->create($entityType->getEntityAttributeCollection())->setEntityTypeFilter($entityType)->setAttributeSetFilter($attributeSetId)->addStoreLabel($storeId)->getData();
         $attributes = [];
         foreach ($attributesInfo as $attributeData) {
             $attributes[] = $attributeData['attribute_code'];
             $this->_createAttribute($entityType, $attributeData);
         }
     } else {
         $this->_initAttributes($entityType);
         $attributes = array_keys($this->_attributeData[$entityType->getEntityTypeCode()]);
     }
     $this->_attributeCodes[$cacheKey] = $attributes;
     if ($this->isCacheEnabled()) {
         $this->_cache->save(serialize($attributes), $cacheKey, [\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG]);
     }
     return $attributes;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:43,代码来源:Config.php


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