1111 */
1212namespace Magento \Catalog \Model \Product \Attribute \Source ;
1313
14+ use Magento \Directory \Model \CountryFactory ;
1415use Magento \Eav \Model \Entity \Attribute \Source \AbstractSource ;
16+ use Magento \Framework \App \Cache \Type \Config ;
1517use Magento \Framework \Data \OptionSourceInterface ;
18+ use Magento \Framework \Locale \ResolverInterface ;
19+ use Magento \Framework \Serialize \SerializerInterface ;
20+ use Magento \Store \Model \StoreManagerInterface ;
1621
1722class Countryofmanufacture extends AbstractSource implements OptionSourceInterface
1823{
1924 /**
20- * @var \Magento\Framework\App\Cache\Type\ Config
25+ * @var Config
2126 */
2227 protected $ _configCacheType ;
2328
2429 /**
25- * Store manager
26- *
27- * @var \Magento\Store\Model\StoreManagerInterface
30+ * @var StoreManagerInterface
2831 */
2932 protected $ _storeManager ;
3033
3134 /**
32- * Country factory
33- *
34- * @var \Magento\Directory\Model\CountryFactory
35+ * @var CountryFactory
3536 */
3637 protected $ _countryFactory ;
3738
3839 /**
39- * @var \Magento\Framework\Serialize\ SerializerInterface
40+ * @var SerializerInterface
4041 */
4142 private $ serializer ;
4243
44+ /**
45+ * @var ResolverInterface
46+ */
47+ private $ localeResolver ;
48+
4349 /**
4450 * Construct
4551 *
46- * @param \Magento\Directory\Model\CountryFactory $countryFactory
47- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
48- * @param \Magento\Framework\App\Cache\Type\Config $configCacheType
52+ * @param CountryFactory $countryFactory
53+ * @param StoreManagerInterface $storeManager
54+ * @param Config $configCacheType
55+ * @param ResolverInterface $localeResolver
56+ * @param SerializerInterface $serializer
4957 */
5058 public function __construct (
51- \Magento \Directory \Model \CountryFactory $ countryFactory ,
52- \Magento \Store \Model \StoreManagerInterface $ storeManager ,
53- \Magento \Framework \App \Cache \Type \Config $ configCacheType
59+ CountryFactory $ countryFactory ,
60+ StoreManagerInterface $ storeManager ,
61+ Config $ configCacheType ,
62+ ResolverInterface $ localeResolver ,
63+ SerializerInterface $ serializer
5464 ) {
5565 $ this ->_countryFactory = $ countryFactory ;
5666 $ this ->_storeManager = $ storeManager ;
5767 $ this ->_configCacheType = $ configCacheType ;
68+ $ this ->localeResolver = $ localeResolver ;
69+ $ this ->serializer = $ serializer ;
5870 }
5971
6072 /**
@@ -64,32 +76,20 @@ public function __construct(
6476 */
6577 public function getAllOptions ()
6678 {
67- $ cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_ ' . $ this ->_storeManager ->getStore ()->getCode ();
79+ $ storeCode = $ this ->_storeManager ->getStore ()->getCode ();
80+ $ locale = $ this ->localeResolver ->getLocale ();
81+
82+ $ cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_ ' . $ storeCode . '_LOCALE_ ' . $ locale ;
6883 if ($ cache = $ this ->_configCacheType ->load ($ cacheKey )) {
69- $ options = $ this ->getSerializer () ->unserialize ($ cache );
84+ $ options = $ this ->serializer ->unserialize ($ cache );
7085 } else {
7186 /** @var \Magento\Directory\Model\Country $country */
7287 $ country = $ this ->_countryFactory ->create ();
7388 /** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */
7489 $ collection = $ country ->getResourceCollection ();
7590 $ options = $ collection ->load ()->toOptionArray ();
76- $ this ->_configCacheType ->save ($ this ->getSerializer () ->serialize ($ options ), $ cacheKey );
91+ $ this ->_configCacheType ->save ($ this ->serializer ->serialize ($ options ), $ cacheKey );
7792 }
7893 return $ options ;
7994 }
80-
81- /**
82- * Get serializer
83- *
84- * @return \Magento\Framework\Serialize\SerializerInterface
85- * @deprecated 102.0.0
86- */
87- private function getSerializer ()
88- {
89- if ($ this ->serializer === null ) {
90- $ this ->serializer = \Magento \Framework \App \ObjectManager::getInstance ()
91- ->get (\Magento \Framework \Serialize \SerializerInterface::class);
92- }
93- return $ this ->serializer ;
94- }
9595}
0 commit comments