diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index 2dc519dbf1540..6a553fb4dbc67 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -166,6 +166,11 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType */ private $arrayUtility; + /** + * @var array + */ + private $cacheChildrenIds = []; + /** * @param \Magento\Catalog\Model\Product\Option $catalogProductOption * @param \Magento\Eav\Model\Config $eavConfig @@ -283,7 +288,12 @@ public function getRelationInfo() */ public function getChildrenIds($parentId, $required = true) { - return $this->_bundleSelection->getChildrenIds($parentId, $required); + $cacheKey = $parentId . '-' . ($required ? 1 : 0); + if (!isset($this->cacheChildrenIds[$cacheKey])) { + $this->cacheChildrenIds[$cacheKey] = $this->_bundleSelection->getChildrenIds($parentId, $required); + } + + return $this->cacheChildrenIds[$cacheKey]; } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index a849d964eaed5..e0295a48beb9a 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -194,6 +194,11 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType */ private $salableProcessor; + /** + * @var array + */ + private $cacheChildrenIds = []; + /** * @codingStandardsIgnoreStart/End * @@ -324,7 +329,15 @@ public function getRelationInfo() */ public function getChildrenIds($parentId, $required = true) { - return $this->_catalogProductTypeConfigurable->getChildrenIds($parentId, $required); + $cacheKey = (is_array($parentId) ? implode(',', $parentId) : $parentId) . '-' . ($required ? 1 : 0); + if (!isset($this->cacheChildrenIds[$cacheKey])) { + $this->cacheChildrenIds[$cacheKey] = $this->_catalogProductTypeConfigurable->getChildrenIds( + $parentId, + $required + ); + } + + return $this->cacheChildrenIds[$cacheKey]; } /** diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index 187fd27fa0554..1b2ea0713ed83 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -86,6 +86,11 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType */ protected $msrpData; + /** + * @var array + */ + private $cacheChildrenIds = []; + /** * @param \Magento\Catalog\Model\Product\Option $catalogProductOption * @param \Magento\Eav\Model\Config $eavConfig @@ -174,10 +179,15 @@ public function getRelationInfo() */ public function getChildrenIds($parentId, $required = true) { - return $this->productLinks->getChildrenIds( - $parentId, - \Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED - ); + $cacheKey = $parentId . '-' . ($required ? 1 : 0); + if (!isset($this->cacheChildrenIds[$cacheKey])) { + $this->cacheChildrenIds[$cacheKey] = $this->productLinks->getChildrenIds( + $parentId, + \Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED + ); + } + + return $this->cacheChildrenIds[$cacheKey]; } /**