Beispiel #1
0
 /**
  * Retrieve Set info by attributes
  *
  * @param array $attributeIds
  * @param int $setId
  * @return array
  */
 public function getSetInfo(array $attributeIds, $setId = null)
 {
     $cacheKey = self::ATTRIBUTES_CACHE_ID . $setId;
     if ($this->eavConfig->isCacheEnabled() && ($cache = $this->eavConfig->getCache()->load($cacheKey))) {
         $setInfoData = unserialize($cache);
     } else {
         $attributeSetData = $this->fetchAttributeSetData($setId);
         $setInfoData = [];
         foreach ($attributeSetData as $row) {
             $data = ['group_id' => $row['attribute_group_id'], 'group_sort' => $row['group_sort_order'], 'sort' => $row['sort_order']];
             $setInfoData[$row['attribute_id']][$row['attribute_set_id']] = $data;
         }
         if ($this->eavConfig->isCacheEnabled()) {
             $this->eavConfig->getCache()->save(serialize($setInfoData), $cacheKey, [\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG]);
         }
     }
     $setInfo = [];
     foreach ($attributeIds as $attributeId) {
         $setInfo[$attributeId] = isset($setInfoData[$attributeId]) ? $setInfoData[$attributeId] : [];
     }
     return $setInfo;
 }