-
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
CE 2.1.7 Attributes - Display Out of Stock Products #10454
Comments
The issue seems to be in a way how Magento retrieves products for showing as a configurable options. In the Magento\ConfigurableProduct\Block\Product\View\Type\Configurable:: getAllowProducts method it checks for the Since the flag is In other words, "Display Out of Stock Products" configuration does not make any difference in building configurable product options. |
Any update on this? Major issue for us. |
I'm working on it #SQUASHTOBERFEST |
Is there any updates on if this has been fixed at all on Magento 2.1.9? |
@callumstar no, it's not fixed in 2.2.1 either. |
Was assigned to Development in Progress. Then was unassigned. Fun stuff. |
I have stumbled across this issue. It seems to be caused by this class: \Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder. This plugin ignores the stock-config check completely. I have overridden this plugin to look like this:
} I am not using the swatches, so it may cause that to break. But with using the selectors, it works correctly. |
Hi @wejobes, |
how is this on 2.2.6? |
@piwni I tried your fork on 2.2.6. but it goes back to hiding the option alltogether. What would be the correct way to implement it? |
@josh-carter i've use your extension, but it doesn't work on magento 2.2.5 |
It seems to me that there may be more things that need to be taken into consideration. I'll take a look at it in a free while. |
@piwni thanks you, i've searching for this issue all day long and find a lot of code and suggestion, but none of them work so far. |
I'm also having this problem in magento2.3 // I have found that the configurable $options data is initially set here
// I have made it so that this returns the entire array of attribute codes and product numbers -
// - for the configurable regardless of stock status
/* @var \Magento\ConfigurableProduct\Helper\Data $this->$helper */
$options = $this->helper->getOptions($currentProduct, $this->getAllowProducts()); Note that the $options[array] correctly contains all out of stock attribute ids => product ids This $options array is passed to a function that attempts to serialize/add extra data that is required buy the js renderer such as labels.
/**
* Get product attributes
*
* @param Product $product
* @param array $options
* @return array
*/
public function getAttributesData(Product $product, array $options = [])
{
$defaultValues = [];
$attributes = [];
$productInstance = $product->getTypeInstance();
$productEnabledAttributes = $productInstance ->getConfigurableAttributes($product);
foreach ($productEnabledAttributes as $attribute) {
$attributeOptionsData = $this->getAttributeOptionsData($attribute, $options);
if ($attributeOptionsData) {
$productAttribute = $attribute->getProductAttribute();
$attributeId = $productAttribute->getId();
$attributes[$attributeId] = [
'id' => $attributeId,
'code' => $productAttribute->getAttributeCode(),
'label' => $productAttribute->getStoreLabel($product->getStoreId()),
'options' => $attributeOptionsData,
'position' => $attribute->getPosition(),
];
$defaultValues[$attributeId] = $this->getAttributeConfigValue($attributeId, $product);
}
}
return [
'attributes' => $attributes,
'defaultValues' => $defaultValues,
];
} However getAttributesData does not obey the $options param. A sub call function must unwittingly run a filter operation. Observe below how the return $attributesData has filtered attribute "138" From the getAttributesData() function, I'm suspecting getConfigurableAttributes() to be the cause of out of stock options not displaying in magento 2.3, this function retrieves data from a cache that was generated a few clock cycles ago. /**
* Retrieve configurable attributes data
*
* @param \Magento\Catalog\Model\Product $product
* @return \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute[]
*/
public function getConfigurableAttributes($product)
{
\Magento\Framework\Profiler::start(
'CONFIGURABLE:' . __METHOD__,
['group' => 'CONFIGURABLE', 'method' => __METHOD__]
);
if (!$product->hasData($this->_configurableAttributes)) {
$configurableAttributes = $this->getConfigurableAttributeCollection($product);
$this->extensionAttributesJoinProcessor->process($configurableAttributes);
$configurableAttributes->orderByPosition()->load();
$product->setData($this->_configurableAttributes, $configurableAttributes);
}
\Magento\Framework\Profiler::stop('CONFIGURABLE:' . __METHOD__);
return $product->getData($this->_configurableAttributes);
} Really confused atm. That stack trace is insane. |
There's a configuration available in admin that says "Show out of stock product" I'm under the impression that this should also apply to configurable products, however the js render code doesn't seem to disable options that are out of stock in selection. This is perhaps why there's two plugins dedicated to making sure out of stock options don't show. Culprit plugin locations:
Since those plugins weren't following the "Show out of stock product" configuration, I added an afterGetSelect plugin checks for the "Show out of stock product" config. I changed the Json builder to send preorder data and in stock information to my override of the configurable product render code. Result: This is what I was trying to do: this explains what the culprit plugins do:'stock check added here' https://i.imgur.com/vnJ4oqA.png 'aaaannnndddd here again for good measure'https://i.imgur.com/Jr6TSBb.png TLDR: Some one at magento doubly doesn't want people getting out of stock options. Configurable SQL table layout is really complex. |
Hi @PathToLife, |
Yep MSI is enabled, but we're not using it. Regardless the culprit plugins should have a check for the "Show out of stock product" (Store ID basis) configuration anyhow. And the configurable js code might need updating so dropdown options are greyed out / show out of stock message |
Ha alright, thanks for the info. Otherwise i m not sure, but i believe some of your work was already done in the plugin mentioned above(https://github.com/interjar/configurable-child-visibility). Anyway good job 👍 |
I am also facing this problem here, Did you get any solution ? |
Still occurs in Magento 2.3 The above module fix does not work for 2.3 Any movement on this or suggestions? |
Still exist in Magneto 2.3, I have tested in 2.3-develop branch. Is there any fix for this issue? |
Have there been any updates on this bug? |
What about you? Your repository was installed more than 6000 times. Are you planning an update for https://github.com/interjar/configurable-child-visibility to be compatible with magento 2.3? @magento: |
@magento This is an extremely basic requirement for any e-commerce platform. How has this bug been allowed to remain unresolved for over two years? This is seriously worrying; if something this fundamental isn't fixed, what other problems might be lurking within the platform? |
Have you tested this with configurable products only having one attribute varient? Related |
Is there a solution for 2.3? |
It seems like the confusion stems from if there's one colour or multiple colour choices. If there is only one colour choice available, the sold out size will be hidden. Whereas if there are multiple colour choices available, the sold out size will be striked when the sold out colour is selected. Personally, I would like the option to always show the sold out size, regardless of the number of colours available. |
@engcom-Charlie Why close this issue instead of seeking clarification? This is still a problem in 2.4! This is the kind of thing making me really frustrated with Magento. |
@diamondavocado @palomamtnez Did you find a solution for this? |
This has been closed incorrectly. See @toby-pondr's comment. This is only an issue if the product only has one color. |
@stroblee looks like only the original author can re-open this. Mind re-opening? |
@engcom-Charlie @magento-engcom-team this closure is based on a misunderstanding of the issue at hand here, see response from @MichaelThessel and the recently opened issue by them also #30046. The intention is clearly to show out stock swatch options, the screenshot demonstrates this: But this doesn't happen when there is only one attribute, so it is only partially working. |
Helloooooo, |
Preconditions
Steps to reproduce
Expected result
Actual result
Other Information
The text was updated successfully, but these errors were encountered: