Skip to content

Commit d2cbcd7

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'mainline/develop' into bug-fixes
2 parents 3899b54 + b2e5e71 commit d2cbcd7

File tree

134 files changed

+4504
-921
lines changed

Some content is hidden

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

134 files changed

+4504
-921
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Bundle\Setup;
7+
8+
use Magento\Framework\Setup\ExternalFKSetup;
9+
use Magento\Framework\Setup\InstallSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
use Magento\Framework\Model\Entity\MetadataPool;
13+
use Magento\Catalog\Api\Data\ProductInterface;
14+
15+
/**
16+
* @codeCoverageIgnore
17+
*/
18+
class Recurring implements InstallSchemaInterface
19+
{
20+
/**
21+
* @var MetadataPool
22+
*/
23+
protected $metadataPool;
24+
25+
/**
26+
* @var ExternalFKSetup
27+
*/
28+
protected $externalFKSetup;
29+
30+
/**
31+
* @param MetadataPool $metadataPool
32+
* @param ExternalFKSetup $externalFKSetup
33+
*/
34+
public function __construct(
35+
MetadataPool $metadataPool,
36+
ExternalFKSetup $externalFKSetup
37+
) {
38+
$this->metadataPool = $metadataPool;
39+
$this->externalFKSetup = $externalFKSetup;
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
46+
{
47+
$installer = $setup;
48+
$installer->startSetup();
49+
50+
$listTables = [
51+
'catalog_product_bundle_price_index' => 'entity_id',
52+
'catalog_product_bundle_selection' => 'product_id',
53+
];
54+
foreach ($listTables as $tableName => $columnName) {
55+
$this->addExternalForeignKeys($installer, $tableName, $columnName);
56+
}
57+
58+
$installer->endSetup();
59+
}
60+
61+
/**
62+
* Add external foreign keys
63+
*
64+
* @param SchemaSetupInterface $installer
65+
* @param string $tableName
66+
* @param string $columnName
67+
* @return void
68+
* @throws \Exception
69+
*/
70+
protected function addExternalForeignKeys(SchemaSetupInterface $installer, $tableName, $columnName)
71+
{
72+
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
73+
$this->externalFKSetup->install(
74+
$installer,
75+
$metadata->getEntityTable(),
76+
$metadata->getIdentifierField(),
77+
$tableName,
78+
$columnName
79+
);
80+
}
81+
}

app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public function __construct(
5252
public function execute()
5353
{
5454
$storeId = (int)$this->getRequest()->getParam('store');
55+
$store = $this->storeManager->getStore($storeId);
56+
$this->storeManager->setCurrentStore($store->getCode());
57+
5558
$categoryId = (int)$this->getRequest()->getParam('id');
5659

5760
if (!$categoryId) {

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Controller\Adminhtml\Category;
77

8+
use Magento\Store\Model\StoreManagerInterface;
9+
810
/**
911
* Class Save
1012
*
@@ -43,24 +45,32 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
4345
]
4446
];
4547

48+
/**
49+
* @var StoreManagerInterface
50+
*/
51+
private $storeManager;
52+
4653
/**
4754
* Constructor
4855
*
4956
* @param \Magento\Backend\App\Action\Context $context
5057
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
5158
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
5259
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
60+
* @param StoreManagerInterface $storeManager
5361
*/
5462
public function __construct(
5563
\Magento\Backend\App\Action\Context $context,
5664
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
5765
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
58-
\Magento\Framework\View\LayoutFactory $layoutFactory
66+
\Magento\Framework\View\LayoutFactory $layoutFactory,
67+
StoreManagerInterface $storeManager
5968
) {
6069
parent::__construct($context);
6170
$this->resultRawFactory = $resultRawFactory;
6271
$this->resultJsonFactory = $resultJsonFactory;
6372
$this->layoutFactory = $layoutFactory;
73+
$this->storeManager = $storeManager;
6474
}
6575

6676
/**
@@ -104,6 +114,8 @@ public function execute()
104114
$data = $this->stringToBoolConverting($data);
105115
$data = $this->imagePreprocessing($data);
106116
$storeId = isset($data['general']['store_id']) ? $data['general']['store_id'] : null;
117+
$store = $this->storeManager->getStore($storeId);
118+
$this->storeManager->setCurrentStore($store->getCode());
107119
$parentId = isset($data['general']['parent']) ? $data['general']['parent'] : null;
108120
if ($data['general']) {
109121
$category->addData($this->_filterCategoryPostData($data['general']));
@@ -163,6 +175,7 @@ public function execute()
163175
if ($category->hasCustomDesignTo()) {
164176
$categoryResource->getAttribute('custom_design_from')->setMaxValue($category->getCustomDesignTo());
165177
}
178+
166179
$validate = $category->validate();
167180
if ($validate !== true) {
168181
foreach ($validate as $code => $error) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public function __construct(
4141
*/
4242
public function execute()
4343
{
44+
/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
45+
$storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface');
46+
$storeId = (int) $this->getRequest()->getParam('store', 0);
47+
$store = $storeManager->getStore($storeId);
48+
$storeManager->setCurrentStore($store->getCode());
4449
$productId = (int) $this->getRequest()->getParam('id');
4550
$product = $this->productBuilder->build($this->getRequest());
4651

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function initialize(\Magento\Catalog\Model\Product $product)
156156
$product->lockAttribute('media');
157157
}
158158

159-
if ($this->storeManager->hasSingleStore()) {
159+
if ($this->storeManager->hasSingleStore() && empty($product->getWebsiteIds())) {
160160
$product->setWebsiteIds([$this->storeManager->getStore(true)->getWebsite()->getId()]);
161161
}
162162

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Backend\App\Action;
1010
use Magento\Catalog\Controller\Adminhtml\Product;
11+
use Magento\Store\Model\StoreManagerInterface;
1112

1213
class Save extends \Magento\Catalog\Controller\Adminhtml\Product
1314
{
@@ -37,13 +38,21 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product
3738
protected $productRepository;
3839

3940
/**
41+
* @var StoreManagerInterface
42+
*/
43+
private $storeManager;
44+
45+
/**
46+
* Save constructor.
47+
*
4048
* @param Action\Context $context
4149
* @param Builder $productBuilder
4250
* @param Initialization\Helper $initializationHelper
4351
* @param \Magento\Catalog\Model\Product\Copier $productCopier
4452
* @param \Magento\Catalog\Model\Product\TypeTransitionManager $productTypeManager
4553
* @param \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement
4654
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
55+
* @param StoreManagerInterface $storeManager
4756
*/
4857
public function __construct(
4958
\Magento\Backend\App\Action\Context $context,
@@ -52,13 +61,15 @@ public function __construct(
5261
\Magento\Catalog\Model\Product\Copier $productCopier,
5362
\Magento\Catalog\Model\Product\TypeTransitionManager $productTypeManager,
5463
\Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement,
55-
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
64+
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
65+
StoreManagerInterface $storeManager
5666
) {
5767
$this->initializationHelper = $initializationHelper;
5868
$this->productCopier = $productCopier;
5969
$this->productTypeManager = $productTypeManager;
6070
$this->categoryLinkManagement = $categoryLinkManagement;
6171
$this->productRepository = $productRepository;
72+
$this->storeManager = $storeManager;
6273
parent::__construct($context, $productBuilder);
6374
}
6475

@@ -71,7 +82,9 @@ public function __construct(
7182
*/
7283
public function execute()
7384
{
74-
$storeId = $this->getRequest()->getParam('store');
85+
$storeId = $this->getRequest()->getParam('store', 0);
86+
$store = $this->storeManager->getStore($storeId);
87+
$this->storeManager->setCurrentStore($store->getCode());
7588
$redirectBack = $this->getRequest()->getParam('back', false);
7689
$productId = $this->getRequest()->getParam('id');
7790
$resultRedirect = $this->resultRedirectFactory->create();

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ public function afterLoad($object)
116116
if ($attributeCode == 'available_sort_by') {
117117
$data = $object->getData($attributeCode);
118118
if ($data) {
119-
$object->setData($attributeCode, explode(',', $data));
119+
if (!is_array($data)) {
120+
$object->setData($attributeCode, explode(',', $data));
121+
} else {
122+
$object->setData($attributeCode, $data);
123+
}
124+
120125
}
121126
}
122127
return $this;

0 commit comments

Comments
 (0)