EmicoEcommerce / Magento2TweakwiseExport-archived

Magento 2 module for Tweakwise export
Other
6 stars 16 forks source link

Bundle uses childoptions of another bundle when both bundles use the same simple in a option. #118

Closed leonhelmus closed 2 years ago

leonhelmus commented 3 years ago

Issue Brief

What is the purpose of this issue? Explain the background context.

Environment

Steps to reproduce

  1. Create a bundle in the backend with an option that is required with product Z. Reuse that product Z in another bundle and put the option on required and a option that is optional and put a product X & Y in it. Now put product Z on out of stock depending on how the bundle is loaded it will either show the first bundle or the other in the tweakwise feed.

This happens because of the following: When looking at the feed this happens because of the shared class variables for \Emico\TweakwiseExport\Model\Write\Products\Collection, named $this->entities. When looking at the method \Emico\TweakwiseExport\Model\Write\Products\CollectionDecorator\Children::addChild retrieves the same product once it's set. Although it probably shouldn't happen it also sets the class variable \Emico\TweakwiseExport\Model\Write\Products\ExportEntityChild $this->childOptions in the class variable \Emico\TweakwiseExport\Model\Write\Products\Collection, named $this->entities.

Because of this it overwrites the $this->childOptions everytime with new values. This way you can have a optionId that is not mend for that bundle.

Because of these issues it sometimes looks at another option from a other parent product id when using this method: \Emico\TweakwiseExport\Model\Write\Products\ExportEntityBundle::getStockItem. Because it uses the option settings of a other bundle instead of it's own option.

To me it looks like no child products can be shared for bundles. I don't know if this is also an issue for other composed products. But for me this sometimes shows a bundle on the frontend and other times not...

Also when looking at the method: \Emico\TweakwiseExport\Model\Write\Products\ExportEntityBundle

i think line 56 should go after line 60.

if (!$childOptions->isRequired()) {
                $optionGroups[$optionId]['is_in_stock'] = 1;
            }

            $optionGroups[$optionId]['is_in_stock'] = $child->getStockItem()->getIsInStock();

should be:

$optionGroups[$optionId]['is_in_stock'] = $child->getStockItem()->getIsInStock();

if (!$childOptions->isRequired()) {
    $optionGroups[$optionId]['is_in_stock'] = 1;
}

This way you do not overwrite the is_in_stock that was already set when the option is not required.

Actual result

It adds the bundles depending on the query sometimes settings of options that are mend for another bundle. Instead of required => true it sets required false.

Expected result

It should add the bundles on it's own options when it's using the same products as a other bundle instead of the options of another bundle.

RemcoWolterink commented 3 years ago

I hope this could be fixed asap.

Hnto commented 2 years ago

hi @RemcoWolterink are you still experiencing this issue at the latest version?

RemcoWolterink commented 2 years ago

Not tested and at the moment less urgent for us. It was happening with configurable bundle products, but we are facing out those types.

leonhelmus commented 2 years ago

Since it's not relevant anymore i will close the issue. Thanks for looking into it @Hnto