Skip to content

Commit 63b7c78

Browse files
committed
MAGETWO-62227: Unable to sort attributes table when trying to Add Attribute to a product
2 parents 359177f + 515b0b8 commit 63b7c78

File tree

210 files changed

+6729
-3576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+6729
-3576
lines changed

app/autoload.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,3 @@
3535
}
3636

3737
AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));
38-
39-
// Sets default autoload mappings, may be overridden in Bootstrap::create
40-
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);

app/bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
}
2929

3030
require_once __DIR__ . '/autoload.php';
31+
// Sets default autoload mappings, may be overridden in Bootstrap::create
32+
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);
33+
3134
require_once BP . '/app/functions.php';
3235

3336
/* Custom umask value may be provided in optional mage_umask file in root */

app/code/Magento/Bundle/Model/Product/Price.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Bundle\Model\Product;
87

98
use Magento\Customer\Api\GroupManagementInterface;
109
use Magento\Framework\Pricing\PriceCurrencyInterface;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
1112

1213
/**
13-
* Bundle Price Model
14-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1514
* @api
15+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1616
*/
1717
class Price extends \Magento\Catalog\Model\Product\Type\Price
1818
{
@@ -48,7 +48,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price
4848
private $serializer;
4949

5050
/**
51-
* Price constructor.
51+
* Constructor
5252
*
5353
* @param \Magento\CatalogRule\Model\ResourceModel\RuleFactory $ruleFactory
5454
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -61,6 +61,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price
6161
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
6262
* @param \Magento\Catalog\Helper\Data $catalogData
6363
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
64+
* @param ProductTierPriceExtensionFactory|null $tierPriceExtensionFactory
6465
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6566
*/
6667
public function __construct(
@@ -74,10 +75,11 @@ public function __construct(
7475
\Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory,
7576
\Magento\Framework\App\Config\ScopeConfigInterface $config,
7677
\Magento\Catalog\Helper\Data $catalogData,
77-
\Magento\Framework\Serialize\Serializer\Json $serializer = null
78+
\Magento\Framework\Serialize\Serializer\Json $serializer = null,
79+
ProductTierPriceExtensionFactory $tierPriceExtensionFactory = null
7880
) {
7981
$this->_catalogData = $catalogData;
80-
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
82+
$this->serializer = $serializer ?: ObjectManager::getInstance()
8183
->get(\Magento\Framework\Serialize\Serializer\Json::class);
8284
parent::__construct(
8385
$ruleFactory,
@@ -88,7 +90,8 @@ public function __construct(
8890
$priceCurrency,
8991
$groupManagement,
9092
$tierPriceFactory,
91-
$config
93+
$config,
94+
$tierPriceExtensionFactory
9295
);
9396
}
9497

app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
namespace Magento\Bundle\Test\Unit\Model\Product;
77

88
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
910

1011
/**
11-
* Test for Model ProductPrice.
12-
*
1312
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1413
*/
1514
class PriceTest extends \PHPUnit_Framework_TestCase
@@ -114,7 +113,10 @@ function ($value) {
114113
return json_decode($value, true);
115114
}
116115
);
117-
116+
$tierPriceExtensionFactoryMock = $this->getMockBuilder(ProductTierPriceExtensionFactory::class)
117+
->setMethods(['create'])
118+
->disableOriginalConstructor()
119+
->getMock();
118120
$objectManagerHelper = new ObjectManagerHelper($this);
119121
$this->model = $objectManagerHelper->getObject(
120122
\Magento\Bundle\Model\Product\Price::class,
@@ -129,7 +131,8 @@ function ($value) {
129131
'tierPriceFactory' => $tpFactory,
130132
'config' => $scopeConfig,
131133
'catalogData' => $this->catalogHelperMock,
132-
'serializer' => $this->serializer
134+
'serializer' => $this->serializer,
135+
'tierPriceExtensionFactory' => $tierPriceExtensionFactoryMock
133136
]
134137
);
135138
}

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ public function getGalleryImagesJson()
122122
}
123123
if (empty($imagesItems)) {
124124
$imagesItems[] = [
125-
'thumb' => $this->getImage($this->getProduct(), 'product_thumbnail_image')->getImageUrl(),
126-
'img' => $this->getImage($this->getProduct(), 'product_base_image')->getImageUrl(),
127-
'full' => $this->getImage($this->getProduct(), 'product_page_image_large')->getImageUrl(),
125+
'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
126+
'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
127+
'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
128128
'caption' => '',
129129
'position' => '0',
130130
'isMain' => true,

app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
@@ -73,18 +72,24 @@ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Produ
7372
protected $extensionAttributesFactory;
7473

7574
/**
75+
* Constructor
76+
*
7677
* @param \Magento\Backend\App\Action\Context $context
7778
* @param Builder $productBuilder
7879
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
80+
* @param \Magento\Eav\Api\Data\AttributeGroupInterfaceFactory|null $attributeGroupFactory
7981
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8082
*/
8183
public function __construct(
8284
\Magento\Backend\App\Action\Context $context,
8385
\Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder,
84-
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
86+
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
87+
\Magento\Eav\Api\Data\AttributeGroupInterfaceFactory $attributeGroupFactory = null
8588
) {
8689
parent::__construct($context, $productBuilder);
8790
$this->resultJsonFactory = $resultJsonFactory;
91+
$this->attributeGroupFactory = $attributeGroupFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
92+
->get(\Magento\Eav\Api\Data\AttributeGroupInterfaceFactory::class);
8893
}
8994

9095
/**
@@ -125,7 +130,7 @@ public function execute()
125130
$attributeGroup = reset($attributeGroupItems);
126131
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
127132
/** @var AttributeGroupInterface $attributeGroup */
128-
$attributeGroup = $this->getAttributeGroupFactory()->create();
133+
$attributeGroup = $this->attributeGroupFactory->create();
129134
}
130135

131136
$extensionAttributes = $attributeGroup->getExtensionAttributes()
@@ -221,18 +226,6 @@ private function getAttributeGroupRepository()
221226
return $this->attributeGroupRepository;
222227
}
223228

