Skip to content

Commit 9c44ebf

Browse files
author
Oleksii Korshenko
committed
MAGETWO-62136: Prepare code base for 2.1.4
Conflicts: app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js composer.json composer.lock
2 parents 641201b + bd7f025 commit 9c44ebf

File tree

48 files changed

+1684
-428
lines changed

Some content is hidden

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

48 files changed

+1684
-428
lines changed

app/code/Magento/Braintree/Helper/Country.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Braintree\Helper;
77

8+
use Magento\Braintree\Model\Adminhtml\System\Config\Country as CountryConfig;
89
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
910
use Magento\Braintree\Model\Adminhtml\System\Config\Country as CountryConfig;
1011

@@ -51,6 +52,7 @@ public function getCountries()
5152
->loadData()
5253
->toOptionArray(false);
5354
}
55+
5456
return $this->countries;
5557
}
5658
}

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ public function getRemoveUrl()
228228
*/
229229
public function getPostDataRemove($product)
230230
{
231-
$listCleanUrl = $this->getEncodedUrl($this->_getUrl('catalog/product_compare'));
232231
$data = [
233-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $listCleanUrl,
234-
'product' => $product->getId()
232+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
233+
'product' => $product->getId(),
235234
];
236235
return $this->postHelper->getPostData($this->getRemoveUrl(), $data);
237236
}
@@ -253,9 +252,8 @@ public function getClearListUrl()
253252
*/
254253
public function getPostDataClearList()
255254
{
256-
$refererUrl = $this->_getRequest()->getServer('HTTP_REFERER');
257255
$params = [
258-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($refererUrl)
256+
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
259257
];
260258
return $this->postHelper->getPostData($this->getClearListUrl(), $params);
261259
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
221221

222222
unset($tables[$entityTableName]);
223223

224-
$allColumns = array_merge(['entity_id', 'type_id', 'attribute_set_id'], $columnsList);
224+
$allColumns = array_values(
225+
array_unique(
226+
array_merge(['entity_id', $linkField, 'type_id', 'attribute_set_id'], $columnsList)
227+
)
228+
);
225229

226230
/* @var $status \Magento\Eav\Model\Entity\Attribute */
227231
$status = $this->_productIndexerHelper->getAttribute('status');
@@ -263,7 +267,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
263267

264268
$select->joinLeft(
265269
$temporaryTableName,
266-
"e.entity_id = " . $temporaryTableName . ".entity_id",
270+
"e.${linkField} = ${temporaryTableName}.${linkField}",
267271
$columnsNames
268272
);
269273
$allColumns = array_merge($allColumns, $columnsNames);
@@ -277,7 +281,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
277281
if (!empty($columnValueNames)) {
278282
$select->joinLeft(
279283
$temporaryValueTableName,
280-
"e.${linkField} = " . $temporaryValueTableName . ".entity_id",
284+
"e.${linkField} = " . $temporaryValueTableName . ".${linkField}",
281285
$columnValueNames
282286
);
283287
$allColumns = array_merge($allColumns, $columnValueNames);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Indexer\Product\Flat\Table;
7+
8+
/**
9+
* Class Builder
10+
*/
11+
class Builder implements BuilderInterface
12+
{
13+
/**
14+
* @var \Magento\Framework\DB\Ddl\Table
15+
*/
16+
private $tableInstance;
17+
18+
/**
19+
* Builder constructor.
20+
*
21+
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
22+
* @param string $tableName
23+
*/
24+
public function __construct(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $tableName)
25+
{
26+
$this->tableInstance = $connection->newTable($tableName);
27+
}
28+
29+
/**
30+
* Adds column to table.
31+
*
32+
* $options contains additional options for columns. Supported values are:
33+
* - 'unsigned', for number types only. Default: FALSE.
34+
* - 'precision', for numeric and decimal only. Default: taken from $size, if not set there then 0.
35+
* - 'scale', for numeric and decimal only. Default: taken from $size, if not set there then 10.
36+
* - 'default'. Default: not set.
37+
* - 'nullable'. Default: TRUE.
38+
* - 'primary', add column to primary index. Default: do not add.
39+
* - 'primary_position', only for column in primary index. Default: count of primary columns + 1.
40+
* - 'identity' or 'auto_increment'. Default: FALSE.
41+
*
42+
* @param string $name the column name
43+
* @param string $type the column data type
44+
* @param string|int|array $size the column length
45+
* @param array $options array of additional options
46+
* @param string $comment column description
47+
* @return $this
48+
* @throws \Zend_Db_Exception
49+
*/
50+
public function addColumn($name, $type, $size = null, $options = [], $comment = null)
51+
{
52+
$this->tableInstance->addColumn($name, $type, $size, $options, $comment);
53+
return $this;
54+
}
55+
56+
/**
57+
* @return \Magento\Framework\DB\Ddl\Table
58+
*/
59+
public function getTable()
60+
{
61+
return $this->tableInstance;
62+
}
63+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Indexer\Product\Flat\Table;
7+
8+
/**
9+
* Interface BuilderInterface
10+
*/
11+
interface BuilderInterface
12+
{
13+
/**
14+
* Adds column to table.
15+
*
16+
* $options contains additional options for columns. Supported values are:
17+
* - 'unsigned', for number types only. Default: FALSE.
18+
* - 'precision', for numeric and decimal only. Default: taken from $size, if not set there then 0.
19+
* - 'scale', for numeric and decimal only. Default: taken from $size, if not set there then 10.
20+
* - 'default'. Default: not set.
21+
* - 'nullable'. Default: TRUE.
22+
* - 'primary', add column to primary index. Default: do not add.
23+
* - 'primary_position', only for column in primary index. Default: count of primary columns + 1.
24+
* - 'identity' or 'auto_increment'. Default: FALSE.
25+
*
26+
* @param string $name the column name
27+
* @param string $type the column data type
28+
* @param string|int|array $size the column length
29+
* @param array $options array of additional options
30+
* @param string $comment column description
31+
* @return $this
32+
* @throws \Zend_Db_Exception
33+
*/
34+
public function addColumn($name, $type, $size = null, $options = [], $comment = null);
35+
36+
/**
37+
* @return \Magento\Framework\DB\Ddl\Table
38+
*/
39+
public function getTable();
40+
}

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

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Product\Flat;
77

8-
use Magento\Framework\App\ResourceConnection;
8+
use Magento\Catalog\Model\Indexer\Product\Flat\Table\BuilderInterfaceFactory;
99

1010
/**
1111
* Class TableBuilder
@@ -32,6 +32,11 @@ class TableBuilder
3232
*/
3333
protected $resource;
3434

35+
/**
36+
* @var BuilderInterfaceFactory
37+
*/
38+
private $tableBuilderFactory;
39+
3540
/**
3641
* Check whether builder was executed
3742
*
@@ -123,17 +128,27 @@ protected function _createTemporaryTable($tableName, array $columns, $valueField
123128
$valueTables = [];
124129
if (!empty($columns)) {
125130
$valueTableName = $tableName . $valueFieldSuffix;
126-
$temporaryTable = $this->_connection->newTable($tableName);
127-
$valueTemporaryTable = $this->_connection->newTable($valueTableName);
131+
$temporaryTableBuilder = $this->getTableBuilderFactory()->create(
132+
[
133+
'connection' => $this->_connection,
134+
'tableName' => $tableName
135+
]
136+
);
137+
$valueTemporaryTableBuilder = $this->getTableBuilderFactory()->create(
138+
[
139+
'connection' => $this->_connection,
140+
'tableName' => $valueTableName
141+
]
142+
);
128143
$flatColumns = $this->_productIndexerHelper->getFlatColumns();
129144

130-
$temporaryTable->addColumn('entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER);
145+
$temporaryTableBuilder->addColumn('entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER);
131146

132-
$temporaryTable->addColumn('type_id', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT);
147+
$temporaryTableBuilder->addColumn('type_id', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT);
133148

134-
$temporaryTable->addColumn('attribute_set_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER);
149+
$temporaryTableBuilder->addColumn('attribute_set_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER);
135150

136-
$valueTemporaryTable->addColumn('entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER);
151+
$valueTemporaryTableBuilder->addColumn('entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER);
137152

138153
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
139154
foreach ($columns as $columnName => $attribute) {
@@ -145,7 +160,7 @@ protected function _createTemporaryTable($tableName, array $columns, $valueField
145160
$column = $column[$attributeCode];
146161
}
147162

148-
$temporaryTable->addColumn(
163+
$temporaryTableBuilder->addColumn(
149164
$columnName,
150165
$column['type'],
151166
isset($column['length']) ? $column['length'] : null
@@ -154,19 +169,19 @@ protected function _createTemporaryTable($tableName, array $columns, $valueField
154169
$columnValueName = $attributeCode . $valueFieldSuffix;
155170
if (isset($flatColumns[$columnValueName])) {
156171
$columnValue = $flatColumns[$columnValueName];
157-
$valueTemporaryTable->addColumn(
172+
$valueTemporaryTableBuilder->addColumn(
158173
$columnValueName,
159174
$columnValue['type'],
160175
isset($columnValue['length']) ? $columnValue['length'] : null
161176
);
162177
}
163178
}
164179
$this->_connection->dropTemporaryTable($tableName);
165-
$this->_connection->createTemporaryTable($temporaryTable);
180+
$this->_connection->createTemporaryTable($temporaryTableBuilder->getTable());
166181

167-
if (count($valueTemporaryTable->getColumns()) > 1) {
182+
if (count($valueTemporaryTableBuilder->getTable()->getColumns()) > 1) {
168183
$this->_connection->dropTemporaryTable($valueTableName);
169-
$this->_connection->createTemporaryTable($valueTemporaryTable);
184+
$this->_connection->createTemporaryTable($valueTemporaryTableBuilder->getTable());
170185
$valueTables[$valueTableName] = $valueTableName;
171186
}
172187
}
@@ -197,7 +212,8 @@ protected function _fillTemporaryEntityTable($tableName, array $columns, array $
197212
if (!empty($columns)) {
198213
$select = $this->_connection->select();
199214
$temporaryEntityTable = $this->_getTemporaryTableName($tableName);
200-
$idsColumns = ['entity_id', 'type_id', 'attribute_set_id'];
215+
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
216+
$idsColumns = array_unique([$metadata->getLinkField(), 'entity_id', 'type_id', 'attribute_set_id']);
201217

202218
$columns = array_merge($idsColumns, array_keys($columns));
203219

@@ -261,7 +277,7 @@ protected function _fillTemporaryTable(
261277
);
262278
$temporaryTableName = $this->_getTemporaryTableName($tableName);
263279
$temporaryValueTableName = $temporaryTableName . $valueFieldSuffix;
264-
$keyColumn = ['entity_id'];
280+
$keyColumn = array_unique([$metadata->getLinkField(), 'entity_id']);
265281
$columns = array_merge($keyColumn, array_keys($columnsList));
266282
$valueColumns = $keyColumn;
267283
$flatColumns = $this->_productIndexerHelper->getFlatColumns();
@@ -333,6 +349,19 @@ protected function _fillTemporaryTable(
333349
}
334350
}
335351

352+
/**
353+
* @return BuilderInterfaceFactory
354+
*/
355+
private function getTableBuilderFactory()
356+
{
357+
if (null === $this->tableBuilderFactory) {
358+
$this->tableBuilderFactory = \Magento\Framework\App\ObjectManager::getInstance()
359+
->get(BuilderInterfaceFactory::class);
360+
}
361+
362+
return $this->tableBuilderFactory;
363+
}
364+
336365
/**
337366
* @return \Magento\Framework\EntityManager\MetadataPool
338367
*/

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,14 +1905,18 @@ public function addOption(Product\Option $option)
19051905
*/
19061906
public function getOptionById($optionId)
19071907
{
1908-
/** @var \Magento\Catalog\Model\Product\Option $option */
1909-
foreach ($this->getOptions() as $option) {
1910-
if ($option->getId() == $optionId) {
1911-
return $option;
1908+
$result = null;
1909+
if (is_array($this->getOptions())) {
1910+
/** @var \Magento\Catalog\Model\Product\Option $option */
1911+
foreach ($this->getOptions() as $option) {
1912+
if ($option->getId() == $optionId) {
1913+
$result = $option;
1914+
break;
1915+
}
19121916
}
19131917
}
19141918

1915-
return null;
1919+
return $result;
19161920
}
19171921

19181922
/**

app/code/Magento/Catalog/Model/Product/Option/Type/File.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\Product\Option\Type;
77

8+
use Magento\Framework\App\Filesystem\DirectoryList;
89
use Magento\Framework\Filesystem;
910
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Catalog\Model\Product\Exception as ProductException;
@@ -69,17 +70,22 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
6970
*/
7071
protected $validatorFile;
7172

73+
/**
74+
* @var Filesystem
75+
*/
76+
private $filesystem;
77+
7278
/**
7379
* @param \Magento\Checkout\Model\Session $checkoutSession
7480
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
7581
* @param \Magento\Quote\Model\Quote\Item\OptionFactory $itemOptionFactory
76-
* @param \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder
77-
* @param \Magento\Framework\Escaper $escaper
7882
* @param \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase
7983
* @param File\ValidatorInfo $validatorInfo
8084
* @param File\ValidatorFile $validatorFile
85+
* @param \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder
86+
* @param \Magento\Framework\Escaper $escaper
8187
* @param array $data
82-
* @throws \Magento\Framework\Exception\FileSystemException
88+
* @param Filesystem $filesystem
8389
*/
8490
public function __construct(
8591
\Magento\Checkout\Model\Session $checkoutSession,
@@ -90,12 +96,15 @@ public function __construct(
9096
\Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile $validatorFile,
9197
\Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder,
9298
\Magento\Framework\Escaper $escaper,
93-
array $data = []
99+
array $data = [],
100+
Filesystem $filesystem = null
94101
) {
95102
$this->_itemOptionFactory = $itemOptionFactory;
96103
$this->_urlBuilder = $urlBuilder;
97104
$this->_escaper = $escaper;
98105
$this->_coreFileStorageDatabase = $coreFileStorageDatabase;
106+
$this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class);
107+
$this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
99108
$this->validatorInfo = $validatorInfo;
100109
$this->validatorFile = $validatorFile;
101110
parent::__construct($checkoutSession, $scopeConfig, $data);

0 commit comments

Comments
 (0)