diff --git a/Helper/Data.php b/Helper/Data.php index 23b071b..5ba48c4 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -33,6 +33,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ protected $_priceHelper; + /** + * @var \Magento\Framework\Serialize\SerializerInterface + */ + private $_serializer; + /** * Constructor * @@ -41,9 +46,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Framework\Pricing\Helper\Data $priceHelper + \Magento\Framework\Pricing\Helper\Data $priceHelper, + \Magento\Framework\Serialize\SerializerInterface $serializer ){ $this->_priceHelper = $priceHelper; + $this->_serializer = $serializer; parent::__construct($context); } @@ -58,7 +65,7 @@ public function getConversion($product) $productUnit = $product->getData('baseprice_product_unit'); $referenceUnit = $product->getData('baseprice_reference_unit'); - $configArray = unserialize($this->scopeConfig->getValue( + $configArray = $this->_serializer->unserialize($this->scopeConfig->getValue( self::CONVERSION_CONFIG_PATH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE )); diff --git a/Setup/InstallData.php b/Setup/InstallData.php index 33b7ca2..20e237b 100644 --- a/Setup/InstallData.php +++ b/Setup/InstallData.php @@ -48,6 +48,11 @@ class InstallData implements InstallDataInterface */ protected $_eavConfig; + /** + * @var \Magento\Framework\Serialize\SerializerInterface + */ + private $_serializer; + /** * Constructor * @@ -60,12 +65,14 @@ public function __construct( \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory, \Magento\Catalog\Api\ProductAttributeOptionManagementInterface $productAttributeOptionManagementInterface, \Magento\Config\Model\ResourceModel\Config $configResource, - \Magento\Eav\Model\Config $eavConfig + \Magento\Eav\Model\Config $eavConfig, + \Magento\Framework\Serialize\SerializerInterface $serializer ){ $this->_eavSetupFactory = $eavSetupFactory; $this->_productAttributeOptionManagementInterface = $productAttributeOptionManagementInterface; $this->_configResource = $configResource; $this->_eavConfig = $eavConfig; + $this->_serializer = $serializer; } /** @@ -268,7 +275,7 @@ protected function _setSystemConfiguration() // save system configuration $this->_configResource->saveConfig( \Magenerds\BasePrice\Helper\Data::CONVERSION_CONFIG_PATH, - serialize($data), + $this->_serializer->serialize($data), \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0 );