224-
/**
225-
* @return AttributeGroupInterfaceFactory
226-
*/
227-
private function getAttributeGroupFactory()
228-
{
229-
if (null === $this->attributeGroupFactory) {
230-
$this->attributeGroupFactory = \Magento\Framework\App\ObjectManager::getInstance()
231-
->get(\Magento\Eav\Api\Data\AttributeGroupInterfaceFactory::class);
232-
}
233-
return $this->attributeGroupFactory;
234-
}
235-
236229
/**
237230
* @return SearchCriteriaBuilder
238231
*/

app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
@@ -41,21 +40,27 @@ class Builder
4140
protected $storeFactory;
4241

4342
/**
43+
* Constructor
44+
*
4445
* @param ProductFactory $productFactory
4546
* @param Logger $logger
4647
* @param Registry $registry
4748
* @param WysiwygModel\Config $wysiwygConfig
49+
* @param StoreFactory|null $storeFactory
4850
*/
4951
public function __construct(
5052
ProductFactory $productFactory,
5153
Logger $logger,
5254
Registry $registry,
53-
WysiwygModel\Config $wysiwygConfig
55+
WysiwygModel\Config $wysiwygConfig,
56+
StoreFactory $storeFactory = null
5457
) {
5558
$this->productFactory = $productFactory;
5659
$this->logger = $logger;
5760
$this->registry = $registry;
5861
$this->wysiwygConfig = $wysiwygConfig;
62+
$this->storeFactory = $storeFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
63+
->get(\Magento\Store\Model\StoreFactory::class);
5964
}
6065

6166
/**
@@ -70,7 +75,7 @@ public function build(RequestInterface $request)
7075
/** @var $product \Magento\Catalog\Model\Product */
7176
$product = $this->productFactory->create();
7277
$product->setStoreId($request->getParam('store', 0));
73-
$store = $this->getStoreFactory()->create();
78+
$store = $this->storeFactory->create();
7479
$store->load($request->getParam('store', 0));
7580

7681
$typeId = $request->getParam('type');
@@ -99,16 +104,4 @@ public function build(RequestInterface $request)
99104
$this->wysiwygConfig->setStoreId($request->getParam('store'));
100105
return $product;
101106
}
102-
103-
/**
104-
* @return StoreFactory
105-
*/
106-
private function getStoreFactory()
107-
{
108-
if (null === $this->storeFactory) {
109-
$this->storeFactory = \Magento\Framework\App\ObjectManager::getInstance()
110-
->get(\Magento\Store\Model\StoreFactory::class);
111-
}
112-
return $this->storeFactory;
113-
}
114107
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Magento\Framework\App\ObjectManager;
1414

1515
/**
16-
* Class Helper
1716
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1817
*/
1918
class Helper
@@ -40,7 +39,6 @@ class Helper
4039

4140
/**
4241
* @var \Magento\Framework\Stdlib\DateTime\Filter\Date
43-
*
4442
* @deprecated
4543
*/
4644
protected $dateFilter;
@@ -81,14 +79,19 @@ class Helper
8179
private $linkTypeProvider;
8280

