Skip to content

Commit

Permalink
Merge pull request #504 from magento-troll/sprint21
Browse files Browse the repository at this point in the history
MAGETWO-51655 [Improvement] Convert customer group identifier field from SMALLINT to INT
  • Loading branch information
rganin authored Oct 20, 2016
2 parents cbe29b0 + f659682 commit 0c6227d
Show file tree
Hide file tree
Showing 44 changed files with 654 additions and 81 deletions.
6 changes: 4 additions & 2 deletions app/code/Magento/Bundle/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$installer = $setup;

$installer->startSetup();

$customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group'));
$customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int'
? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE'];
/**
* Create table 'catalog_product_bundle_option'
*/
Expand Down Expand Up @@ -340,7 +342,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)
->addColumn(
'customer_group_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
$customerGroupIdType,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true],
'Customer Group Id'
Expand Down
18 changes: 18 additions & 0 deletions app/code/Magento/Bundle/Setup/UpgradeSchema.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}
}

if (version_compare($context->getVersion(), '2.0.3', '<')) {
$tables = [
'catalog_product_index_price_bundle_idx',
'catalog_product_index_price_bundle_opt_idx',
'catalog_product_index_price_bundle_opt_tmp',
'catalog_product_index_price_bundle_sel_idx',
'catalog_product_index_price_bundle_sel_tmp',
'catalog_product_index_price_bundle_tmp',
];
foreach ($tables as $table) {
$setup->getConnection()->modifyColumn(
$setup->getTable($table),
'customer_group_id',
['type' => 'integer', 'nullable' => false]
);
}
}

$setup->endSetup();
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Bundle/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Bundle" setup_version="2.0.2">
<module name="Magento_Bundle" setup_version="2.0.3">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down
9 changes: 6 additions & 3 deletions app/code/Magento/Catalog/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$installer->getConnection()
->createTable($table);

$customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group'));
$customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int'
? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE'];
/**
* Create table 'catalog_product_entity_tier_price'
*/
Expand Down Expand Up @@ -1883,7 +1886,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)
->addColumn(
'customer_group_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
$customerGroupIdType,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Customer Group ID'
Expand Down Expand Up @@ -2937,7 +2940,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)
->addColumn(
'customer_group_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
$customerGroupIdType,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true],
'Customer Group ID'
Expand Down Expand Up @@ -3056,7 +3059,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)
->addColumn(
'customer_group_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
$customerGroupIdType,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true],
'Customer Group ID'
Expand Down
25 changes: 25 additions & 0 deletions app/code/Magento/Catalog/Setup/UpgradeSchema.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
if (version_compare($context->getVersion(), '2.1.0', '<')) {
$this->addPercentageValueColumn($setup);
}

if (version_compare($context->getVersion(), '2.1.1', '<')) {
$tables = [
'catalog_product_index_price_cfg_opt_agr_idx',
'catalog_product_index_price_cfg_opt_agr_tmp',
'catalog_product_index_price_cfg_opt_idx',
'catalog_product_index_price_cfg_opt_tmp',
'catalog_product_index_price_final_idx',
'catalog_product_index_price_final_tmp',
'catalog_product_index_price_idx',
'catalog_product_index_price_opt_agr_idx',
'catalog_product_index_price_opt_agr_tmp',
'catalog_product_index_price_opt_idx',
'catalog_product_index_price_opt_tmp',
'catalog_product_index_price_tmp',
];
foreach ($tables as $table) {
$setup->getConnection()->modifyColumn(
$setup->getTable($table),
'customer_group_id',
['type' => 'integer', 'nullable' => false]
);
}
}

$setup->endSetup();
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Catalog" setup_version="2.1.0">
<module name="Magento_Catalog" setup_version="2.1.1">
<sequence>
<module name="Magento_Eav"/>
<module name="Magento_Cms"/>
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/CatalogRule/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con

$installer->startSetup();

$customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group'));
$customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int'
? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE'];
/**
* Create table 'catalogrule'
*/
Expand Down Expand Up @@ -372,7 +375,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)
->addColumn(
'customer_group_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
$customerGroupIdType,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
'Customer Group Id'
Expand Down Expand Up @@ -477,7 +480,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)
->addColumn(
'customer_group_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
$customerGroupIdType,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true],
'Customer Group Id'
Expand Down
14 changes: 14 additions & 0 deletions app/code/Magento/CatalogRule/Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
$this->removeSubProductDiscounts($setup);
}

if (version_compare($context->getVersion(), '2.0.2', '<')) {
$tables = [
'catalogrule_product',
'catalogrule_product_price',
];
foreach ($tables as $table) {
$setup->getConnection()->modifyColumn(
$setup->getTable($table),
'customer_group_id',
['type' => 'integer']
);
}
}

$setup->endSetup();
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogRule/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_CatalogRule" setup_version="2.0.1">
<module name="Magento_CatalogRule" setup_version="2.0.2">
<sequence>
<module name="Magento_Rule"/>
<module name="Magento_Catalog"/>
Expand Down
11 changes: 10 additions & 1 deletion app/code/Magento/Customer/Block/Account/AuthorizationLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
namespace Magento\Customer\Block\Account;

use Magento\Customer\Model\Context;
use Magento\Customer\Block\Account\SortLinkInterface;

/**
* Customer authorization link
*
* @SuppressWarnings(PHPMD.DepthOfInheritance)
*/
class AuthorizationLink extends \Magento\Framework\View\Element\Html\Link
class AuthorizationLink extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface
{
/**
* Customer session
Expand Down Expand Up @@ -88,4 +89,12 @@ public function isLoggedIn()
{
return $this->httpContext->getValue(Context::CONTEXT_AUTH);
}

/**
* {@inheritdoc}
*/
public function getSortOrder()
{
return $this->getData(self::SORT_ORDER);
}
}
21 changes: 21 additions & 0 deletions app/code/Magento/Customer/Block/Account/Delimiter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Block\Account;

/**
* Class for delimiter.
*/
class Delimiter extends \Magento\Framework\View\Element\Template implements SortLinkInterface
{
/**
* {@inheritdoc}
*/
public function getSortOrder()
{
return $this->getData(self::SORT_ORDER);
}
}
12 changes: 11 additions & 1 deletion app/code/Magento/Customer/Block/Account/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
*/
namespace Magento\Customer\Block\Account;

use Magento\Customer\Block\Account\SortLinkInterface;

/**
* Class Link
*
* @SuppressWarnings(PHPMD.DepthOfInheritance)
*/
class Link extends \Magento\Framework\View\Element\Html\Link
class Link extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface
{
/**
* @var \Magento\Customer\Model\Url
Expand Down Expand Up @@ -38,4 +40,12 @@ public function getHref()
{
return $this->_customerUrl->getAccountUrl();
}

/**
* {@inheritdoc}
*/
public function getSortOrder()
{
return $this->getData(self::SORT_ORDER);
}
}
47 changes: 47 additions & 0 deletions app/code/Magento/Customer/Block/Account/Navigation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Block\Account;

use \Magento\Framework\View\Element\Html\Links;
use \Magento\Customer\Block\Account\SortLinkInterface;

/**
* Class for sorting links in navigation panels.
*/
class Navigation extends Links
{
/**
* {@inheritdoc}
*/
public function getLinks()
{
$links = $this->_layout->getChildBlocks($this->getNameInLayout());
$sortableLink = [];
foreach ($links as $key => $link) {
if ($link instanceof SortLinkInterface) {
$sortableLink[] = $link;
unset($links[$key]);
}
}

usort($sortableLink, [$this, "compare"]);
return array_merge($sortableLink, $links);
}

/**
* Compare sortOrder in links.
*
* @param SortLinkInterface $firstLink
* @param SortLinkInterface $secondLink
* @return int
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink)
{
return ($firstLink->getSortOrder() < $secondLink->getSortOrder());
}
}
21 changes: 21 additions & 0 deletions app/code/Magento/Customer/Block/Account/SortLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Block\Account;

/**
* Class for sortable links.
*/
class SortLink extends \Magento\Framework\View\Element\Html\Link\Current implements SortLinkInterface
{
/**
* {@inheritdoc}
*/
public function getSortOrder()
{
return $this->getData(self::SORT_ORDER);
}
}
27 changes: 27 additions & 0 deletions app/code/Magento/Customer/Block/Account/SortLinkInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Block\Account;

/**
* Interface for sortable links.
* @api
*/
interface SortLinkInterface
{
/**#@+
* Constant for confirmation status
*/
const SORT_ORDER = 'sortOrder';
/**#@-*/

/**
* Get sort order for block.
*
* @return int
*/
public function getSortOrder();
}
Loading

0 comments on commit 0c6227d

Please sign in to comment.