-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[2.4.4] Product with Salable Qty of 0 shows 'In Stock' on product page #35319
Comments
Hi @FadedOut. Thank you for your report.
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento give me 2.4-develop instance |
Hi @VZeroCool. Thank you for your request. I'm working on Magento instance for you. |
Hi @VZeroCool, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
Hi @engcom-November. Thank you for working on this issue.
|
Hi @FadedOut , Thank you for reporting and collaboration. Scenario 2: Existing Product - If both Product Quantity & Salable Quantity = 0, User is not able to select swatch (Crossed out) in 2.4.3-p1 instance and "The requested qty is not available" error message is displayed in 2.4.4 version Scenario 3: New Product created in 2.4.4 version with Product Quantity 0 - "There are no source items with the in stock status" error message is displayed |
@magento give me 2.4-develop instance |
Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-November, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
✅ Jira issue https://jira.corp.magento.com/browse/AC-2877 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-November. Thank you for verifying the issue. |
Thank you @engcom-November for verifying. |
This happens for me in a test site using PHP 8.1, but if I revert to 7.4 the error goes away. |
This error: Product EAV index process error during indexation process: Deprecated Functionality: explode(): Passing null to parameter #2 ($string) of type string is deprecated in vendor/magento/module-catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php on line 444 Is also happening for us. There are bunch of entries with null values on the eav tables. And that particular line, under PHP8.1 is preventing the proper reindex of the EAV indices. |
Yeah it's weird, for me, if I run the command: bin/magento indexer:reindex then the error shows in the terminal. And in the Magento Admin [index management] it will say "Reindex Required" for the Product EAV. But the odd part: if I don't run the command and let CRON do it, the "Reindex Required" doesn't appear, it seams to run fine when ran by CRON. So I'm not sure what is going on there, if the Product EAV is not really ever being completed correctly...but @engcom-November said reindexing was working fine for him, so I don't know... And are you talking about the "catalog_product_index_eav" table? If so, I didn't see any "NULL" but I do have quite a few "1"s under the 'value' column. I'm guessing that's not correct. It's also bloated, like 75k rows. Not sure if that is correct... |
Hi, please correct me if my input is wrong or irrelevant. I'm strugling to find a solution for an option of a configurable product to be striked-through instead of normally displayed in case it is out-of-stock. After a lot of searching I ended up to this patch MDVA-34850 here https://experienceleague.adobe.com/tools/commerce-quality-patches/index.html |
I am having a similar issue.
Changing line 444 from: Makes this PHP8.1 compatible. Is this just missing 8.1 compatibility or does it signal something incorrectly set or missing in my database for product attrributes? |
Pretty certain that just means it's missing PHP 8.1 compatibility. Because that was popping up for me on a few different modules (the $string with null error). Once they were updated for PHP 8.x those errors went away. |
@FadedOut thanks for the response. This issue should be addressed in the module rather than Magento itself? |
@drinkingsouls No prob. Yup, it has to be fixed in the module because Magento works fine with PHP 8.x now. So if you're still getting problems like that it's because the module is not compatible with PHP 8.x - you'd have to bring that up with the module developers. |
Guys the issue here is actually "Product with Salable Qty of 0 shows 'In Stock' on product page". By mistake it was correlated with "Product EAV index process error" as explained by @FadedOut . So please let's stick to the initial issue which is also major! |
You are correct in that this is really about the stock and the dropdowns/swatches. But As for using the fix from the official patch posted (by engcom-Hotel on July 18) I had issues with it. So just use what has already been posted that has been confirmed to work. That is what has been already mentioned, the fix linked in my first OP (first line) works fine for now. Don't get all bent out of shape until you fully read a bug report topic - there has been a temp fix posted. If there wasn't then I could understand your concern (as there are indeed several like these - no temp fixes) but it's not warranted here, thanks to the great members above we have a fix for now. |
@FadedOut so if I understood correctly you suggest to use the patch here #35319 (comment) and not the official patch that is planned to be rolled out in 2.4.6 version? Please bear in mind I have 2.4.5 and not 2.4.4. Can this make a difference? |
Yes that comment by "loic-paquin" that you linked to is correct. It is also not a "patch" it is simply a hack to make it work. It is not intended to be "official" in any capacity - it is a temporary fix until the official fix is released (2.4.6). You can use this fix for 2.4.5. I am on 2.4.5-p1 and have used that and it works fine (though do remember modifying core files is not recommended for the main reason of when upgrading to a new version of Magento the "hack" gets overridden - I had to reimplement the fix when I upgraded from 2.4.4 to 2.4.5). As for mentioning that I had "issues" with the official commit does not mean there is any wrong with it. It is simply that it's a code release not for this version (2.4.5), it is code for 2.4.6. Which is why the developer said it would be fixed in 2.4.6. Magento and it's code can indeed be complicated, so if you're not able to make sense of what to do, you may wish to hire a coder/Magento developer to help you with it. The comments (the fix posted) I believe to be maybe a 4 or 5/10 complicated, you just have to read thoroughly. But, I do understand making changes like that is not for everyone, to which is why I say you may want to hire someone to help with that. The information on how to make it work has been given and there is nothing more that needs to be done or said until the official fix is released with 2.4.6. The fix (also here: #35319 (comment) ) works so you'll just have to read it thoroughly or you may wish to hire someone to help. If you do decide to attempt it yourself, the best thing you can do is simple: just make a backup of the file before you modify it. Then modify it and run the standard commands (I use the following for an all-in-one command). Then test if what you did worked. If not, revert the file and try again. But always keep a backup of the file and you'll be fine. It's posted in that comment which file it is.
Sorry I can't help more but I would just be a broken record and be wasting my time - everything you need has been posted already. With that fix you'll have a proper working variation stock visual. |
@FadedOut thank you for your detailed answer! |
@FadedOut |
@rohitkumawat17 I'm sorry I'm not following. This topic has plenty of information to help you get this issue resolved. Simply follow the instructions posted above to have the cross-outs working correctly. And these changes still work fine with 2.4.5-p1 (I'm using it currently). Here: #35319 (comment) |
I am still facing the issue. If the product has 2 attributes size and color. |
@rohitkumawat17 if you do that fix you will not have the issue. Simple. If you modified the file and it is still doing it, then you've modified it wrong. My current site is living proof it works. Or you didn't run the proper commands after modifying the file. Run: That's my super-all-in-one command. |
Hi,
Can you provide me the file? So I can confirm my file if I left anything?
I updated these files:
1. Swatch-renderer.js
2. Data.php
…On Fri, Jan 27, 2023, 3:53 PM James Noon ***@***.***> wrote:
@rohitkumawat17 <https://github.com/rohitkumawat17> if you do that fix
you will not have the issue. Simple. If you modified the file and it *is*
still doing it, then you've modified it wrong. My current site is living
proof it works.
Or you didn't run the proper commands after modifying the file. Run:
rm -rf var/cache/* ; rm -rf var/page_cache/* ; rm -rf
var/view_preprocessed/* ; rm -rf pub/static/*/* ; rm -rf generated/code/* ;
rm -rf generated/metadata/* ; php bin/magento setup:upgrade ; php
bin/magento setup:di:compile ; php bin/magento setup:static-content:deploy
; php bin/magento cache:flush ; php bin/magento cache:clean
That's my super-all-in-one command.
—
Reply to this email directly, view it on GitHub
<#35319 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AW67S6NKPDPQDA7CRWJHGITWUOO2ZANCNFSM5TRICPVQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'm not sure what you modified in swatch-rendering.js as there was no "fix" posted for that file... Hopefully you have originals of both of those files. Always make a copy/backup of files then modify the new (copied file). If you have the originals, restore them and only make a copy of Data.php. But no problem I'll add it below. This is for the composer installed Magento - not sure if the file would be the same for the non-composer version. EDIT: I should mention this file is from 2.4.5-p1, so directly replacing it in a 2.4.4 may not be super wise (if you're on 2.4.4 that is) - I'm not sure if anything else in the file changed from 2.4.4 to 2.4.5-p1. Use a program like WinMerge to compare. But ultimately the changes happened on lines 93-110 I put the file into the correct folder structure for you to have a better understanding of where to put it. But as a refresher: And again, make sure to run that command above after replacing the file. And clearing browser cache. |
Can you double-check this please. This problem still exists in 2.4.6-p1, we still have to do the hack mentioned here: #35319 (comment). Will this ever get fixed properly so we can stop hacking files? It has been years with this issue (v2.4.1 in 2020!!! #31117) @engcom-November @engcom-Alfa @engcom-Bravo @engcom-Charlie Can someone actually investigate and fix this? You guys add tags with "Progress: done" but it's never actually fixed... |
Hi @FadedOut, Thanks for your update. It is Working as expected in Magento 2.4-develop instance the configurable variation is crossed out and we are not able to add to cart. Issue is reproducible in Magento 2.4.6-p1 instance.swatches are not crossed out. It is working as expected in Magento 2.4.7-beta1 instance.swatches are crossed out. Issue seems to fixed in latest version of the Magento i.e Magento 2.4.7-beta1.kindly upgrade to latest version of the Magento. Thanks. |
Could someone explain if this is possible and how I can apply the fix provided in version 2.4.7 to version 2.4.5? Thank you |
I think this issue still exists on a product with a mix of swatches and dropdown attributes. It uses swatch-renderer.js (rather than configurable.js) in that case and swatch-renderer only disables the swatch options, not the dropdown options. |
Hello @nthurston I ran into the exact same issues using MAgento 2.4.6-p3. Have you found a fix for this back in the day? |
I still have this problem on 2.4.5-p7, even with 2.4-develop changes applied. I'm trying to figure out where this all goes wrong. I have MSI enabled, with two different stock sources - both show incorrect on their respective website: website 1: b2c stock Can believe this is so hard to get right. |
I have managed to get this to work, my conclusion is that the isSalable() is not checking for any quantities on the salable stock. So if you make $product->isSalable() you always get true. This is not following best pratices, and is only used as a demonstration of the issue source. My solution consists on only touching file vendor/magento/module-configurable-product/Helper/Data.php , the file below is from version 2.4.6-p4 , modified with the issue tag. <?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ConfigurableProduct\Helper;
use Magento\Catalog\Model\Product\Image\UrlBuilder;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Helper\Image as ImageHelper;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Image;
use Magento\Catalog\Api\ProductRepositoryInterface; /* Salable Issue */
use Magento\InventorySalesApi\Api\GetProductSalableQtyInterface; /* Salable Issue */
/**
* Class Data
*
* Helper class for getting options
* @api
* @since 100.0.2
*/
class Data
{
/**
* @var ImageHelper
*/
protected $imageHelper;
/**
* @var UrlBuilder
*/
private $imageUrlBuilder;
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
protected $productRepository; /* Salable Issue */
protected $getProductSalableQty; /* Salable Issue */
/**
* @param ImageHelper $imageHelper
* @param UrlBuilder|null $urlBuilder
* @param ScopeConfigInterface|null $scopeConfig
*/
public function __construct(
ImageHelper $imageHelper,
UrlBuilder $urlBuilder = null,
?ScopeConfigInterface $scopeConfig = null,
ProductRepositoryInterface $productRepository, /* Salable Issue */
GetProductSalableQtyInterface $getProductSalableQty /* Salable Issue */
) {
$this->imageHelper = $imageHelper;
$this->imageUrlBuilder = $urlBuilder ?? ObjectManager::getInstance()->get(UrlBuilder::class);
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
$this->productRepository = $productRepository; /* Salable Issue */
$this->getProductSalableQty = $getProductSalableQty; /* Salable Issue */
}
/**
* Retrieve collection of gallery images
*
* @param ProductInterface $product
* @return Image[]|null
*/
public function getGalleryImages(ProductInterface $product)
{
$images = $product->getMediaGalleryImages();
if ($images instanceof \Magento\Framework\Data\Collection) {
/** @var $image Image */
foreach ($images as $image) {
$smallImageUrl = $this->imageUrlBuilder
->getUrl($image->getFile(), 'product_page_image_small');
$image->setData('small_image_url', $smallImageUrl);
$mediumImageUrl = $this->imageUrlBuilder
->getUrl($image->getFile(), 'product_page_image_medium');
$image->setData('medium_image_url', $mediumImageUrl);
$largeImageUrl = $this->imageUrlBuilder
->getUrl($image->getFile(), 'product_page_image_large');
$image->setData('large_image_url', $largeImageUrl);
}
}
return $images;
}
/**
* Get Options for Configurable Product Options
*
* @param Product $currentProduct
* @param array $allowedProducts
* @return array
*/
public function getOptions($currentProduct, $allowedProducts)
{
$options = [];
$allowAttributes = $this->getAllowAttributes($currentProduct);
foreach ($allowedProducts as $product) {
$productId = $product->getId();
foreach ($allowAttributes as $attribute) {
$productAttribute = $attribute->getProductAttribute();
$productAttributeId = $productAttribute->getId();
$attributeValue = $product->getData($productAttribute->getAttributeCode());
/*if ($this->canDisplayShowOutOfStockStatus()) {
if ($product->isSalable()) {
$options['salable'][$productAttributeId][$attributeValue][] = $productId;
}
$options[$productAttributeId][$attributeValue][] = $productId;
} else {
if ($product->isSalable()) {
$options[$productAttributeId][$attributeValue][] = $productId;
}
}*/
/********************* Salable Issue ************************/
$product = $this->productRepository->get($product->getSku());
$stockItem = $product->getExtensionAttributes()->getStockItem();
if( $stockItem->getManageStock() && $this->getProductSalableQty->execute($product->getSku(), 1) > 0) {
$options['salable'][$productAttributeId][$attributeValue][] = $productId;
}
if( !$stockItem->getManageStock() ) {
$options['salable'][$productAttributeId][$attributeValue][] = $productId;
}
$options[$productAttributeId][$attributeValue][] = $productId;
/********************* Salable Issue ************************/
$options['index'][$productId][$productAttributeId] = $attributeValue;
}
}
$options['canDisplayShowOutOfStockStatus'] = $this->canDisplayShowOutOfStockStatus();
return $options;
}
/**
* Get allowed attributes
*
* @param Product $product
* @return array
*/
public function getAllowAttributes($product)
{
return ($product->getTypeId() == Configurable::TYPE_CODE)
? $product->getTypeInstance()->getConfigurableAttributes($product)
: [];
}
/**
* Returns if display out of stock status set or not in catalog inventory
*
* @return bool
*/
private function canDisplayShowOutOfStockStatus(): bool
{
return (bool) $this->scopeConfig->getValue('cataloginventory/options/show_out_of_stock');
}
} |
I will try this asap, still have issues with configurables seemingly out of stock even though the simples have returned to a positive qty. |
FIX:
A quick non-official hack/fix was posted further below by @loic-paquin and @jas8522 here
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Product EAV index process error during indexation process: Deprecated Functionality: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/********/public_html/vendor/magento/module-catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php on line 444
My previous installation of 2.4.3-p1 that I just upgraded from, this worked as intended (out of stock variations could not be selected/clicked. It showed a cross-through of the variation that was out of stock). It now does not do this, after upgrading to 2.4.4.
Below are screenshots of the product page as well as the admin/backend showing 0 for default stock quantity. This example is shown on the stock Magento Luma theme.
EDIT/UPDATE:
The original report of EAV indexing (using CLI) failing might be related, was incorrect. It is not related and made no difference for the bug of "Product with Salable Qty of 0 shows 'In Stock' on product page" - they are separate issues.
Additional Information:
#35319 (comment)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: