Skip to content

Commit

Permalink
Merge pull request magento#731 from magento-engcom/619
Browse files Browse the repository at this point in the history
MSI-719: Investigate fails test on Groped products
  • Loading branch information
Valeriy Nayda authored Mar 26, 2018
2 parents 3b5a20b + 3e81526 commit 0758ae1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

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

use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\InventoryCatalog\Model\IsSingleSourceModeInterface;
use Magento\InventoryConfiguration\Model\IsSourceItemsAllowedForProductTypeInterface;

/**
* Quantity modifier on CatalogInventory Product Editing Form
Expand All @@ -26,17 +28,33 @@ class Quantity extends AbstractModifier
*/
private $isSingleSourceMode;

/**
* @var LocatorInterface
*/
private $locator;

/**
* @var IsSourceItemsAllowedForProductTypeInterface
*/
private $isSourceItemsAllowedForProductType;

/**
* CatalogInventory constructor.
* @param ArrayManager $arrayManager
* @param IsSingleSourceModeInterface $isSingleSourceMode
* @param LocatorInterface $locator
* @param IsSourceItemsAllowedForProductTypeInterface $isSourceItemsAllowedForProductType
*/
public function __construct(
ArrayManager $arrayManager,
IsSingleSourceModeInterface $isSingleSourceMode
IsSingleSourceModeInterface $isSingleSourceMode,
LocatorInterface $locator,
IsSourceItemsAllowedForProductTypeInterface $isSourceItemsAllowedForProductType
) {
$this->arrayManager = $arrayManager;
$this->isSingleSourceMode = $isSingleSourceMode;
$this->locator = $locator;
$this->isSourceItemsAllowedForProductType = $isSourceItemsAllowedForProductType;
}

/**
Expand All @@ -58,6 +76,12 @@ public function modifyMeta(array $meta)
return $meta;
}

$product = $this->locator->getProduct();

if ($this->isSourceItemsAllowedForProductType->execute($product->getTypeId()) === false) {
return $meta;
}

if ($this->isSingleSourceMode->execute() === true) {
$meta = $this->arrayManager->merge(
$stockQtyPath . '/children/qty/arguments/data/config',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

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

use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\InventoryCatalog\Model\IsSingleSourceModeInterface;
use Magento\InventoryConfiguration\Model\IsSourceItemsAllowedForProductTypeInterface;

/**
* StockStatus modifier on CatalogInventory Product Editing Form
Expand All @@ -26,17 +28,33 @@ class StockStatus extends AbstractModifier
*/
private $isSingleSourceMode;

/**
* @var LocatorInterface
*/
private $locator;

/**
* @var IsSourceItemsAllowedForProductTypeInterface
*/
private $isSourceItemsAllowedForProductType;

/**
* CatalogInventory constructor.
* @param ArrayManager $arrayManager
* @param IsSingleSourceModeInterface $isSingleSourceMode
* @param LocatorInterface $locator
* @param IsSourceItemsAllowedForProductTypeInterface $isSourceItemsAllowedForProductType
*/
public function __construct(
ArrayManager $arrayManager,
IsSingleSourceModeInterface $isSingleSourceMode
IsSingleSourceModeInterface $isSingleSourceMode,
LocatorInterface $locator,
IsSourceItemsAllowedForProductTypeInterface $isSourceItemsAllowedForProductType
) {
$this->arrayManager = $arrayManager;
$this->isSingleSourceMode = $isSingleSourceMode;
$this->locator = $locator;
$this->isSourceItemsAllowedForProductType = $isSourceItemsAllowedForProductType;
}

/**
Expand All @@ -58,6 +76,12 @@ public function modifyMeta(array $meta)
return $meta;
}

$product = $this->locator->getProduct();

if ($this->isSourceItemsAllowedForProductType->execute($product->getTypeId()) === false) {
return $meta;
}

if ($this->isSingleSourceMode->execute() === true) {
$meta = $this->arrayManager->merge(
$stockStatusPath . '/arguments/data/config',
Expand Down

0 comments on commit 0758ae1

Please sign in to comment.