當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObject::getAttributeSetId方法代碼示例

本文整理匯總了PHP中Magento\Framework\DataObject::getAttributeSetId方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObject::getAttributeSetId方法的具體用法?PHP DataObject::getAttributeSetId怎麽用?PHP DataObject::getAttributeSetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\DataObject的用法示例。


在下文中一共展示了DataObject::getAttributeSetId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getLoadAllAttributesCacheSuffix

 /**
  * @param DataObject|null $object
  * @return string
  */
 private function getLoadAllAttributesCacheSuffix(DataObject $object = null)
 {
     $attributeSetId = 0;
     $storeId = 0;
     if (null !== $object) {
         $attributeSetId = $object->getAttributeSetId() ?: $attributeSetId;
         $storeId = $object->getStoreId() ?: $storeId;
     }
     $suffix = $storeId . '-' . $attributeSetId;
     return $suffix;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:15,代碼來源:AttributeLoader.php

示例2: _getLoadAttributesSelect

 /**
  * Retrieve select object for loading entity attributes values
  * Join attribute store value
  *
  * @param \Magento\Framework\DataObject $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 = [$this->getDefaultStoreId()];
     if ($storeId != $this->getDefaultStoreId()) {
         $storeIds[] = $storeId;
     }
     $select = $this->getConnection()->select()->from(['attr_table' => $table], [])->where("attr_table.{$this->getEntityIdField()} = ?", $object->getId())->where('attr_table.store_id IN (?)', $storeIds);
     if ($setId) {
         $select->join(['set_table' => $this->getTable('eav_entity_attribute')], $this->getConnection()->quoteInto('attr_table.attribute_id = set_table.attribute_id' . ' AND set_table.attribute_set_id = ?', $setId), []);
     }
     return $select;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:31,代碼來源:AbstractResource.php

示例3: getEntityAttributeCodes

 /**
  * Get codes of all entity type attributes
  *
  * @param  mixed $entityType
  * @param  \Magento\Framework\DataObject $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\DataObject) {
         $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:whoople,項目名稱:magento2-testing,代碼行數:43,代碼來源:Config.php


注:本文中的Magento\Framework\DataObject::getAttributeSetId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。