Skip to content

Commit 12e36c5

Browse files
author
Bohdan Korablov
committed
Merge branch 'MAGETWO-48913' of https://github.corp.magento.com/magento-tango/magento2ce into MAGETWO-48913
2 parents 44115ac + 44a1d12 commit 12e36c5

File tree

21 files changed

+468
-195
lines changed

21 files changed

+468
-195
lines changed

app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@ protected function setUp()
5252
->getMockForAbstractClass();
5353
$this->collectionMock = $this->getMockBuilder(Collection::class)
5454
->disableOriginalConstructor()
55-
->setMethods(['toArray', 'isLoaded', 'addAttributeToFilter', 'load', 'getSize'])
56-
->getMock();
55+
->setMethods(
56+
[
57+
'toArray',
58+
'isLoaded',
59+
'addAttributeToFilter',
60+
'load',
61+
'getSize',
62+
'addFilterByRequiredOptions',
63+
'addStoreFilter'
64+
]
65+
)->getMock();
5766
$this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
5867
->disableOriginalConstructor()
5968
->setMethods(['create'])
@@ -100,6 +109,11 @@ public function testGetData()
100109
$this->collectionMock->expects($this->once())
101110
->method('addAttributeToFilter')
102111
->with('type_id', [self::ALLOWED_TYPE]);
112+
$this->collectionMock->expects($this->once())
113+
->method('addFilterByRequiredOptions');
114+
$this->collectionMock->expects($this->once())
115+
->method('addStoreFilter')
116+
->with(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
103117
$this->collectionMock->expects($this->once())
104118
->method('toArray')
105119
->willReturn($items);

app/code/Magento/Bundle/Ui/DataProvider/Product/BundleDataProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function getData()
6666
'type_id',
6767
$this->dataHelper->getAllowedSelectionTypes()
6868
);
69+
$this->getCollection()->addFilterByRequiredOptions();
70+
$this->getCollection()->addStoreFilter(
71+
\Magento\Store\Model\Store::DEFAULT_STORE_ID
72+
);
6973
$this->getCollection()->load();
7074
}
7175
$items = $this->getCollection()->toArray();

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ protected function getBundleSelections()
577577
'dataScope' => 'selection_qty',
578578
'value' => '1',
579579
'sortOrder' => 100,
580+
'validation' => [
581+
'validate-number' => true,
582+
'validate-digits' => true,
583+
],
580584
],
581585
],
582586
],

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WysiwygTest.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Related/AbstractDataProviderTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ public function testGetCollection()
9494
$this->productLinkRepositoryMock->expects($this->once())
9595
->method('getList')
9696
->willReturn([]);
97-
$this->requestMock->expects($this->once())
97+
$this->requestMock->expects($this->exactly(2))
9898
->method('getParam')
99-
->with('current_product_id')
10099
->willReturn(1);
101100

102101
$this->assertInstanceOf(Collection::class, $this->getModel()->getCollection());

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
use Magento\Framework\App\RequestInterface;
2222
use Magento\Framework\Filter\Translit;
2323
use Magento\Store\Model\StoreManagerInterface;
24-
use Magento\Ui\Component\Form\Element\Checkbox;
2524
use Magento\Ui\Component\Form\Field;
2625
use Magento\Ui\Component\Form\Fieldset;
2726
use Magento\Ui\DataProvider\EavValidationRules;
2827
use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper;
2928
use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper;
29+
use Magento\Ui\Component\Form\Element\Wysiwyg as WysiwygElement;
3030

3131
/**
3232
* Class Eav
@@ -133,6 +133,11 @@ class Eav extends AbstractModifier
133133
*/
134134
private $translitFilter;
135135

