Skip to content

Commit 0c6227d

Browse files
authored
Merge pull request #504 from magento-troll/sprint21
MAGETWO-51655 [Improvement] Convert customer group identifier field from SMALLINT to INT
2 parents cbe29b0 + f659682 commit 0c6227d

File tree

44 files changed

+654
-81
lines changed

Some content is hidden

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

44 files changed

+654
-81
lines changed

app/code/Magento/Bundle/Setup/InstallSchema.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
2424
$installer = $setup;
2525

2626
$installer->startSetup();
27-
27+
$customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group'));
28+
$customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int'
29+
? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE'];
2830
/**
2931
* Create table 'catalog_product_bundle_option'
3032
*/
@@ -340,7 +342,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
340342
)
341343
->addColumn(
342344
'customer_group_id',
343-
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
345+
$customerGroupIdType,
344346
null,
345347
['unsigned' => true, 'nullable' => false, 'primary' => true],
346348
'Customer Group Id'

app/code/Magento/Bundle/Setup/UpgradeSchema.php

100644100755
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
4444
}
4545
}
4646

47+
if (version_compare($context->getVersion(), '2.0.3', '<')) {
48+
$tables = [
49+
'catalog_product_index_price_bundle_idx',
50+
'catalog_product_index_price_bundle_opt_idx',
51+
'catalog_product_index_price_bundle_opt_tmp',
52+
'catalog_product_index_price_bundle_sel_idx',
53+
'catalog_product_index_price_bundle_sel_tmp',
54+
'catalog_product_index_price_bundle_tmp',
55+
];
56+
foreach ($tables as $table) {
57+
$setup->getConnection()->modifyColumn(
58+
$setup->getTable($table),
59+
'customer_group_id',
60+
['type' => 'integer', 'nullable' => false]
61+
);
62+
}
63+
}
64+
4765
$setup->endSetup();
4866
}
4967
}

app/code/Magento/Bundle/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Bundle" setup_version="2.0.2">
9+
<module name="Magento_Bundle" setup_version="2.0.3">
1010
<sequence>
1111
<module name="Magento_Catalog"/>
1212
</sequence>

app/code/Magento/Catalog/Setup/InstallSchema.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
18531853
$installer->getConnection()
18541854
->createTable($table);
18551855

1856+
$customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group'));
1857+
$customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int'
1858+
? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE'];
18561859
/**
18571860
* Create table 'catalog_product_entity_tier_price'
18581861
*/
@@ -1883,7 +1886,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
18831886
)
18841887
->addColumn(
18851888
'customer_group_id',
1886-
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
1889+
$customerGroupIdType,
18871890
null,
18881891
['unsigned' => true, 'nullable' => false, 'default' => '0'],
18891892
'Customer Group ID'
@@ -2937,7 +2940,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
29372940
)
29382941
->addColumn(
29392942
'customer_group_id',
2940-
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
2943+
$customerGroupIdType,
29412944
null,
29422945
['unsigned' => true, 'nullable' => false, 'primary' => true],
29432946
'Customer Group ID'
@@ -3056,7 +3059,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
30563059
)
30573060
->addColumn(
30583061
'customer_group_id',
3059-
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
3062+
$customerGroupIdType,
30603063
null,
30613064
['unsigned' => true, 'nullable' => false, 'primary' => true],
30623065
'Customer Group ID'

app/code/Magento/Catalog/Setup/UpgradeSchema.php

100644100755
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
3636
if (version_compare($context->getVersion(), '2.1.0', '<')) {
3737
$this->addPercentageValueColumn($setup);
3838
}
39+
40+
if (version_compare($context->getVersion(), '2.1.1', '<')) {
41+
$tables = [
42+
'catalog_product_index_price_cfg_opt_agr_idx',
43+
'catalog_product_index_price_cfg_opt_agr_tmp',
44+
'catalog_product_index_price_cfg_opt_idx',
45+
'catalog_product_index_price_cfg_opt_tmp',
46+
'catalog_product_index_price_final_idx',
47+
'catalog_product_index_price_final_tmp',
48+
'catalog_product_index_price_idx',
49+
'catalog_product_index_price_opt_agr_idx',
50+
'catalog_product_index_price_opt_agr_tmp',
51+
'catalog_product_index_price_opt_idx',
52+
'catalog_product_index_price_opt_tmp',
53+
'catalog_product_index_price_tmp',
54+
];
55+
foreach ($tables as $table) {
56+
$setup->getConnection()->modifyColumn(
57+
$setup->getTable($table),
58+
'customer_group_id',
59+
['type' => 'integer', 'nullable' => false]
60+
);
61+
}
62+
}
63+
3964
$setup->endSetup();
4065
}
4166

app/code/Magento/Catalog/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Catalog" setup_version="2.1.0">
9+
<module name="Magento_Catalog" setup_version="2.1.1">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>

app/code/Magento/CatalogRule/Setup/InstallSchema.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
2525

2626
$installer->startSetup();
2727