8381
/**
84-
* Helper constructor.
82+
* Constructor
83+
*
8584
* @param \Magento\Framework\App\RequestInterface $request
8685
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
8786
* @param StockDataFilter $stockFilter
8887
* @param ProductLinks $productLinks
8988
* @param \Magento\Backend\Helper\Js $jsHelper
9089
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
91-
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
90+
* @param \Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory|null $customOptionFactory
91+
* @param \Magento\Catalog\Api\Data\ProductLinkInterfaceFactory|null $productLinkFactory
92+
* @param \Magento\Catalog\Api\ProductRepositoryInterface|null $productRepository
93+
* @param \Magento\Catalog\Model\Product\LinkTypeProvider|null $linkTypeProvider
94+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9295
*/
9396
public function __construct(
9497
\Magento\Framework\App\RequestInterface $request,
@@ -97,6 +100,9 @@ public function __construct(
97100
\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks,
98101
\Magento\Backend\Helper\Js $jsHelper,
99102
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
103+
\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory $customOptionFactory = null,
104+
\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory $productLinkFactory = null,
105+
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository = null,
100106
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider = null
101107
) {
102108
$this->request = $request;
@@ -105,6 +111,12 @@ public function __construct(
105111
$this->productLinks = $productLinks;
106112
$this->jsHelper = $jsHelper;
107113
$this->dateFilter = $dateFilter;
114+
$this->customOptionFactory = $customOptionFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
115+
->get(\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory::class);
116+
$this->productLinkFactory = $productLinkFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
117+
->get(\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory::class);
118+
$this->productRepository = $productRepository ?: \Magento\Framework\App\ObjectManager::getInstance()
119+
->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
108120
$this->linkTypeProvider = $linkTypeProvider ?: \Magento\Framework\App\ObjectManager::getInstance()
109121
->get(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
110122
}
@@ -211,7 +223,7 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
211223
return empty($valueData['is_delete']);
212224
});
213225
}
214-
$customOption = $this->getCustomOptionFactory()->create(['data' => $customOptionData]);
226+
$customOption = $this->customOptionFactory->create(['data' => $customOptionData]);
215227
$customOption->setProductSku($product->getSku());
216228
$customOptions[] = $customOption;
217229
}
@@ -272,8 +284,8 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)
272284
continue;
273285
}
274286

275-
$linkProduct = $this->getProductRepository()->getById($linkData['id']);
276-
$link = $this->getProductLinkFactory()->create();
287+
$linkProduct = $this->productRepository->getById($linkData['id']);
288+
$link = $this->productLinkFactory->create();
277289
$link->setSku($product->getSku())
278290
->setLinkedProductSku($linkProduct->getSku())
279291
->setLinkType($linkType)
@@ -288,10 +300,10 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)
288300

289301
/**
290302
* Internal normalization
291-
* TODO: Remove this method
292303
*
293304
* @param array $productData
294305
* @return array
306+
* @todo Remove this method
295307
*/
296308
protected function normalize(array $productData)
297309
{
@@ -372,44 +384,8 @@ private function overwriteValue($optionId, $option, $overwriteOptions)
372384
}
373385

374386
/**
375-
* @return CustomOptionFactory
376-
*/
377-
private function getCustomOptionFactory()
378-
{
379-
if (null === $this->customOptionFactory) {
380-
$this->customOptionFactory = \Magento\Framework\App\ObjectManager::getInstance()
381-
->get(\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory::class);
382-
}
383-
return $this->customOptionFactory;
384-
}
385-
386-
/**
387-
* @return ProductLinkFactory
388-
*/
389-
private function getProductLinkFactory()
390-
{
391-
if (null === $this->productLinkFactory) {
392-
$this->productLinkFactory = \Magento\Framework\App\ObjectManager::getInstance()
393-
->get(\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory::class);
394-
}
395-
return $this->productLinkFactory;
396-
}
397-
398-
/**
399-
* @return ProductRepository
400-
*/
401-
private function getProductRepository()
402-
{
403-
if (null === $this->productRepository) {
404-
$this->productRepository = \Magento\Framework\App\ObjectManager::getInstance()
405-
->get(\Magento\Catalog\Api\ProductRepositoryInterface\Proxy::class);
406-
}
407-
return $this->productRepository;
408-
}
409-
410-
/**
411-
* @deprecated
412387
* @return LinkResolver
388+
* @deprecated
413389
*/
414390
private function getLinkResolver()
415391
{
@@ -421,7 +397,6 @@ private function getLinkResolver()
421397

422398
/**
423399
* @return \Magento\Framework\Stdlib\DateTime\Filter\DateTime
424-
*
425400
* @deprecated
426401
*/
427402
private function getDateTimeFilter()

0 commit comments

Comments
 (0)