136+
/**
137+
* @var array
138+
*/
139+
private $bannedInputTypes = ['media_image'];
140+
136141
/**
137142
* Initialize dependencies
138143
*
@@ -218,14 +223,19 @@ public function modifyMeta(array $meta)
218223
protected function getAttributesMeta(array $attributes, $groupCode)
219224
{
220225
$meta = [];
226+
221227
foreach ($attributes as $sortKey => $attribute) {
228+
if (in_array($attribute->getFrontendInput(), $this->bannedInputTypes)) {
229+
continue;
230+
}
231+
222232
$code = $attribute->getAttributeCode();
223233
$canDisplayService = $this->canDisplayUseDefault($attribute);
224234
$usedDefault = $this->usedDefault($attribute);
225235

226236
$child = $this->setupMetaProperties($attribute);
227237

228-
$meta['container_' . $code] = [
238+
$meta[static::CONTAINER_PREFIX . $code] = [
229239
'arguments' => [
230240
'data' => [
231241
'config' => [
@@ -240,6 +250,11 @@ protected function getAttributesMeta(array $attributes, $groupCode)
240250
],
241251
];
242252

253+
if ($attribute->getIsWysiwygEnabled()) {
254+
$meta[static::CONTAINER_PREFIX . $code]['arguments']['data']['config']['component'] =
255+
'Magento_Ui/js/form/components/group';
256+
}
257+
243258
$child['arguments']['data']['config']['code'] = $code;
244259
$child['arguments']['data']['config']['source'] = $groupCode;
245260
$child['arguments']['data']['config']['scopeLabel'] = $this->getScopeLabel($attribute);
@@ -456,6 +471,27 @@ protected function setupMetaProperties(ProductAttributeInterface $attribute)
456471
$meta['arguments']['data']['config']['options'] = $attributeModel->getSource()->getAllOptions();
457472
}
458473

474+
$meta = $this->addWysiwyg($attribute, $meta);
475+
476+
return $meta;
477+
}
478+
479+
/**
480+
* Add wysiwyg properties
481+
*
482+
* @param ProductAttributeInterface $attribute
483+
* @param array $meta
484+
* @return array
485+
*/
486+
private function addWysiwyg(ProductAttributeInterface $attribute, array $meta)
487+
{
488+
if (!$attribute->getIsWysiwygEnabled()) {
489+
return $meta;
490+
}
491+
492+
$meta['arguments']['data']['config']['formElement'] = WysiwygElement::NAME;
493+
$meta['arguments']['data']['config']['wysiwyg'] = true;
494+
459495
return $meta;
460496
}
461497

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
99
use Magento\Catalog\Api\ProductRepositoryInterface;
1010
use Magento\Catalog\Model\Locator\LocatorInterface;
11+
use Magento\Eav\Api\AttributeSetRepositoryInterface;
1112
use Magento\Framework\Phrase;
1213
use Magento\Framework\UrlInterface;
1314
use Magento\Ui\Component\DynamicRows;
@@ -18,6 +19,7 @@
1819
use Magento\Ui\Component\Form\Fieldset;
1920
use Magento\Ui\Component\Modal;
2021
use Magento\Catalog\Helper\Image as ImageHelper;
22+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
2123

2224
/**
2325
* Class Related
@@ -66,25 +68,41 @@ class Related extends AbstractModifier
6668
*/
6769
protected $imageHelper;
6870

71+
/**
72+
* @var Status
73+
*/
74+
protected $status;
75+
76+
/**
77+
* @var AttributeSetRepositoryInterface
78+
*/
79+
protected $attributeSetRepository;
80+
6981
/**
7082
* @param LocatorInterface $locator
7183
* @param UrlInterface $urlBuilder
7284
* @param ProductLinkRepositoryInterface $productLinkRepository
7385
* @param ProductRepositoryInterface $productRepository
7486
* @param ImageHelper $imageHelper
87+
* @param Status $status
88+
* @param AttributeSetRepositoryInterface $attributeSetRepository
7589
*/
7690
public function __construct(
7791
LocatorInterface $locator,
7892
UrlInterface $urlBuilder,
7993
ProductLinkRepositoryInterface $productLinkRepository,
8094
ProductRepositoryInterface $productRepository,
81-
ImageHelper $imageHelper
95+
ImageHelper $imageHelper,
96+
Status $status,
97+
AttributeSetRepositoryInterface $attributeSetRepository
8298
) {
8399
$this->locator = $locator;
84100
$this->urlBuilder = $urlBuilder;
85101
$this->productLinkRepository = $productLinkRepository;
86102
$this->productRepository = $productRepository;
87103
$this->imageHelper = $imageHelper;
104+
$this->status = $status;
105+
$this->attributeSetRepository = $attributeSetRepository;
88106
}
89107