28+
$customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group'));
29+
$customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int'
30+
? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE'];
2831
/**
2932
* Create table 'catalogrule'
3033
*/
@@ -372,7 +375,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
372375
)
373376
->addColumn(
374377
'customer_group_id',
375-
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
378+
$customerGroupIdType,
376379
null,
377380
['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
378381
'Customer Group Id'
@@ -477,7 +480,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
477480
)
478481
->addColumn(
479482
'customer_group_id',
480-
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
483+
$customerGroupIdType,
481484
null,
482485
['unsigned' => true, 'nullable' => false, 'primary' => true],
483486
'Customer Group Id'

app/code/Magento/CatalogRule/Setup/UpgradeSchema.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
2626
$this->removeSubProductDiscounts($setup);
2727
}
2828

29+
if (version_compare($context->getVersion(), '2.0.2', '<')) {
30+
$tables = [
31+
'catalogrule_product',
32+
'catalogrule_product_price',
33+
];
34+
foreach ($tables as $table) {
35+
$setup->getConnection()->modifyColumn(
36+
$setup->getTable($table),
37+
'customer_group_id',
38+
['type' => 'integer']
39+
);
40+
}
41+
}
42+
2943
$setup->endSetup();
3044
}
3145

app/code/Magento/CatalogRule/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_CatalogRule" setup_version="2.0.1">
9+
<module name="Magento_CatalogRule" setup_version="2.0.2">
1010
<sequence>
1111
<module name="Magento_Rule"/>
1212
<module name="Magento_Catalog"/>

app/code/Magento/Customer/Block/Account/AuthorizationLink.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
namespace Magento\Customer\Block\Account;
77

88
use Magento\Customer\Model\Context;
9+
use Magento\Customer\Block\Account\SortLinkInterface;
910

1011
/**
1112
* Customer authorization link
1213
*
1314
* @SuppressWarnings(PHPMD.DepthOfInheritance)
1415
*/
15-
class AuthorizationLink extends \Magento\Framework\View\Element\Html\Link
16+
class AuthorizationLink extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface
1617
{
1718
/**
1819
* Customer session
@@ -88,4 +89,12 @@ public function isLoggedIn()
8889
{
8990
return $this->httpContext->getValue(Context::CONTEXT_AUTH);
9091
}
92+
93+
/**
94+
* {@inheritdoc}
95+
*/
96+
public function getSortOrder()
97+
{
98+
return $this->getData(self::SORT_ORDER);
99+
}
91100
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Block\Account;
8+
9+
/**
10+
* Class for delimiter.
11+
*/
12+
class Delimiter extends \Magento\Framework\View\Element\Template implements SortLinkInterface
13+
{
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function getSortOrder()
18+
{
19+
return $this->getData(self::SORT_ORDER);
20+
}
21+
}

app/code/Magento/Customer/Block/Account/Link.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*/
66
namespace Magento\Customer\Block\Account;
77

8+
use Magento\Customer\Block\Account\SortLinkInterface;
9+
810
/**
911
* Class Link
1012
*
1113
* @SuppressWarnings(PHPMD.DepthOfInheritance)
1214
*/
13-
class Link extends \Magento\Framework\View\Element\Html\Link
15+
class Link extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface
1416
{
1517
/**
1618
* @var \Magento\Customer\Model\Url
@@ -38,4 +40,12 @@ public function getHref()
3840
{
3941
return $this->_customerUrl->getAccountUrl();
4042
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function getSortOrder()
48+
{
49+
return $this->getData(self::SORT_ORDER);
50+
}
4151
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Block\Account;
8+
9+
use \Magento\Framework\View\Element\Html\Links;
10+
use \Magento\Customer\Block\Account\SortLinkInterface;
11+
12+
/**
13+
* Class for sorting links in navigation panels.
14+
*/
15+
class Navigation extends Links
16+
{
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function getLinks()
21+
{
22+
$links = $this->_layout->getChildBlocks($this->getNameInLayout());
23+
$sortableLink = [];
24+
foreach ($links as $key => $link) {
25+
if ($link instanceof SortLinkInterface) {
26+
$sortableLink[] = $link;
27+
unset($links[$key]);
28+
}
29+
}
30+
31+
usort($sortableLink, [$this, "compare"]);
32+
return array_merge($sortableLink, $links);
33+
}
34+
35+
/**
36+
* Compare sortOrder in links.
37+
*
38+
* @param SortLinkInterface $firstLink
39+
* @param SortLinkInterface $secondLink
40+
* @return int
41+
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
42+
*/
43+
private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink)
44+
{
45+
return ($firstLink->getSortOrder() < $secondLink->getSortOrder());
46+
}
47+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Block\Account;
8+
9+
/**
10+
* Class for sortable links.
11+
*/
12+
class SortLink extends \Magento\Framework\View\Element\Html\Link\Current implements SortLinkInterface
13+
{
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function getSortOrder()
18+
{
19+
return $this->getData(self::SORT_ORDER);
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Block\Account;
8+
9+
/**
10+
* Interface for sortable links.
11+
* @api
12+
*/
13+
interface SortLinkInterface
14+
{
15+
/**#@+
16+
* Constant for confirmation status
17+
*/
18+
const SORT_ORDER = 'sortOrder';
19+
/**#@-*/
20+
21+
/**
22+
* Get sort order for block.
23+
*
24+
* @return int
25+
*/
26+
public function getSortOrder();
27+
}

0 commit comments

Comments
 (0)