Skip to content
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

MSI: 654: Exception when trying to create Grouped or Bundle product in admin #656

Merged
merged 8 commits into from
Mar 15, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Magento\InventoryConfigurableProduct\Ui\DataProvider\Product\Form\Modifier;

use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Ui\AllowedProductTypes;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\ConfigurablePanel;
use Magento\Ui\Component\Form;
Expand All @@ -16,8 +18,27 @@
*/
class InventoryConfigurablePanel extends AbstractModifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to move this to modifier <type name="Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\Composite">
And remove AllowedProductTypes check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naydav done

{
const RECORD = 'record';
const QUANTITY_CONTAINER = 'quantity_container';
/**
* @var LocatorInterface
*/
private $locator;

/**
* @var AllowedProductTypes
*/
private $allowedProductTypes;

/**
* @param LocatorInterface $locator
* @param AllowedProductTypes $allowedProductTypes
*/
public function __construct(
LocatorInterface $locator,
AllowedProductTypes $allowedProductTypes
) {
$this->locator = $locator;
$this->allowedProductTypes = $allowedProductTypes;
}

/**
* @inheritdoc
Expand Down Expand Up @@ -55,10 +76,13 @@ private function getQuantityContainerConfig(): array
*/
public function modifyMeta(array $meta)
{
$children = 'children';
$meta[ConfigurablePanel::GROUP_CONFIGURABLE][$children]
[ConfigurablePanel::CONFIGURABLE_MATRIX][$children]
[static::RECORD][$children][static::QUANTITY_CONTAINER] = $this->getQuantityContainerConfig();
if ($this->allowedProductTypes->isAllowedProductType($this->locator->getProduct())) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use this code for products different from configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because simple, virtual and downloadable product can be converted to configurable.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving InventoryConfigurablePanel we can remove this double check

$matrix = $meta[ConfigurablePanel::GROUP_CONFIGURABLE]['children'][ConfigurablePanel::CONFIGURABLE_MATRIX];

$matrix['children']['record']['children']['quantity_container'] = $this->getQuantityContainerConfig();

$meta[ConfigurablePanel::GROUP_CONFIGURABLE]['children'][ConfigurablePanel::CONFIGURABLE_MATRIX] = $matrix;
}

return $meta;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@
</argument>
</arguments>
</virtualType>
<type name="Magento\InventoryConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\InventoryConfigurablePanel">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving InventoryConfigurablePanel we can remove this double check

<arguments>
<argument name="allowedProductTypes" xsi:type="object">Magento\Catalog\Ui\BaseAllowedProductTypes</argument>
</arguments>
</type>
</config>