Skip to content

Commit

Permalink
Fixes nested array for used products cache key
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
michaellehmkuhl committed Mar 14, 2019
1 parent 6d8e725 commit 8029be3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down

0 comments on commit 8029be3

Please sign in to comment.