Skip to content

Commit 14ee44f

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-43020-Implement-Authorization-For-SOAP-And-REST-Schemas
2 parents c01a56e + f6b6b4b commit 14ee44f

File tree

105 files changed

+3367
-1245
lines changed

Some content is hidden

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

105 files changed

+3367
-1245
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function render(\Magento\Framework\DataObject $row)
3030
$truncateLength = $this->getColumn()->getTruncate();
3131
}
3232
$text = $this->filterManager->truncate(parent::_getValue($row), ['length' => $truncateLength]);
33-
if ($this->getColumn()->getEscape()) {
33+
if (!$this->getColumn()->hasEscape() || $this->getColumn()->getEscape()) {
3434
$text = $this->escapeHtml($text);
3535
}
3636
if ($this->getColumn()->getNl2br()) {

app/code/Magento/Catalog/Model/CategoryRepository.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Exception\CouldNotSaveException;
1111
use Magento\Framework\Exception\NoSuchEntityException;
1212
use Magento\Framework\Exception\StateException;
13+
use Magento\Catalog\Api\Data\CategoryInterface;
1314

1415
class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInterface
1516
{
@@ -33,6 +34,11 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter
3334
*/
3435
protected $categoryResource;
3536

37+
/**
38+
* @var \Magento\Framework\Model\Entity\MetadataPool
39+
*/
40+
protected $metadataPool;
41+
3642
/**
3743
* List of fields that can used config values in case when value does not defined directly
3844
*
@@ -44,15 +50,18 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter
4450
* @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
4551
* @param \Magento\Catalog\Model\ResourceModel\Category $categoryResource
4652
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
53+
* @param \Magento\Framework\Model\Entity\MetadataPool $metadataPool
4754
*/
4855
public function __construct(
4956
\Magento\Catalog\Model\CategoryFactory $categoryFactory,
5057
\Magento\Catalog\Model\ResourceModel\Category $categoryResource,
51-
\Magento\Store\Model\StoreManagerInterface $storeManager
58+
\Magento\Store\Model\StoreManagerInterface $storeManager,
59+
\Magento\Framework\Model\Entity\MetadataPool $metadataPool
5260
) {
5361
$this->categoryFactory = $categoryFactory;
5462
$this->categoryResource = $categoryResource;
5563
$this->storeManager = $storeManager;
64+
$this->metadataPool = $metadataPool;
5665
}
5766

5867
/**
@@ -61,10 +70,21 @@ public function __construct(
6170
public function save(\Magento\Catalog\Api\Data\CategoryInterface $category)
6271
{
6372
$existingData = $category->toFlatArray();
73+
6474
/** 'available_sort_by' should be set separately because fields of array type are destroyed by toFlatArray() */
6575
$existingData['available_sort_by'] = $category->getAvailableSortBy();
76+
6677
if ($category->getId()) {
78+
$metadata = $this->metadataPool->getMetadata(
79+
CategoryInterface::class
80+
);
81+
6782
$existingCategory = $this->get($category->getId());
83+
84+
$existingData[$metadata->getLinkField()] = $existingCategory->getData(
85+
$metadata->getLinkField()
86+
);
87+
6888
if (isset($existingData['image']) && is_array($existingData['image'])) {
6989
$existingData['image_additional_data'] = $existingData['image'];
7090
unset($existingData['image']);

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
/**
1313
* Class FlatTableBuilder
14+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1415
*/
1516
class FlatTableBuilder
1617
{
@@ -279,7 +280,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
279280
if (!empty($columnValueNames)) {
280281
$select->joinLeft(
281282
$temporaryValueTableName,
282-
"e.${linkField} = " . $temporaryValueTableName . ".${linkField}",
283+
"e.${linkField} = " . $temporaryValueTableName . ".entity_id",
283284
$columnValueNames
284285
);
285286
$allColumns = array_merge($allColumns, $columnValueNames);

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,11 @@ protected function _reindexRows($changedIds = [])
378378
if (!empty($notCompositeIds)) {
379379
$select = $this->_connection->select()->from(
380380
['l' => $this->_defaultIndexerResource->getTable('catalog_product_relation')],
381-
'parent_id'
381+
''
382382
)->join(
383383
['e' => $this->_defaultIndexerResource->getTable('catalog_product_entity')],
384-
'e.entity_id = l.parent_id',
385-
['type_id']
384+
'e.' . $this->getProductIdFieldName() . ' = l.parent_id',
385+
['e.entity_id as parent_id', 'type_id']
386386
)->where(
387387
'l.child_id IN(?)',
388388
$notCompositeIds
@@ -422,11 +422,15 @@ protected function _reindexRows($changedIds = [])
422422
*/
423423
protected function _copyRelationIndexData($parentIds, $excludeIds = null)
424424
{
425+
$linkField = $this->getProductIdFieldName();
425426
$select = $this->_connection->select()->from(
426427
$this->_defaultIndexerResource->getTable('catalog_product_relation'),
427428
['child_id']
429+
)->join(
430+
['e' => $this->_defaultIndexerResource->getTable('catalog_product_entity')],
431+
'e.' . $linkField . ' = parent_id'
428432
)->where(
429-
'parent_id IN(?)',
433+
'e.entity_id IN(?)',
430434
$parentIds
431435
);
432436
if (!empty($excludeIds)) {

app/code/Magento/Catalog/Model/ResourceModel/Attribute.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,20 @@ protected function _clearUselessAttributeValues(\Magento\Framework\Model\Abstrac
113113
/**
114114
* Delete entity
115115
*
116-
* @param \Magento\Framework\Model\AbstractModel $object
116+
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $object
117117
* @return $this
118118
* @throws \Magento\Framework\Exception\LocalizedException
119119
*/
120-
public function deleteEntity(\Magento\Framework\Model\AbstractModel $object)
120+
public function deleteEntity(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $object)
121121
{
122122
if (!$object->getEntityAttributeId()) {
123123
return $this;
124124
}
125125

126-
$select = $this->getConnection()->select()->from(
127-
$this->getTable('eav_entity_attribute')
128-
)->where(
129-
'entity_attribute_id = ?',
130-
(int)$object->getEntityAttributeId()
131-
);
132-
$result = $this->getConnection()->fetchRow($select);
133-
126+
$result = $this->getEntityAttribute($object->getEntityAttributeId());
134127
if ($result) {
135128
$attribute = $this->_eavConfig->getAttribute(
136-
\Magento\Catalog\Model\Product::ENTITY,
129+
$object->getEntityTypeId(),
137130
$result['attribute_id']
138131
);
139132

app/code/Magento/Catalog/Model/ResourceModel/Category/Tree.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
*/
66
namespace Magento\Catalog\Model\ResourceModel\Category;
77

8+
use Magento\Framework\Data\Tree\Dbp;
89
use Magento\Catalog\Api\Data\CategoryInterface;
910
use Magento\Framework\Model\Entity\MetadataPool;
1011

1112
/**
1213
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1314
*/
14-
class Tree extends \Magento\Framework\Data\Tree\Dbp
15+
class Tree extends Dbp
1516
{
1617
const ID_FIELD = 'id';
1718

@@ -124,10 +125,10 @@ public function __construct(
124125
$resource->getConnection('catalog'),
125126
$resource->getTableName('catalog_category_entity'),
126127
[
127-
\Magento\Framework\Data\Tree\Dbp::ID_FIELD => 'entity_id',
128-
\Magento\Framework\Data\Tree\Dbp::PATH_FIELD => 'path',
129-
\Magento\Framework\Data\Tree\Dbp::ORDER_FIELD => 'position',
130-
\Magento\Framework\Data\Tree\Dbp::LEVEL_FIELD => 'level'
128+
Dbp::ID_FIELD => 'entity_id',
129+
Dbp::PATH_FIELD => 'path',
130+
Dbp::ORDER_FIELD => 'position',
131+
Dbp::LEVEL_FIELD => 'level'
131132
]
132133
);
133134
$this->_eventManager = $eventManager;

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,9 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
100100
protected $_addTaxPercents = false;
101101

102102
/**
103-
* Product limitation filters
104-
* Allowed filters
105-
* store_id int;
106-
* category_id int;
107-
* category_is_anchor int;
108-
* visibility array|int;
109-
* website_ids array|int;
110-
* store_table string;
111-
* use_price_index bool; join price index table flag
112-
* customer_group_id int; required for price; customer group limitation for price
113-
* website_id int; required for price; website limitation for price
114-
*
115-
* @var array
103+
* @var \Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation
116104
*/
117-
protected $_productLimitationFilters = [];
105+
protected $_productLimitationFilters;
118106

119107
/**
120108
* Category product count select
@@ -275,6 +263,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
275263
* @param \Magento\Customer\Model\Session $customerSession
276264
* @param \Magento\Framework\Stdlib\DateTime $dateTime
277265
* @param GroupManagementInterface $groupManagement
266+
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation $productLimitation
278267
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
279268
*
280269
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -299,6 +288,7 @@ public function __construct(
299288
\Magento\Customer\Model\Session $customerSession,
300289
\Magento\Framework\Stdlib\DateTime $dateTime,
301290
GroupManagementInterface $groupManagement,
291+
\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation $productLimitation,
302292
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
303293
) {
304294
$this->moduleManager = $moduleManager;
@@ -311,6 +301,7 @@ public function __construct(
311301
$this->_resourceHelper = $resourceHelper;
312302
$this->dateTime = $dateTime;
313303
$this->_groupManagement = $groupManagement;
304+
$this->_productLimitationFilters = $productLimitation;
314305
parent::__construct(
315306
$entityFactory,
316307
$logger,
@@ -811,7 +802,7 @@ public function addWebsiteFilter($websites = null)
811802
/**
812803
* Get filters applied to collection
813804
*
814-
* @return array
805+
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation
815806
*/
816807
public function getLimitationFilters()
817808
{
@@ -1434,7 +1425,7 @@ public function setAllIdsCache($value)
14341425
*/
14351426
public function addPriceData($customerGroupId = null, $websiteId = null)
14361427
{
1437-
$this->_productLimitationFilters['use_price_index'] = true;
1428+
$this->_productLimitationFilters->setUsePriceIndex(true);
14381429

14391430
if (!isset($this->_productLimitationFilters['customer_group_id']) && is_null($customerGroupId)) {
14401431
$customerGroupId = $this->_customerSession->getCustomerGroupId();
@@ -1646,9 +1637,10 @@ public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
16461637
$storeId = $this->getStoreId();
16471638
if ($attribute == 'price' && $storeId != 0) {
16481639
$this->addPriceData();
1649-
$this->getSelect()->order("price_index.min_price {$dir}");
1650-
1651-
return $this;
1640+
if ($this->_productLimitationFilters->isUsingPriceIndex()) {
1641+
$this->getSelect()->order("price_index.min_price {$dir}");
1642+
return $this;
1643+
}
16521644
}
16531645

16541646
if ($this->isEnabledFlat()) {
@@ -1864,7 +1856,7 @@ protected function _productLimitationJoinPrice()
18641856
protected function _productLimitationPrice($joinLeft = false)
18651857
{
18661858
$filters = $this->_productLimitationFilters;
1867-
if (empty($filters['use_price_index'])) {
1859+
if (!$filters->isUsingPriceIndex()) {
18681860
return $this;
18691861
}
18701862

@@ -1923,7 +1915,7 @@ protected function _productLimitationPrice($joinLeft = false)
19231915
*/
19241916
public function applyFrontendPriceLimitations()
19251917
{
1926-
$this->_productLimitationFilters['use_price_index'] = true;
1918+
$this->_productLimitationFilters->setUsePriceIndex(true);
19271919
if (!isset($this->_productLimitationFilters['customer_group_id'])) {
19281920
$customerGroupId = $this->_customerSession->getCustomerGroupId();
19291921
$this->_productLimitationFilters['customer_group_id'] = $customerGroupId;

0 commit comments

Comments
 (0)