Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

category product list swatches always appear in_stock #3527

Open
ioweb-gr opened this issue Sep 19, 2023 · 2 comments
Open

category product list swatches always appear in_stock #3527

ioweb-gr opened this issue Sep 19, 2023 · 2 comments

Comments

@ioweb-gr
Copy link
Contributor

ioweb-gr commented Sep 19, 2023

Preconditions (*)

  1. OpenMage 20.1.1

Steps to reproduce (*)

I'm not sure how to replicate this, in our installation we had swatches enabled for configurable products by size and upgraded to the newer version only to see that all swatches even for not-saleable products would show up in category display page, but when the user would click on any product, in the product display page he would see only the saleable products instead.

It turns out that the stock item is not properly loaded giving me a null value normally when used like this

$isInStock = $childProduct->getStockItem()->getIsInStock();

By switching to load the stock item properly it works perfectly fine

e.g.

Index: app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php
--- a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php	
+++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php	(date 1695106866756)
@@ -100,7 +100,8 @@
 
                 foreach ($parentProduct->getChildrenProducts() as $childProduct) {
                     // product has no value for attribute or not available, we can't process it
-                    $isInStock = $childProduct->getStockItem()->getIsInStock();
+                    $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($childProduct);
+                    $isInStock = $stockItem->getIsInStock();
                     if (!$childProduct->hasData($attribute->getAttributeCode())
                         || (!$isInStock && !Mage::helper('cataloginventory')->isShowOutOfStock())
                     ) {

Expected result (*)

  1. Only salable products appear

Actual result (*)

  1. All swatches appear even for the not-available products

CDP

image

PDP

image

@elidrissidev
Copy link
Member

This seems like a duplicate of #1694, can you confirm or is it a new bug in this version?

@ioweb-gr
Copy link
Contributor Author

My case is only for the list page , not the product page so I think it's related but not the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants