Guest User

Untitled

a guest
Jun 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. 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";}}
  2.  
  3. $fields = $this->scopeConfig->getValue('yourSystemConfigPath', MagentoStoreModelScopeInterface::SCOPE_STORE);
  4. $fields = unserialize($fields);
  5.  
  6. <?php
  7.  
  8. namespace NwdthemesArraySerializedHelper;
  9.  
  10. use MagentoFrameworkAppObjectManager;
  11.  
  12. /**
  13. * ArraySerialized helper
  14. */
  15. class Data extends MagentoFrameworkAppHelperAbstractHelper
  16. {
  17. /**
  18. * Get config value
  19. * @param $configPath
  20. * @param null $store
  21. * @return mixed
  22. */
  23. public function getConfigValue($configPath, $store = null)
  24. {
  25. return $this->scopeConfig->getValue(
  26. $configPath,
  27. MagentoStoreModelScopeInterface::SCOPE_STORE,
  28. $store
  29. );
  30. }
  31.  
  32. /**
  33. * Get serialized config value
  34. * temporarily solution to get unserialized config value
  35. * should be deprecated in 2.3.x
  36. *
  37. * @param $configPath
  38. * @param null $store
  39. * @return mixed
  40. */
  41. public function getSerializedConfigValue($configPath, $store = null)
  42. {
  43. $value = $this->getConfigValue($configPath, $store);
  44.  
  45. if (empty($value)) return false;
  46.  
  47. if ($this->isSerialized($value)) {
  48. $unserializer = ObjectManager::getInstance()->get(MagentoFrameworkUnserializeUnserialize::class);
  49. } else {
  50. $unserializer = ObjectManager::getInstance()->get(MagentoFrameworkSerializeSerializerJson::class);
  51. }
  52.  
  53. return $unserializer->unserialize($value);
  54. }
  55.  
  56. /**
  57. * Check if value is a serialized string
  58. *
  59. * @param string $value
  60. * @return boolean
  61. */
  62. private function isSerialized($value)
  63. {
  64. return (boolean) preg_match('/^((s|i|d|b|a|O|C):|N;)/', $value);
  65. }
  66.  
  67. }
Add Comment
Please, Sign In to add comment