You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you go on a detail page of a variant product, than to another product and than back to the first variant product: The first variant product will be in the slider.
Fix: in "RecentlyViewedProductService" exchange the function "buildRecentProductSliderStruct" with this code:
public function buildRecentProductSliderStruct(SalesChannelContext $context, ?array $excludeProductIds = []): ProductSliderStruct
{
$products = $this->getRecentProductEntities($context) ?? new ProductCollection([]);
if (!empty($excludeProductIds)) {
foreach ($excludeProductIds as $productId) {
if($products->has($productId)){
$products->remove($productId);
continue;
}
// If the $productId is from a child, exclude the parent
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('id', $productId));
$searchResult = $this->salesChannelProductRepository->search($criteria, $context);
$product = $searchResult->getEntities()->first();
$products = $products->filter(function(SalesChannelProductEntity $element) use ($product) {
if($product->getParentId() !== $element->getId()){
return true;
}
return false;
});
}
}
$productSliderStruct = new ProductSliderStruct();
$productSliderStruct->setProducts($products);
return $productSliderStruct;
}
The text was updated successfully, but these errors were encountered:
If you go on a detail page of a variant product, than to another product and than back to the first variant product: The first variant product will be in the slider.
Fix: in "RecentlyViewedProductService" exchange the function "buildRecentProductSliderStruct" with this code:
The text was updated successfully, but these errors were encountered: