Skip to content

Commit 2d27fee

Browse files
committed
MAGETWO-96459: Fix performance on MAGETWO-83832
1 parent f24b02f commit 2d27fee

File tree

1 file changed

+5
-15
lines changed
  • app/code/Magento/Catalog/Model/Product/Attribute/Source

1 file changed

+5
-15
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
99
use Magento\Framework\App\ObjectManager;
10-
use Magento\Framework\Serialize\SerializerInterface;
11-
use Magento\Framework\Serialize\Serializer\Json;
1210

1311
/**
1412
* Catalog product landing page attribute source
@@ -25,44 +23,36 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
2523
*/
2624
private $layoutCache;
2725

28-
/**
29-
* @var SerializerInterface
30-
*/
31-
private $serializer;
32-
3326
/**
3427
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
3528
* @param LayoutCache|null $layoutCache
36-
* @param SerializerInterface|null $serializer
3729
*/
3830
public function __construct(
3931
\Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder,
40-
LayoutCache $layoutCache = null,
41-
SerializerInterface $serializer = null
32+
LayoutCache $layoutCache = null
4233
) {
4334
$this->pageLayoutBuilder = $pageLayoutBuilder;
4435
$this->layoutCache = $layoutCache ?? ObjectManager::getInstance()->get(LayoutCache::class);
45-
$this->serializer = $serializer ?? ObjectManager::getInstance()->get(Json::class);
4636
}
4737

4838
/**
4939
* Get list of available layouts
5040
*
5141
* @return array
52-
* @throws \InvalidArgumentException
5342
*/
5443
public function getAllOptions()
5544
{
5645
if (!$this->_options) {
5746
$layoutCacheKey = __CLASS__;
5847
if ($data = $this->layoutCache->load($layoutCacheKey)) {
59-
return $this->_options = $this->serializer->unserialize($data);
48+
return $this->_options = unserialize($data);
6049
} else {
6150
$this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
62-
$this->layoutCache->save($this->serializer->serialize($this->_options), $layoutCacheKey);
51+
array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
52+
$this->layoutCache->save(serialize($this->_options), $layoutCacheKey);
6353
}
54+
6455
}
65-
array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
6656
return $this->_options;
6757
}
6858
}

0 commit comments

Comments
 (0)