-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: CatalogEvent: WroCDContribution day in WroContribution day in WroIssue: Cannot ReproduceCannot reproduce the issue on the latest `2.4-develop` branchCannot reproduce the issue on the latest `2.4-develop` branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releasebug report
Description
Steps to reproduce
- Install Magento from 2.1 branch.
- Set up API integration
- Send call to create Simple Product via /V1/products endpoint
- Once simple has been added, create Configurable Product via V1/products endpoint
- Add Simple Product created on Step 3 via /V1/configurable-products/{sku}/child to the Configurable Product created on Step 4.
Expected result
- 200 Response (return true) when adding the child product to the parent
Actual result
- [Example] Error message appears: "Product has been already attached".
--- actual error ----
{"message":"Product has been already attached","trace":"#0 [internal function]: Magento\ConfigurableProduct\Model\LinkManagement->addChild('576b124120360', '576b12351fb04')\n#1 /var/www/staging.streetwear.la/public_html/app/code/Magento/Webapi/Controller/Rest.php(307): call_user_func_array(Array, Array)\n#2 /var/www/staging.streetwear.la/public_html/app/code/Magento/Webapi/Controller/Rest.php(216): Magento\Webapi\Controller\Rest->processApiRequest()\n#3 /var/www/staging.streetwear.la/public_html/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(37): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#4 /var/www/staging.streetwear.la/public_html/lib/internal/Magento/Framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#5 /var/www/staging.streetwear.la/public_html/lib/internal/Magento/Framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()\n#6 /var/www/staging.streetwear.la/public_html/index.php(44): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))\n#7 {main}"}
In closing:
I tested the the endpoint method addChild() located on line 95 on file:
app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
Here is the method with notes:
public function addChild($sku, $childSku)
{
$product = $this->productRepository->get($sku);
$child = $this->productRepository->get($childSku);
$childrenIds = array_values($this->configurableType->getChildrenIds($product->getId())[0]);
if (in_array($child->getId(), $childrenIds)) {
throw new StateException(__('Product has been already attached'));
}
$childrenIds[] = $child->getId();
$product->setAssociatedProductIds($childrenIds);
$product->save();
return true;
}
This IF statement (in_array($child->getId(), $childrenIds)) fires if the ID of $childSku is returned by this line:
$childrenIds = array_values($this->configurableType->getChildrenIds($product->getId())[0]);
The weird part is that the exception that is executed here:
throw new StateException(__('Product has been already attached'));
fires even after adding the FIRST Single Product to the Configurable and that is what the BUG is.
dmanners
Metadata
Metadata
Assignees
Labels
Component: CatalogEvent: WroCDContribution day in WroContribution day in WroIssue: Cannot ReproduceCannot reproduce the issue on the latest `2.4-develop` branchCannot reproduce the issue on the latest `2.4-develop` branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releasebug report