Skip to content

Commit 42a857a

Browse files
committed
MAGETWO-96463: Add caching to improve admin performance
- remove caching \Magento\Catalog\Model\Product\Attribute\Source\Layout
1 parent 2d27fee commit 42a857a

File tree

1 file changed

+6
-25
lines changed
  • app/code/Magento/Catalog/Model/Product/Attribute/Source

1 file changed

+6
-25
lines changed

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

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
*/
66
namespace Magento\Catalog\Model\Product\Attribute\Source;
77

8-
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
9-
use Magento\Framework\App\ObjectManager;
10-
118
/**
129
* Catalog product landing page attribute source
10+
*
11+
* @author Magento Core Team <core@magentocommerce.com>
1312
*/
1413
class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1514
{
@@ -18,40 +17,22 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1817
*/
1918
protected $pageLayoutBuilder;
2019

21-
/**
22-
* @var LayoutCache
23-
*/
24-
private $layoutCache;
25-
2620
/**
2721
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
28-
* @param LayoutCache|null $layoutCache
2922
*/
30-
public function __construct(
31-
\Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder,
32-
LayoutCache $layoutCache = null
33-
) {
23+
public function __construct(\Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder)
24+
{
3425
$this->pageLayoutBuilder = $pageLayoutBuilder;
35-
$this->layoutCache = $layoutCache ?? ObjectManager::getInstance()->get(LayoutCache::class);
3626
}
3727

3828
/**
39-
* Get list of available layouts
40-
*
4129
* @return array
4230
*/
4331
public function getAllOptions()
4432
{
4533
if (!$this->_options) {
46-
$layoutCacheKey = __CLASS__;
47-
if ($data = $this->layoutCache->load($layoutCacheKey)) {
48-
return $this->_options = unserialize($data);
49-
} else {
50-
$this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
51-
array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
52-
$this->layoutCache->save(serialize($this->_options), $layoutCacheKey);
53-
}
54-
34+
$this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
35+
array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
5536
}
5637
return $this->_options;
5738
}

0 commit comments

Comments
 (0)