30 private $resourceConnection;
37 private $swatchAttributeCodes;
60 $this->cacheKey = $cacheKey;
61 $this->cacheTags = $cacheTags;
72 if ($this->swatchAttributeCodes ===
null) {
73 $swatchAttributeCodesCache = $this->cache->load($this->cacheKey);
74 if (
false === $swatchAttributeCodesCache) {
75 $swatchAttributeCodes = $this->getSwatchAttributeCodes();
76 $this->cache->save(json_encode($swatchAttributeCodes), $this->cacheKey, $this->cacheTags);
78 $swatchAttributeCodes = json_decode($swatchAttributeCodesCache,
true);
80 $this->swatchAttributeCodes = $swatchAttributeCodes;
83 return $this->swatchAttributeCodes;
93 private function getSwatchAttributeCodes()
95 $select = $this->resourceConnection->getConnection()->select()
97 [
'a' => $this->resourceConnection->getTableName(
'eav_attribute')],
99 'attribute_id' =>
'a.attribute_id',
100 'attribute_code' =>
'a.attribute_code',
103 'a.attribute_id IN (?)',
106 $result = $this->resourceConnection->getConnection()->fetchPairs(
$select);
117 private function getAttributeIdsSelect()
119 return $this->resourceConnection->getConnection()->select()
121 [
'o' => $this->resourceConnection->getTableName(
'eav_attribute_option')],
122 [
'attribute_id' =>
'o.attribute_id']
124 [
's' => $this->resourceConnection->getTableName(
'eav_attribute_option_swatch')],
125 'o.option_id = s.option_id',
__construct(CacheInterface $cache, ResourceConnection $resourceConnection, $cacheKey, array $cacheTags)