12
12
namespace Magento \Eav \Model \Entity \Attribute \Frontend ;
13
13
14
14
use Magento \Framework \App \CacheInterface ;
15
- use Magento \Store \Api \ StoreResolverInterface ;
15
+ use Magento \Store \Model \ StoreManagerInterface ;
16
16
use Magento \Framework \App \ObjectManager ;
17
17
use Magento \Eav \Model \Cache \Type as CacheType ;
18
18
use Magento \Eav \Model \Entity \Attribute ;
19
19
20
20
abstract class AbstractFrontend implements \Magento \Eav \Model \Entity \Attribute \Frontend \FrontendInterface
21
21
{
22
+ /**
23
+ * Default cache tags values
24
+ * will be used if no values in the constructor provided
25
+ * @var array
26
+ */
27
+ private static $ defaultCacheTags = [CacheType::CACHE_TAG , Attribute::CACHE_TAG ];
28
+
22
29
/**
23
30
* @var CacheInterface
24
31
*/
25
32
private $ cache ;
26
33
27
34
/**
28
- * @var StoreResolverInterface
35
+ * @var StoreManagerInterface
29
36
*/
30
- private $ storeResolver ;
37
+ private $ storeManager ;
31
38
32
39
/**
33
40
* @var array
@@ -49,23 +56,23 @@ abstract class AbstractFrontend implements \Magento\Eav\Model\Entity\Attribute\F
49
56
/**
50
57
* @param \Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory $attrBooleanFactory
51
58
* @param CacheInterface $cache
52
- * @param StoreResolverInterface $storeResolver
59
+ * @param $storeResolver @deprecated
53
60
* @param array $cacheTags
61
+ * @param StoreManagerInterface $storeManager
54
62
* @codeCoverageIgnore
63
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
55
64
*/
56
65
public function __construct (
57
66
\Magento \Eav \Model \Entity \Attribute \Source \BooleanFactory $ attrBooleanFactory ,
58
67
CacheInterface $ cache = null ,
59
- StoreResolverInterface $ storeResolver = null ,
60
- array $ cacheTags = [
61
- CacheType::CACHE_TAG ,
62
- Attribute::CACHE_TAG ,
63
- ]
68
+ $ storeResolver = null ,
69
+ array $ cacheTags = null ,
70
+ StoreManagerInterface $ storeManager = null
64
71
) {
65
72
$ this ->_attrBooleanFactory = $ attrBooleanFactory ;
66
73
$ this ->cache = $ cache ?: ObjectManager::getInstance ()->get (CacheInterface::class);
67
- $ this ->storeResolver = $ storeResolver ?: ObjectManager:: getInstance ()-> get (StoreResolverInterface::class) ;
68
- $ this ->cacheTags = $ cacheTags ;
74
+ $ this ->cacheTags = $ cacheTags ?: self :: $ defaultCacheTags ;
75
+ $ this ->storeManager = $ storeManager ?: ObjectManager:: getInstance ()-> get (StoreManagerInterface::class) ;
69
76
}
70
77
71
78
/**
@@ -252,7 +259,7 @@ public function getSelectOptions()
252
259
{
253
260
$ cacheKey = 'attribute-navigation-option- ' .
254
261
$ this ->getAttribute ()->getAttributeCode () . '- ' .
255
- $ this ->storeResolver -> getCurrentStoreId ();
262
+ $ this ->storeManager -> getStore ()-> getId ();
256
263
$ optionString = $ this ->cache ->load ($ cacheKey );
257
264
if (false === $ optionString ) {
258
265
$ options = $ this ->getAttribute ()->getSource ()->getAllOptions ();
0 commit comments