90108
/**
@@ -146,11 +164,19 @@ public function modifyData(array $data)
146164
}
147165

148166
/** @var \Magento\Catalog\Model\Product $linkedProduct */
149-
$linkedProduct = $this->productRepository->get($linkItem->getLinkedProductSku());
167+
$linkedProduct = $this->productRepository->get(
168+
$linkItem->getLinkedProductSku(),
169+
false,
170+
$this->locator->getStore()->getId()
171+
);
150172
$data[$productId]['links'][$dataScope][] = [
151173
'id' => $linkedProduct->getId(),
152174
'thumbnail' => $this->imageHelper->init($linkedProduct, 'product_listing_thumbnail')->getUrl(),
153175
'name' => $linkedProduct->getName(),
176+
'status' => $this->status->getOptionText($linkedProduct->getStatus()),
177+
'attribute_set' => $this->attributeSetRepository
178+
->get($linkedProduct->getAttributeSetId())
179+
->getAttributeSetName(),
154180
'sku' => $linkItem->getLinkedProductSku(),
155181
'price' => $linkedProduct->getPrice(),
156182
'position' => $linkItem->getPosition(),
@@ -159,6 +185,7 @@ public function modifyData(array $data)
159185
}
160186

161187
$data[$productId][self::DATA_SOURCE_DEFAULT]['current_product_id'] = $productId;
188+
$data[$productId][self::DATA_SOURCE_DEFAULT]['current_store_id'] = $this->locator->getStore()->getId();
162189

163190
return $data;
164191
}
@@ -412,10 +439,12 @@ protected function getGenericModal(Phrase $title, $scope)
412439
'behaviourType' => 'simple',
413440
'externalFilterMode' => true,
414441
'imports' => [
415-
'productId' => '${ $.provider }:data.product.current_product_id'
442+
'productId' => '${ $.provider }:data.product.current_product_id',
443+
'storeId' => '${ $.provider }:data.product.current_store_id',
416444
],
417445
'exports' => [
418-
'productId' => '${ $.externalProvider }:params.current_product_id'
446+
'productId' => '${ $.externalProvider }:params.current_product_id',
447+
'storeId' => '${ $.externalProvider }:params.current_store_id',
419448
]
420449
],
421450
],
@@ -458,6 +487,8 @@ protected function getGrid($scope)
458487
'map' => [
459488
'id' => 'entity_id',
460489
'name' => 'name',
490+
'status' => 'status_text',
491+
'attribute_set' => 'attribute_set_text',
461492
'sku' => 'sku',
462493
'price' => 'price',
463494
'thumbnail' => 'thumbnail_src',
@@ -501,8 +532,10 @@ protected function getGrid($scope)
501532
],
502533
],
503534
'name' => $this->getTextColumn('name', false, 'Name', 20),
504-
'sku' => $this->getTextColumn('sku', true, 'SKU', 30),
505-
'price' => $this->getTextColumn('price', true, 'Price', 40),
535+
'status' => $this->getTextColumn('status', true, 'Status', 30),
536+
'attribute_set' => $this->getTextColumn('attribute_set', false, 'Attribute Set', 40),
537+
'sku' => $this->getTextColumn('sku', true, 'SKU', 50),
538+
'price' => $this->getTextColumn('price', true, 'Price', 60),
506539
'actionDelete' => [
507540
'arguments' => [
508541
'data' => [
@@ -511,7 +544,7 @@ protected function getGrid($scope)
511544
'componentType' => 'actionDelete',
512545
'dataType' => Text::NAME,
513546
'label' => __('Actions'),
514-
'sortOrder' => 50,
547+
'sortOrder' => 70,
515548
'fit' => true,
516549
],
517550
],
@@ -525,7 +558,7 @@ protected function getGrid($scope)
525558
'formElement' => Input::NAME,
526559
'componentType' => Field::NAME,
527560
'dataScope' => 'position',
528-
'sortOrder' => 60,
561+
'sortOrder' => 80,
529562
'visible' => false,
530563
],
531564
],

0 commit comments

Comments
 (0)