Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a:1:{s:18:"_1498478770604_604";a:4:{s:4:"name";s:12:"Number Pi";s:5:"image";s:23:"/media/wysiwyg/test.png";s:4:"text";s:606:"Lorum ipsum";s:20:"activation_attribute";s:1:"1";}}
- $fields = $this->scopeConfig->getValue('yourSystemConfigPath', MagentoStoreModelScopeInterface::SCOPE_STORE);
- $fields = unserialize($fields);
- <?php
- namespace NwdthemesArraySerializedHelper;
- use MagentoFrameworkAppObjectManager;
- /**
- * ArraySerialized helper
- */
- class Data extends MagentoFrameworkAppHelperAbstractHelper
- {
- /**
- * Get config value
- * @param $configPath
- * @param null $store
- * @return mixed
- */
- public function getConfigValue($configPath, $store = null)
- {
- return $this->scopeConfig->getValue(
- $configPath,
- MagentoStoreModelScopeInterface::SCOPE_STORE,
- $store
- );
- }
- /**
- * Get serialized config value
- * temporarily solution to get unserialized config value
- * should be deprecated in 2.3.x
- *
- * @param $configPath
- * @param null $store
- * @return mixed
- */
- public function getSerializedConfigValue($configPath, $store = null)
- {
- $value = $this->getConfigValue($configPath, $store);
- if (empty($value)) return false;
- if ($this->isSerialized($value)) {
- $unserializer = ObjectManager::getInstance()->get(MagentoFrameworkUnserializeUnserialize::class);
- } else {
- $unserializer = ObjectManager::getInstance()->get(MagentoFrameworkSerializeSerializerJson::class);
- }
- return $unserializer->unserialize($value);
- }
- /**
- * Check if value is a serialized string
- *
- * @param string $value
- * @return boolean
- */
- private function isSerialized($value)
- {
- return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value);
- }
- }
Add Comment
Please, Sign In to add comment