Skip to content

Commit 6bb5361

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-90572
2 parents d837558 + b39852c commit 6bb5361

File tree

11 files changed

+185
-70
lines changed

11 files changed

+185
-70
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a
1111
## Install Magento
1212
To install Magento, see either:
1313

14-
* [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento.
1514
* [Installation guide](http://devdocs.magento.com/guides/v2.2/install-gde/bk-install-guide.html)
1615

1716
<h2>Contributing to the Magento 2 code base</h2>
@@ -28,6 +27,19 @@ To suggest documentation improvements, click [here][4].
2827
[3]: <https://github.com/magento/magento2/issues>
2928
[4]: <http://devdocs.magento.com>
3029

30+
<h3>Community Maintainers</h3>
31+
The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions.
32+
33+
<a href="https://magento.com/magento-contributors#maintainers">
34+
<img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/maintainers.png"/>
35+
</a>
36+
37+
<h3>Top Contributors</h3>
38+
Magento team thanks for any contribution that can improve our code base, documentation or increase test coverage. We always recognize our most active members, your contributions are the foundation of the Magento open source platform.
39+
<a href="https://magento.com/magento-contributors">
40+
<img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/contributors.png"/>
41+
</a>
42+
3143
<h3>Labels applied by the Magento team</h3>
3244

3345
| Label | Description |

app/code/Magento/CatalogRule/Model/Rule.php

Lines changed: 66 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,34 @@
66
namespace Magento\CatalogRule\Model;
77

88
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\ProductFactory;
10+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
11+
use Magento\CatalogRule\Api\Data\RuleExtensionInterface;
912
use Magento\CatalogRule\Api\Data\RuleInterface;
13+
use Magento\CatalogRule\Helper\Data;
14+
use Magento\CatalogRule\Model\Data\Condition\Converter;
15+
use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor;
16+
use Magento\CatalogRule\Model\ResourceModel\Rule as RuleResourceModel;
17+
use Magento\CatalogRule\Model\Rule\Action\CollectionFactory as RuleCollectionFactory;
18+
use Magento\CatalogRule\Model\Rule\Condition\CombineFactory;
19+
use Magento\Customer\Model\Session;
1020
use Magento\Framework\Api\AttributeValueFactory;
1121
use Magento\Framework\Api\ExtensionAttributesFactory;
1222
use Magento\Framework\App\ObjectManager;
1323
use Magento\Framework\DataObject\IdentityInterface;
1424
use Magento\CatalogRule\Model\ResourceModel\Product\ConditionsToCollectionApplier;
25+
use Magento\Framework\App\Cache\TypeListInterface;
26+
use Magento\Framework\DataObject;
27+
use Magento\Framework\Data\Collection\AbstractDb;
28+
use Magento\Framework\Data\FormFactory;
29+
use Magento\Framework\Model\Context;
30+
use Magento\Framework\Model\ResourceModel\AbstractResource;
31+
use Magento\Framework\Model\ResourceModel\Iterator;
32+
use Magento\Framework\Registry;
33+
use Magento\Framework\Serialize\Serializer\Json;
34+
use Magento\Framework\Stdlib\DateTime;
35+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
36+
use Magento\Store\Model\StoreManagerInterface;
1537

1638
/**
1739
* Catalog Rule data model
@@ -148,6 +170,11 @@ class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, I
148170
*/
149171
private $websitesMap;
150172

173+
/**
174+
* @var RuleResourceModel
175+
*/
176+
private $ruleResourceModel;
177+
151178
/**
152179
* Rule constructor
153180
*
@@ -174,33 +201,34 @@ class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, I
174201
* @param AttributeValueFactory|null $customAttributeFactory
175202
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
176203
* @param ConditionsToCollectionApplier $conditionsToCollectionApplier
177-
*
204+
* @param RuleResourceModel|null $ruleResourceModel
178205
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
179206
*/
180207
public function __construct(
181-
\Magento\Framework\Model\Context $context,
182-
\Magento\Framework\Registry $registry,
183-
\Magento\Framework\Data\FormFactory $formFactory,
184-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
185-
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
186-
\Magento\Store\Model\StoreManagerInterface $storeManager,
187-
\Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory,
188-
\Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory,
189-
\Magento\Catalog\Model\ProductFactory $productFactory,
190-
\Magento\Framework\Model\ResourceModel\Iterator $resourceIterator,
191-
\Magento\Customer\Model\Session $customerSession,
192-
\Magento\CatalogRule\Helper\Data $catalogRuleData,
193-
\Magento\Framework\App\Cache\TypeListInterface $cacheTypesList,
194-
\Magento\Framework\Stdlib\DateTime $dateTime,
195-
\Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor $ruleProductProcessor,
196-
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
197-
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
208+
Context $context,
209+
Registry $registry,
210+
FormFactory $formFactory,
211+
TimezoneInterface $localeDate,
212+
CollectionFactory $productCollectionFactory,
213+
StoreManagerInterface $storeManager,
214+
CombineFactory $combineFactory,
215+
RuleCollectionFactory $actionCollectionFactory,
216+
ProductFactory $productFactory,
217+
Iterator $resourceIterator,
218+
Session $customerSession,
219+
Data $catalogRuleData,
220+
TypeListInterface $cacheTypesList,
221+
DateTime $dateTime,
222+
RuleProductProcessor $ruleProductProcessor,
223+
AbstractResource $resource = null,
224+
AbstractDb $resourceCollection = null,
198225
array $relatedCacheTypes = [],
199226
array $data = [],
200227
ExtensionAttributesFactory $extensionFactory = null,
201228
AttributeValueFactory $customAttributeFactory = null,
202-
\Magento\Framework\Serialize\Serializer\Json $serializer = null,
203-
ConditionsToCollectionApplier $conditionsToCollectionApplier = null
229+
Json $serializer = null,
230+
ConditionsToCollectionApplier $conditionsToCollectionApplier = null,
231+
RuleResourceModel $ruleResourceModel = null
204232
) {
205233
$this->_productCollectionFactory = $productCollectionFactory;
206234
$this->_storeManager = $storeManager;
@@ -214,7 +242,7 @@ public function __construct(
214242
$this->_relatedCacheTypes = $relatedCacheTypes;
215243
$this->dateTime = $dateTime;
216244
$this->_ruleProductProcessor = $ruleProductProcessor;
217-
245+
$this->ruleResourceModel = $ruleResourceModel ?: ObjectManager::getInstance()->get(RuleResourceModel::class);
218246
$this->conditionsToCollectionApplier = $conditionsToCollectionApplier
219247
?? ObjectManager::getInstance()->get(ConditionsToCollectionApplier::class);
220248

@@ -240,7 +268,7 @@ public function __construct(
240268
protected function _construct()
241269
{
242270
parent::_construct();
243-
$this->_init(\Magento\CatalogRule\Model\ResourceModel\Rule::class);
271+
$this->_init(RuleResourceModel::class);
244272
$this->setIdFieldName('rule_id');
245273
}
246274

@@ -272,7 +300,7 @@ public function getActionsInstance()
272300
public function getCustomerGroupIds()
273301
{
274302
if (!$this->hasCustomerGroupIds()) {
275-
$customerGroupIds = $this->_getResource()->getCustomerGroupIds($this->getId());
303+
$customerGroupIds = $this->ruleResourceModel->getCustomerGroupIds($this->getId());
276304
$this->setData('customer_group_ids', (array)$customerGroupIds);
277305
}
278306
return $this->_getData('customer_group_ids');
@@ -286,7 +314,7 @@ public function getCustomerGroupIds()
286314
public function getNow()
287315
{
288316
if (!$this->_now) {
289-
return (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
317+
return (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT);
290318
}
291319
return $this->_now;
292320
}
@@ -342,6 +370,9 @@ public function getMatchingProductIds()
342370
return $this->_productIds;
343371
}
344372

373+
/**
374+
* @return bool
375+
*/
345376
private function canPreMapProducts()
346377
{
347378
$conditions = $this->getConditions();
@@ -400,7 +431,7 @@ protected function _getWebsitesMap()
400431
/**
401432
* {@inheritdoc}
402433
*/
403-
public function validateData(\Magento\Framework\DataObject $dataObject)
434+
public function validateData(DataObject $dataObject)
404435
{
405436
$result = parent::validateData($dataObject);
406437
if ($result === true) {
@@ -507,7 +538,7 @@ public function calcProductPriceRule(Product $product, $price)
507538
*/
508539
protected function _getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId)
509540
{
510-
return $this->_getResource()->getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId);
541+
return $this->ruleResourceModel->getRulesFromProduct($dateTs, $websiteId, $customerGroupId, $productId);
511542
}
512543

513544
/**
@@ -553,10 +584,10 @@ protected function _invalidateCache()
553584
*/
554585
public function afterSave()
555586
{
556-
if ($this->isObjectNew()) {
557-
$this->getMatchingProductIds();
558-
if (!empty($this->_productIds) && is_array($this->_productIds)) {
559-
$this->_getResource()->addCommitCallback([$this, 'reindex']);
587+
if ($this->isObjectNew() && !$this->_ruleProductProcessor->isIndexerScheduled()) {
588+
$productIds = $this->getMatchingProductIds();
589+
if (!empty($productIds) && is_array($productIds)) {
590+
$this->ruleResourceModel->addCommitCallback([$this, 'reindex']);
560591
}
561592
} else {
562593
$this->_ruleProductProcessor->getIndexer()->invalidate();
@@ -805,7 +836,7 @@ public function getToDate()
805836
/**
806837
* {@inheritdoc}
807838
*
808-
* @return \Magento\CatalogRule\Api\Data\RuleExtensionInterface|null
839+
* @return RuleExtensionInterface|null
809840
*/
810841
public function getExtensionAttributes()
811842
{
@@ -815,10 +846,10 @@ public function getExtensionAttributes()
815846
/**
816847
* {@inheritdoc}
817848
*
818-
* @param \Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes
849+
* @param RuleExtensionInterface $extensionAttributes
819850
* @return $this
820851
*/
821-
public function setExtensionAttributes(\Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes)
852+
public function setExtensionAttributes(RuleExtensionInterface $extensionAttributes)
822853
{
823854
return $this->_setExtensionAttributes($extensionAttributes);
824855
}
@@ -830,8 +861,8 @@ public function setExtensionAttributes(\Magento\CatalogRule\Api\Data\RuleExtensi
830861
private function getRuleConditionConverter()
831862
{
832863
if (null === $this->ruleConditionConverter) {
833-
$this->ruleConditionConverter = \Magento\Framework\App\ObjectManager::getInstance()
834-
->get(\Magento\CatalogRule\Model\Data\Condition\Converter::class);
864+
$this->ruleConditionConverter = ObjectManager::getInstance()
865+
->get(Converter::class);
835866
}
836867
return $this->ruleConditionConverter;
837868
}

dev/tests/integration/testsuite/Magento/CatalogRule/Model/RuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp()
3333

3434
$this->_object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
3535
\Magento\CatalogRule\Model\Rule::class,
36-
['resource' => $resourceMock]
36+
['ruleResourceModel' => $resourceMock]
3737
);
3838
}
3939

lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ public function insertForce($table, array $bind);
495495
/**
496496
* Updates table rows with specified data based on a WHERE clause.
497497
*
498+
* The $where parameter in this instance can be a single WHERE clause or an array containing a multiple. In all
499+
* instances, a WHERE clause can be a string or an instance of {@see Zend_Db_Expr}. In the event you use an array,
500+
* you may specify the clause as the key and a value to be bound to it as the value. E.g., ['amt > ?' => $amt]
501+
*
502+
* If the $where parameter is an array of multiple clauses, they will be joined by AND, with each clause wrapped in
503+
* parenthesis. If you wish to use an OR, you must give a single clause that is an instance of {@see Zend_Db_Expr}
504+
*
498505
* @param mixed $table The table to update.
499506
* @param array $bind Column-value pairs.
500507
* @param mixed $where UPDATE WHERE clause(s).

lib/internal/Magento/Framework/View/Layout/etc/head.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<xs:attribute name="sizes" type="xs:string"/>
1919
<xs:attribute name="target" type="xs:string"/>
2020
<xs:attribute name="type" type="xs:string"/>
21+
<xs:attribute name="order" type="xs:integer"/>
2122
<xs:attribute name="src_type" type="xs:string"/>
2223
</xs:complexType>
2324

lib/internal/Magento/Framework/View/Page/Config/Generator/Head.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Head implements Layout\GeneratorInterface
4242
*/
4343
protected $assetProperties = [
4444
'ie_condition',
45+
'order'
4546
];
4647

4748
/**

lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,16 @@ public function interpret(
7171
Layout\Element $headElement
7272
) {
7373
$pageConfigStructure = $readerContext->getPageConfigStructure();
74-
/** @var \Magento\Framework\View\Layout\Element $node */
75-
foreach ($headElement as $node) {
74+
$nodes = iterator_to_array($headElement, false);
75+
76+
usort(
77+
$nodes,
78+
function (Layout\Element $current, Layout\Element $next) {
79+
return $current->getAttribute('order') <=> $next->getAttribute('order');
80+
}
81+
);
82+
83+
foreach ($nodes as $node) {
7684
switch ($node->getName()) {
7785
case self::HEAD_CSS:
7886
case self::HEAD_SCRIPT:
@@ -105,6 +113,7 @@ public function interpret(
105113
break;
106114
}
107115
}
116+
108117
return $this;
109118
}
110119

0 commit comments

Comments
 (0)