From 8029be3355c3cb1dbebd185de54583a6e27f3c65 Mon Sep 17 00:00:00 2001 From: Michael Lehmkuhl Date: Thu, 14 Mar 2019 14:40:57 -0500 Subject: [PATCH 1/2] Fixes nested array for used products cache key When $requiredAttributeIds is passed as an array, it was previously being added to the $keyParts array directly, which resulted in a nested array. When this nested array is passed to getUsedProductsCacheKey(), the implode() in that function throws a notice and produces a cache key that contains the non-unique string "Array" as a part. This can result in caching errors where simple children of configurable products are concerned (e.g., swatches). --- .../Model/Product/Type/Configurable.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 46f10608bc95e..47c1a3c39f9a8 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -1232,6 +1232,8 @@ public function isPossibleBuyFromList($product) /** * Returns array of sub-products for specified configurable product * + * $requiredAttributeIds - one dimensional array, if provided + * * Result array contains all children for specified configurable product * * @param \Magento\Catalog\Model\Product $product @@ -1245,9 +1247,12 @@ public function getUsedProducts($product, $requiredAttributeIds = null) __METHOD__, $product->getData($metadata->getLinkField()), $product->getStoreId(), - $this->getCustomerSession()->getCustomerGroupId(), - $requiredAttributeIds + $this->getCustomerSession()->getCustomerGroupId() ]; + if (!is_null($requiredAttributeIds)) { + sort($requiredAttributeIds); + $keyParts[] = implode('', $requiredAttributeIds); + } $cacheKey = $this->getUsedProductsCacheKey($keyParts); return $this->loadUsedProducts($product, $cacheKey); } From c819cc0e816e7d0710ac379828bd3107dbe176f1 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 5 Apr 2019 15:58:48 -0500 Subject: [PATCH 2/2] Strict comparison with null instead of is_null function usage --- .../ConfigurableProduct/Model/Product/Type/Configurable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 47c1a3c39f9a8..a849d964eaed5 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -1249,7 +1249,7 @@ public function getUsedProducts($product, $requiredAttributeIds = null) $product->getStoreId(), $this->getCustomerSession()->getCustomerGroupId() ]; - if (!is_null($requiredAttributeIds)) { + if ($requiredAttributeIds !== null) { sort($requiredAttributeIds); $keyParts[] = implode('', $requiredAttributeIds); }