diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Associated/AssociatedDataProvider.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Associated/AssociatedDataProvider.php new file mode 100644 index 0000000000000..bbf21e0c911b3 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Associated/AssociatedDataProvider.php @@ -0,0 +1,172 @@ +_configurableType = $configurableType; + $this->productFactory= $productFactory; + $this->locator = $locator; + $this->request = $request; + $this->storeRepository = $storeRepository; + $this->productRepository = $productRepository; + parent::__construct($name, $primaryFieldName, $requestFieldName, $collectionFactory, $addFieldStrategies, $addFilterStrategies, $meta, $data); + } + + /** + * @return Collection|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection + */ + public function getCollection() + { + /** @var Collection $collection */ + $collection = parent::getCollection(); + $collection->addAttributeToSelect('status'); + + + if ($this->getStore()) { + $collection->setStore($this->getStore()); + } + + $collection->addFieldToFilter( + 'type_id', + ['in' => [ + \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, + \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, + \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE + ]] + ); + + $product = $this->_getProduct(); + foreach ((array)$this->_configurableType->getConfigurableAttributesAsArray($product) as $attribute) { + $collection->addAttributeToSelect($attribute['attribute_code']); + $collection->addAttributeToFilter($attribute['attribute_code'], array('notnull' => 1)); + } + + return $collection; + } + + /** + * Get product + * + * @return \Magento\Catalog\Model\Product + */ + private function _getProduct() + { + $product_id = (int) $this->request->getParam('id'); + return $this->productFactory->create()->load($product_id); + } + + /** + * Retrieve store + * + * @return StoreInterface|null + * @since 101.0.0 + */ + private function getStore() + { + if (null !== $this->store) { + return $this->store; + } + + if (!($storeId = $this->request->getParam('current_store_id'))) { + return null; + } + + return $this->store = $this->storeRepository->getById($storeId); + } + +} diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php index 16119dcb5c866..96aaddff6a33e 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php @@ -207,7 +207,7 @@ public function modifyMeta(array $meta) . $this->associatedListingPrefix . static::ASSOCIATED_PRODUCT_LISTING . '.product_columns.ids', 'ns' => $this->associatedListingPrefix . static::ASSOCIATED_PRODUCT_LISTING, - 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), + 'render_url' => $this->urlBuilder->getUrl('mui/index/render', ['id' => $this->locator->getProduct()->getId()]), 'realTimeLink' => true, 'behaviourType' => 'simple', 'externalFilterMode' => false, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 2a40caaabae04..d6de3c5fb352e 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -25,7 +25,7 @@ Magento_Catalog::products - + id entity_id