|
| 1 | +diff --git a/vendor/magento/module-bundle/Ui/DataProvider/Product/BundleDataProvider.php b/vendor/magento/module-bundle/Ui/DataProvider/Product/BundleDataProvider.php |
| 2 | +index 5f1ffc3c268..827082dc774 100644 |
| 3 | +--- a/vendor/magento/module-bundle/Ui/DataProvider/Product/BundleDataProvider.php |
| 4 | ++++ b/vendor/magento/module-bundle/Ui/DataProvider/Product/BundleDataProvider.php |
| 5 | +@@ -8,6 +8,9 @@ namespace Magento\Bundle\Ui\DataProvider\Product; |
| 6 | + use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; |
| 7 | + use Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider; |
| 8 | + use Magento\Bundle\Helper\Data; |
| 9 | ++use Magento\Framework\App\ObjectManager; |
| 10 | ++use Magento\Ui\DataProvider\Modifier\ModifierInterface; |
| 11 | ++use Magento\Ui\DataProvider\Modifier\PoolInterface; |
| 12 | + |
| 13 | + class BundleDataProvider extends ProductDataProvider |
| 14 | + { |
| 15 | +@@ -16,6 +19,11 @@ class BundleDataProvider extends ProductDataProvider |
| 16 | + */ |
| 17 | + protected $dataHelper; |
| 18 | + |
| 19 | ++ /** |
| 20 | ++ * @var PoolInterface |
| 21 | ++ */ |
| 22 | ++ private $modifiersPool; |
| 23 | ++ |
| 24 | + /** |
| 25 | + * Construct |
| 26 | + * |
| 27 | +@@ -24,10 +32,12 @@ class BundleDataProvider extends ProductDataProvider |
| 28 | + * @param string $requestFieldName |
| 29 | + * @param CollectionFactory $collectionFactory |
| 30 | + * @param Data $dataHelper |
| 31 | +- * @param \Magento\Ui\DataProvider\AddFieldToCollectionInterface[] $addFieldStrategies |
| 32 | +- * @param \Magento\Ui\DataProvider\AddFilterToCollectionInterface[] $addFilterStrategies |
| 33 | + * @param array $meta |
| 34 | + * @param array $data |
| 35 | ++ * @param \Magento\Ui\DataProvider\AddFieldToCollectionInterface[] $addFieldStrategies |
| 36 | ++ * @param \Magento\Ui\DataProvider\AddFilterToCollectionInterface[] $addFilterStrategies |
| 37 | ++ * @param PoolInterface|null $modifiersPool |
| 38 | ++ * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
| 39 | + */ |
| 40 | + public function __construct( |
| 41 | + $name, |
| 42 | +@@ -38,7 +48,8 @@ class BundleDataProvider extends ProductDataProvider |
| 43 | + array $meta = [], |
| 44 | + array $data = [], |
| 45 | + array $addFieldStrategies = [], |
| 46 | +- array $addFilterStrategies = [] |
| 47 | ++ array $addFilterStrategies = [], |
| 48 | ++ PoolInterface $modifiersPool = null |
| 49 | + ) { |
| 50 | + parent::__construct( |
| 51 | + $name, |
| 52 | +@@ -52,6 +63,7 @@ class BundleDataProvider extends ProductDataProvider |
| 53 | + ); |
| 54 | + |
| 55 | + $this->dataHelper = $dataHelper; |
| 56 | ++ $this->modifiersPool = $modifiersPool ?: ObjectManager::getInstance()->get(PoolInterface::class); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | +@@ -72,11 +84,34 @@ class BundleDataProvider extends ProductDataProvider |
| 61 | + ); |
| 62 | + $this->getCollection()->load(); |
| 63 | + } |
| 64 | ++ |
| 65 | + $items = $this->getCollection()->toArray(); |
| 66 | + |
| 67 | +- return [ |
| 68 | ++ $data = [ |
| 69 | + 'totalRecords' => $this->getCollection()->getSize(), |
| 70 | + 'items' => array_values($items), |
| 71 | + ]; |
| 72 | ++ |
| 73 | ++ /** @var ModifierInterface $modifier */ |
| 74 | ++ foreach ($this->modifiersPool->getModifiersInstances() as $modifier) { |
| 75 | ++ $data = $modifier->modifyData($data); |
| 76 | ++ } |
| 77 | ++ |
| 78 | ++ return $data; |
| 79 | ++ } |
| 80 | ++ |
| 81 | ++ /** |
| 82 | ++ * @inheritdoc |
| 83 | ++ */ |
| 84 | ++ public function getMeta() |
| 85 | ++ { |
| 86 | ++ $meta = parent::getMeta(); |
| 87 | ++ |
| 88 | ++ /** @var ModifierInterface $modifier */ |
| 89 | ++ foreach ($this->modifiersPool->getModifiersInstances() as $modifier) { |
| 90 | ++ $meta = $modifier->modifyMeta($meta); |
| 91 | ++ } |
| 92 | ++ |
| 93 | ++ return $meta; |
| 94 | + } |
| 95 | + } |
| 96 | +diff --git a/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/AddSelectionQtyTypeToProductsData.php b/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/AddSelectionQtyTypeToProductsData.php |
| 97 | +new file mode 100644 |
| 98 | +index 00000000000..387b82a94c1 |
| 99 | +--- /dev/null |
| 100 | ++++ b/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/AddSelectionQtyTypeToProductsData.php |
| 101 | +@@ -0,0 +1,76 @@ |
| 102 | ++<?php |
| 103 | ++ |
| 104 | ++/** |
| 105 | ++ * Copyright © Magento, Inc. All rights reserved. |
| 106 | ++ * See COPYING.txt for license details. |
| 107 | ++ */ |
| 108 | ++declare(strict_types=1); |
| 109 | ++ |
| 110 | ++namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier; |
| 111 | ++ |
| 112 | ++use Magento\Framework\App\ObjectManager; |
| 113 | ++use Magento\Framework\Exception\NoSuchEntityException; |
| 114 | ++use Magento\Ui\DataProvider\Modifier\ModifierInterface; |
| 115 | ++use Magento\CatalogInventory\Model\StockRegistryPreloader; |
| 116 | ++ |
| 117 | ++/** |
| 118 | ++ * Affects Qty field for newly added selection |
| 119 | ++ */ |
| 120 | ++class AddSelectionQtyTypeToProductsData implements ModifierInterface |
| 121 | ++{ |
| 122 | ++ /** |
| 123 | ++ * @var StockRegistryPreloader |
| 124 | ++ */ |
| 125 | ++ private StockRegistryPreloader $stockRegistryPreloader; |
| 126 | ++ |
| 127 | ++ /** |
| 128 | ++ * Initializes dependencies |
| 129 | ++ * |
| 130 | ++ * @param StockRegistryPreloader $stockRegistryPreloader |
| 131 | ++ */ |
| 132 | ++ public function __construct(StockRegistryPreloader $stockRegistryPreloader) |
| 133 | ++ { |
| 134 | ++ $this->stockRegistryPreloader = $stockRegistryPreloader; |
| 135 | ++ } |
| 136 | ++ |
| 137 | ++ /** |
| 138 | ++ * Modify Meta |
| 139 | ++ * |
| 140 | ++ * @param array $meta |
| 141 | ++ * @return array |
| 142 | ++ */ |
| 143 | ++ public function modifyMeta(array $meta) |
| 144 | ++ { |
| 145 | ++ return $meta; |
| 146 | ++ } |
| 147 | ++ |
| 148 | ++ /** |
| 149 | ++ * Modify Data - checks if new selection can have decimal quantity |
| 150 | ++ * |
| 151 | ++ * @param array $data |
| 152 | ++ * @return array |
| 153 | ++ * @throws NoSuchEntityException |
| 154 | ++ */ |
| 155 | ++ public function modifyData(array $data): array |
| 156 | ++ { |
| 157 | ++ $productIds = array_column($data['items'], 'entity_id'); |
| 158 | ++ |
| 159 | ++ $stockItems = []; |
| 160 | ++ if ($productIds) { |
| 161 | ++ $stockItems = $this->stockRegistryPreloader->preloadStockItems($productIds); |
| 162 | ++ } |
| 163 | ++ |
| 164 | ++ $isQtyDecimals = []; |
| 165 | ++ foreach ($stockItems as $stockItem) { |
| 166 | ++ $isQtyDecimals[$stockItem->getProductId()] = $stockItem->getIsQtyDecimal(); |
| 167 | ++ } |
| 168 | ++ |
| 169 | ++ foreach ($data['items'] as &$item) { |
| 170 | ++ if (isset($isQtyDecimals[$item['entity_id']])) { |
| 171 | ++ $item['selection_qty_is_integer'] = !$isQtyDecimals[$item['entity_id']]; |
| 172 | ++ } |
| 173 | ++ } |
| 174 | ++ |
| 175 | ++ return $data; |
| 176 | ++ } |
| 177 | ++} |
| 178 | +diff --git a/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php b/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php |
| 179 | +index 4e2f17fa46d..7b1c254eae6 100644 |
| 180 | +--- a/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php |
| 181 | ++++ b/vendor/magento/module-bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php |
| 182 | +@@ -403,6 +403,7 @@ class BundlePanel extends AbstractModifier |
| 183 | + 'selection_price_type' => '', |
| 184 | + 'selection_price_value' => '', |
| 185 | + 'selection_qty' => '', |
| 186 | ++ 'selection_qty_is_integer'=> 'selection_qty_is_integer', |
| 187 | + ], |
| 188 | + 'links' => [ |
| 189 | + 'insertData' => '${ $.provider }:${ $.dataProvider }', |
| 190 | +diff --git a/vendor/magento/module-bundle/etc/adminhtml/di.xml b/vendor/magento/module-bundle/etc/adminhtml/di.xml |
| 191 | +index f173bb26fcc..4f3069dee65 100644 |
| 192 | +--- a/vendor/magento/module-bundle/etc/adminhtml/di.xml |
| 193 | ++++ b/vendor/magento/module-bundle/etc/adminhtml/di.xml |
| 194 | +@@ -76,4 +76,21 @@ |
| 195 | + </argument> |
| 196 | + </arguments> |
| 197 | + </type> |
| 198 | ++ <virtualType name="Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\ModifiersPool" type="Magento\Ui\DataProvider\Modifier\Pool"> |
| 199 | ++ <arguments> |
| 200 | ++ <argument name="modifiers" xsi:type="array"> |
| 201 | ++ <item name="add_selection_qty_type_to_products_data" xsi:type="array"> |
| 202 | ++ <item name="class" xsi:type="string">Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\AddSelectionQtyTypeToProductsData</item> |
| 203 | ++ <item name="sortOrder" xsi:type="number">200</item> |
| 204 | ++ </item> |
| 205 | ++ </argument> |
| 206 | ++ </arguments> |
| 207 | ++ </virtualType> |
| 208 | ++ <type name="Magento\Bundle\Ui\DataProvider\Product\BundleDataProvider"> |
| 209 | ++ <arguments> |
| 210 | ++ <argument name="modifiersPool" xsi:type="object"> |
| 211 | ++ Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\ModifiersPool |
| 212 | ++ </argument> |
| 213 | ++ </arguments> |
| 214 | ++ </type> |
| 215 | + </config> |
0 commit comments