-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Imported bundle products are not assigned stock status #12330
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
Comments
Addendum: this also happens when you add customisable options or change whether they are required. |
We are experiencing the same with the same configuration/stack and steps to reproduce. |
@indefinitedevil, thank you for your report. |
@magento-engcom-team Any ETA on this please guys? Our client's website has around 80% of it's products as Bundles. They are on M2.1.5 which is extremely broken and we're trying to get them upgraded to 2.2 but this is a massive show stopper. Please provide an update or temporary fix. Thank you, Tony. |
@magento-engcom-team - This is also an issue for me. After upgrading from M2.1.5 bundles no longer display. Same process listed by @indefinitedevil |
@magento-engcom-team Is anybody going to get back to us re. this please? We cannot launch our clients website without this working so this is causing us a huge amount of problems! Any workaround at this point would be massively appreciated just to get the bundle products appearing. Thanks, Tony |
Can you assign this to me? I’ll fix it. Please add import/export label. Thanks! |
Glad to see this on the way to resolution. For anyone waiting on a fix, what worked for us was: 1) import the simples on which your bundles are based; 2) import the bundles via csv; 3) note the stock status on the bundles is out of stock (the bug); 4) create a dummy simple called "AAA" with inventory zero; 5) For each bundle product, add the AAA simple to the bundle values and save it out; 6) Note the stock status is in-stock and since there is zero inventory of AAA, that option does not display; ("AAA" we used for easy sorting by name when adding the simple to the bundle). Not a very elegant solution, but it kept our project going. |
This issue was moved to magento-engcom/import-export-improvements#80 |
The issue is not that the entry doesn't exist. Even if the entry exists, and you change the status to a 1 in the db, after reindex stock it sets it back to zero. |
did you find a solution for this? I'm having the same problem. |
TonyBrown_ForceInventory.zip Version 1.0.0 forces this flag for all simple and bundle products as default during the indexing process. |
@tonybrown85 |
I'd recommend using version 1.0.0 instead as that should work fine and just force as default, as opposed to using a product attribute to conditionally force it. I've just installed it on my local copy of M.2.2.1 but I cannot replicate the error. Perhaps change it to if($subject->getData('force_visibility')) instead within both bundle.php and simple.php. That may fix it but I'm hazarding a guess. Sorry I'm unable to help further but unfortunately I don't have the time to replicate, debug and fix. |
I'm not sure if this is the same issue, but after upgrading from 2.1.9 to 2.2.3, I discovered all of my bundle products were showing as out of stock and with a price of $0. I found the offending code and reverted it back to the 2.1.12 version until a proper fix has been released. To fix the price issue, open //**********************************************************
//* Added from 2.1.12 due to a bug in 2.2.0
//**********************************************************
// Flag shows - is it necessary to find minimal option amount in case if all options are not required
$shouldFindMinOption = false;
if ($searchMin
&& $bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC
&& !$this->hasRequiredOption($bundleProduct)
) {
$shouldFindMinOption = true;
}
$canSkipRequiredOptions = $searchMin && !$shouldFindMinOption;
$currentPrice = false;
$priceList = [];
foreach ($this->getBundleOptions($bundleProduct) as $option) {
if ($this->canSkipOption($option, $canSkipRequiredOptions)) {
continue;
}
$selectionPriceList = $this->createSelectionPriceList($option, $bundleProduct, $useRegularPrice);
$selectionPriceList = $this->processOptions($option, $selectionPriceList, $searchMin);
$lastSelectionPrice = end($selectionPriceList);
$lastValue = $lastSelectionPrice->getAmount()->getValue() * $lastSelectionPrice->getQuantity();
if ($shouldFindMinOption
&& (!$currentPrice ||
$lastValue < ($currentPrice->getAmount()->getValue() * $currentPrice->getQuantity()))
) {
$currentPrice = end($selectionPriceList);
} elseif (!$shouldFindMinOption) {
$priceList = array_merge($priceList, $selectionPriceList);
}
}
return $shouldFindMinOption ? [$currentPrice] : $priceList;
//*********************************************************
//* End 2.1.12 code
//********************************************************* To fix the stock issue, open //**********************************************************
//* Added from 2.1.12 due to a bug in 2.2.0
//**********************************************************
$optionCollection = $this->getOptionsCollection($product);
if (!count($optionCollection->getItems())) {
return false;
}
$requiredOptionIds = [];
foreach ($optionCollection->getItems() as $option) {
if ($option->getRequired()) {
$requiredOptionIds[$option->getId()] = 0;
}
}
$selectionCollection = $this->getSelectionsCollection($optionCollection->getAllIds(), $product);
if (!count($selectionCollection->getItems())) {
return false;
}
$salableSelectionCount = 0;
foreach ($selectionCollection as $selection) {
/* @var $selection \Magento\Catalog\Model\Product */
if ($selection->isSalable()) {
$selectionEnoughQty = $this->_stockRegistry->getStockItem($selection->getId())
->getManageStock()
? $selection->getSelectionQty() <= $this->_stockState->getStockQty($selection->getId())
: $selection->isInStock();
if (!$selection->hasSelectionQty() || $selection->getSelectionCanChangeQty() || $selectionEnoughQty) {
$requiredOptionIds[$selection->getOptionId()] = 1;
$salableSelectionCount++;
}
}
}
$isSalable = array_sum($requiredOptionIds) == count($requiredOptionIds) && $salableSelectionCount;
$product->setData('all_items_salable', $isSalable);
return $isSalable;
//*********************************************************
//* End 2.1.12 code
//********************************************************* |
From reading magento-engcom/import-export-improvements#80 I gather the problem is that the import does not populate table
|
@domeglic my problem has the same symptoms, but |
@domeglic I confirm that this query solved my issue, Thank you! |
After several days of research and headaches, thank you @domeglic. It solved my issue. This "bug" is still not fixed in Magento 2.2.4. It would be very nice, if this bug will be fixed in the next version? |
Hi @indefinitedevil. Thank you for your report.
The fix will be available with the upcoming 2.3.0 release. |
I believe the same issue still applies to Magento 2.3, if you edit and "save and duplicate" a bundle it doesn't update the catalog_product_relation table |
A workaround for the bug is to add a bundle option and selection entry manually and save the bundle product, then delete the option manually or via $option->delete(); and finally import via file the desired options and selections for the bundle. |
Solved!!! Thanks |
Hi, I don't think this has been merged right? Can you confirm? |
@magento give me 2.3.4 instance |
Hi @tuanpt-0634. Thank you for your request. I'm working on Magento instance for you. |
Hi @tuanpt-0634, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
@magento give me 2.3.4 instance |
Hi @tuanpt-0634. Thank you for your request. I'm working on Magento instance for you. |
Hi @tuanpt-0634, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
@magento give me 2.3.4 instance |
Hi @tuanpt-0634. Thank you for your request. I'm working on Magento instance for you. |
Hi @tuanpt-0634, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
When importing a new bundle product (can be entirely new, or generated through replacement), no entry is generated for it in cataloginventory_stock_status. This means that when the frontend tries to display it, it encounters a NULL entry when trying to discover whether the product is salable.
vendor/magento/module-catalog/Model/Product/Type/AbstractType.php line 355
When running getData('is_salable'), this returns NULL because the cataloginventory_stock_status row doesn't exist. Because it returns NULL, the isSalable function returns false, and that means that the bundle product does not appear in category lists and shows as out of stock on the frontend.
Reindexing does not resolve issue, and neither does saving the product in the backend.
Preconditions
Steps to reproduce
3.a) change the SKU of the bundle product and import it
3.b) re-import it in Replace mode
Expected result
Actual result
The text was updated successfully, but these errors were encountered: