Skip to content

Commit a8e663a

Browse files
committed
MAGETWO-69379: Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-69379-PR-9717
2 parents 2880971 + ae53ec1 commit a8e663a

File tree

84 files changed

+2204
-277
lines changed

Some content is hidden

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

84 files changed

+2204
-277
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ addons:
77
- mysql-client-core-5.6
88
- mysql-client-5.6
99
- postfix
10+
firefox: "46.0"
11+
hosts:
12+
- magento2.travis
1013
language: php
1114
php:
1215
- 7.0
@@ -16,19 +19,26 @@ env:
1619
- COMPOSER_BIN_DIR=~/bin
1720
- INTEGRATION_SETS=3
1821
- NODE_JS_VERSION=6
22+
- MAGENTO_HOST_NAME="magento2.travis"
1923
matrix:
2024
- TEST_SUITE=unit
2125
- TEST_SUITE=integration INTEGRATION_INDEX=1
2226
- TEST_SUITE=integration INTEGRATION_INDEX=2
2327
- TEST_SUITE=integration INTEGRATION_INDEX=3
2428
- TEST_SUITE=static
2529
- TEST_SUITE=js
30+
- TEST_SUITE=functional ACCEPTANCE_INDEX=1
31+
- TEST_SUITE=functional ACCEPTANCE_INDEX=2
2632
matrix:
2733
exclude:
2834
- php: 7.0
2935
env: TEST_SUITE=static
3036
- php: 7.0
3137
env: TEST_SUITE=js
38+
- php: 7.0
39+
env: TEST_SUITE=functional ACCEPTANCE_INDEX=1
40+
- php: 7.0
41+
env: TEST_SUITE=functional ACCEPTANCE_INDEX=2
3242
cache:
3343
apt: true
3444
directories:

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ define(
3636
braintreeDeviceData: null,
3737
paymentMethodNonce: null,
3838
lastBillingAddress: null,
39+
ccCode: null,
40+
ccMessageContainer: null,
3941
validatorManager: validatorManager,
4042
code: 'braintree',
4143

@@ -138,9 +140,39 @@ define(
138140
return;
139141
}
140142

143+
this.restoreMessageContainer();
144+
this.restoreCode();
145+
146+
/**
147+
* Define onReady callback
148+
*/
149+
braintree.onReady = function () {};
141150
this.initBraintree();
142151
},
143152

153+
/**
154+
* Restore original message container for cc-form component
155+
*/
156+
restoreMessageContainer: function () {
157+
this.messageContainer = this.ccMessageContainer;
158+
},
159+
160+
/**
161+
* Restore original code for cc-form component
162+
*/
163+
restoreCode: function () {
164+
this.code = this.ccCode;
165+
},
166+
167+
/** @inheritdoc */
168+
initChildren: function () {
169+
this._super();
170+
this.ccMessageContainer = this.messageContainer;
171+
this.ccCode = this.code;
172+
173+
return this;
174+
},
175+
144176
/**
145177
* Init config
146178
*/

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ define([
5252
var self = this;
5353

5454
/**
55-
* Define already callback
55+
* Define onReady callback
5656
*/
5757
Braintree.onReady = function () {
5858
self.getPaymentMethodNonce();
@@ -78,6 +78,7 @@ define([
7878
formComponent.setPaymentMethodNonce(response.paymentMethodNonce);
7979
formComponent.additionalData['public_hash'] = self.publicHash;
8080
formComponent.code = self.code;
81+
formComponent.messageContainer = self.messageContainer;
8182
formComponent.placeOrder();
8283
});
8384
})

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@
139139
<button class="action primary checkout"
140140
type="submit"
141141
data-bind="
142-
click: placeOrderClick,
143-
attr: {title: $t('Place Order')}
144-
">
142+
click: placeOrderClick,
143+
attr: {title: $t('Place Order')},
144+
css: {disabled: !isPlaceOrderActionAllowed()},
145+
enable: isActive()
146+
"
147+
disabled>
145148
<span data-bind="i18n: 'Place Order'"></span>
146149
</button>
147150
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function execute($entity, $arguments = [])
6666
$options = $bundleProductOptions ?: [];
6767
foreach ($options as $option) {
6868
$this->optionRepository->save($entity, $option);
69-
$entity->setCopyFromView(false);
7069
}
70+
$entity->setCopyFromView(false);
7171
}
7272
return $entity;
7373
}

app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @api
88
*/
99
define([
10+
'jquery',
1011
'Magento_Ui/js/lib/view/utils/async',
1112
'jquery/ui',
1213
'mage/translate',
@@ -838,4 +839,6 @@ define([
838839
};
839840

840841
productConfigure = new ProductConfigure();
842+
jQuery(document).trigger('productConfigure:inited');
843+
jQuery(document).data('productConfigureInited', true);
841844
});

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\ImportExport\Model\Import\Entity\AbstractEntity;
1919
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError;
2020
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
21+
use Magento\Catalog\Model\Config as CatalogConfig;
2122

2223
/**
2324
* Import entity product model
@@ -657,6 +658,13 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
657658
*/
658659
private $multiLineSeparatorForRegexp;
659660

661+
/**
662+
* Catalog config.
663+
*
664+
* @var CatalogConfig
665+
*/
666+
private $catalogConfig;
667+
660668
/**
661669
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
662670
* @param \Magento\ImportExport\Helper\Data $importExportData
@@ -695,6 +703,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
695703
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
696704
* @param array $data
697705
* @param array $dateAttrCodes
706+
* @param CatalogConfig $catalogConfig
698707
* @throws \Magento\Framework\Exception\LocalizedException
699708
*
700709
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -737,7 +746,8 @@ public function __construct(
737746
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
738747
\Magento\Catalog\Model\Product\Url $productUrl,
739748
array $data = [],
740-
array $dateAttrCodes = []
749+
array $dateAttrCodes = [],
750+
CatalogConfig $catalogConfig = null
741751
) {
742752
$this->_eventManager = $eventManager;
743753
$this->stockRegistry = $stockRegistry;
@@ -767,6 +777,9 @@ public function __construct(
767777
$this->scopeConfig = $scopeConfig;
768778
$this->productUrl = $productUrl;
769779
$this->dateAttrCodes = array_merge($this->dateAttrCodes, $dateAttrCodes);
780+
$this->catalogConfig = $catalogConfig ?: \Magento\Framework\App\ObjectManager::getInstance()
781+
->get(CatalogConfig::class);
782+
770783
parent::__construct(
771784
$jsonHelper,
772785
$importExportData,
@@ -1330,7 +1343,7 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp)
13301343
$entityTable = $this->_resourceFactory->create()->getEntityTable();
13311344
}
13321345
if ($entityRowsUp) {
1333-
$this->_connection->insertOnDuplicate($entityTable, $entityRowsUp, ['updated_at']);
1346+
$this->_connection->insertOnDuplicate($entityTable, $entityRowsUp, ['updated_at', 'attribute_set_id']);
13341347
}
13351348
if ($entityRowsIn) {
13361349
$this->_connection->insertMultiple($entityTable, $entityRowsIn);
@@ -1563,9 +1576,29 @@ protected function _saveProducts()
15631576
// 1. Entity phase
15641577
if (isset($this->_oldSku[$rowSku])) {
15651578
// existing row
1579+
if (isset($rowData['attribute_set_code'])) {
1580+
$attributeSetId = $this->catalogConfig->getAttributeSetId(
1581+
$this->getEntityTypeId(),
1582+
$rowData['attribute_set_code']
1583+
);
1584+
1585+
// wrong attribute_set_code was received
1586+
if (!$attributeSetId) {
1587+
throw new \Magento\Framework\Exception\LocalizedException(
1588+
__(
1589+
'Wrong attribute set code "%1", please correct it and try again.',
1590+
$rowData['attribute_set_code']
1591+
)
1592+
);
1593+
}
1594+
} else {
1595+
$attributeSetId = $this->skuProcessor->getNewSku($rowSku)['attr_set_id'];
1596+
}
1597+
15661598
$entityRowsUp[] = [
15671599
'updated_at' => (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT),
1568-
$this->getProductEntityLinkField() => $this->_oldSku[$rowSku][$this->getProductEntityLinkField()],
1600+
'attribute_set_id' => $attributeSetId,
1601+
$this->getProductEntityLinkField() => $this->_oldSku[$rowSku][$this->getProductEntityLinkField()]
15691602
];
15701603
} else {
15711604
if (!$productLimit || $productsQty < $productLimit) {

app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
namespace Magento\CatalogUrlRewrite\Observer;
77

88
use Magento\Catalog\Model\Category;
9-
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\Product\Visibility;
10+
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
11+
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
1012
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
1113
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
14+
use Magento\Framework\App\ObjectManager;
1215
use Magento\Framework\Event\Observer;
13-
use Magento\Framework\App\ResourceConnection;
16+
use Magento\Framework\Event\ObserverInterface;
1417
use Magento\ImportExport\Model\Import as ImportExport;
1518
use Magento\Store\Model\Store;
19+
use Magento\UrlRewrite\Model\MergeDataProviderFactory;
20+
use Magento\UrlRewrite\Model\OptionProvider;
21+
use Magento\UrlRewrite\Model\UrlFinderInterface;
1622
use Magento\UrlRewrite\Model\UrlPersistInterface;
1723
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1824
use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory;
19-
use Magento\UrlRewrite\Model\OptionProvider;
20-
use Magento\UrlRewrite\Model\UrlFinderInterface;
21-
use Magento\Framework\Event\ObserverInterface;
22-
use Magento\Catalog\Model\Product\Visibility;
23-
use Magento\Framework\App\ObjectManager;
24-
use Magento\UrlRewrite\Model\MergeDataProviderFactory;
2525

2626
/**
2727
* Class AfterImportDataObserver
@@ -102,6 +102,20 @@ class AfterImportDataObserver implements ObserverInterface
102102
/** @var \Magento\UrlRewrite\Model\MergeDataProvider */
103103
private $mergeDataProviderPrototype;
104104

105+
/**
106+
* Factory for creating category collection.
107+
*
108+
* @var CategoryCollectionFactory
109+
*/
110+
private $categoryCollectionFactory;
111+
112+
/**
113+
* Array of invoked categories during url rewrites generation.
114+
*
115+
* @var array
116+
*/
117+
private $categoriesCache = [];
118+
105119
/**
106120
* @param \Magento\Catalog\Model\ProductFactory $catalogProductFactory
107121
* @param \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory $objectRegistryFactory
@@ -112,7 +126,7 @@ class AfterImportDataObserver implements ObserverInterface
112126
* @param UrlRewriteFactory $urlRewriteFactory
113127
* @param UrlFinderInterface $urlFinder
114128
* @param \Magento\UrlRewrite\Model\MergeDataProviderFactory|null $mergeDataProviderFactory
115-
* @throws \InvalidArgumentException
129+
* @param CategoryCollectionFactory|null $categoryCollectionFactory
116130
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
117131
*/
118132
public function __construct(
@@ -124,7 +138,8 @@ public function __construct(
124138
UrlPersistInterface $urlPersist,
125139
UrlRewriteFactory $urlRewriteFactory,
126140
UrlFinderInterface $urlFinder,
127-
MergeDataProviderFactory $mergeDataProviderFactory = null
141+
MergeDataProviderFactory $mergeDataProviderFactory = null,
142+
CategoryCollectionFactory $categoryCollectionFactory = null
128143
) {
129144
$this->urlPersist = $urlPersist;
130145
$this->catalogProductFactory = $catalogProductFactory;
@@ -138,6 +153,8 @@ public function __construct(
138153
$mergeDataProviderFactory = ObjectManager::getInstance()->get(MergeDataProviderFactory::class);
139154
}
140155
$this->mergeDataProviderPrototype = $mergeDataProviderFactory->create();
156+
$this->categoryCollectionFactory = $categoryCollectionFactory ?:
157+
ObjectManager::getInstance()->get(CategoryCollectionFactory::class);
141158
}
142159

143160
/**
@@ -318,7 +335,7 @@ protected function canonicalUrlRewriteGenerate()
318335
}
319336

320337
/**
321-
* Generate list based on categories
338+
* Generate list based on categories.
322339
*
323340
* @return UrlRewrite[]
324341
*/
@@ -328,7 +345,7 @@ protected function categoriesUrlRewriteGenerate()
328345
foreach ($this->products as $productId => $productsByStores) {
329346
foreach ($productsByStores as $storeId => $product) {
330347
foreach ($this->categoryCache[$productId] as $categoryId) {
331-
$category = $this->import->getCategoryProcessor()->getCategoryById($categoryId);
348+
$category = $this->getCategoryById($categoryId, $storeId);
332349
if ($category->getParentId() == Category::TREE_ROOT_ID) {
333350
continue;
334351
}
@@ -481,4 +498,27 @@ protected function isCategoryProperForGenerating($category, $storeId)
481498
$this->acceptableCategories[$storeId][$category->getId()] = $acceptable;
482499
return $acceptable;
483500
}
501+
502+
/**
503+
* Get category by id considering store scope.
504+
*
505+
* @param int $categoryId
506+
* @param int $storeId
507+
* @return Category|\Magento\Framework\DataObject
508+
*/
509+
private function getCategoryById($categoryId, $storeId)
510+
{
511+
if (!isset($this->categoriesCache[$categoryId][$storeId])) {
512+
/** @var CategoryCollection $categoryCollection */
513+
$categoryCollection = $this->categoryCollectionFactory->create();
514+
$categoryCollection->addIdFilter([$categoryId])
515+
->setStoreId($storeId)
516+
->addAttributeToSelect('name')
517+
->addAttributeToSelect('url_key')
518+
->addAttributeToSelect('url_path');
519+
$this->categoriesCache[$categoryId][$storeId] = $categoryCollection->getFirstItem();
520+
}
521+
522+
return $this->categoriesCache[$categoryId][$storeId];
523+
}
484524
}

0 commit comments

Comments
 (0)