Skip to content

Commit 0da0b13

Browse files
authored
Merge pull request #678 from magento-nord/NORD-PR
Bugs fixed: * MAGETWO-33564: [GitHub] Database Schema: Incorrect Unique Indexes #1002 * MAGETWO-56095: When category has products that are not visible to catalog the pager still shows is this expected behavior? * MAGETWO-59649: Current store resolver does not work for global scope * MAGETWO-60962: New attribute is not visible when create new address * MAGETWO-55937: [Complex product/Grouped productsl] Tax Amount and Custom Prices isn't displayed on Slide Panel (admin panel)
2 parents 2e22823 + 68928b3 commit 0da0b13

File tree

22 files changed

+603
-58
lines changed

22 files changed

+603
-58
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ public function isIndexable()
417417
if ($this->getAttributeCode() == 'price') {
418418
return false;
419419
}
420+
if ($this->getAttributeCode() == 'visibility') {
421+
return true;
422+
}
420423

421424
if (!$this->getIsFilterableInSearch() && !$this->getIsVisibleInAdvancedSearch() && !$this->getIsFilterable()) {
422425
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
254254
->addIndex(
255255
$installer->getIdxName(
256256
'cataloginventory_stock_item',
257-
['product_id', 'website_id'],
257+
['product_id', 'stock_id'],
258258
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
259259
),
260-
['product_id', 'website_id'],
260+
['product_id', 'stock_id'],
261261
['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
262262
)
263263
->addIndex(
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogInventory\Setup;
8+
9+
use Magento\Framework\Setup\UpgradeSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
use Magento\CatalogInventory\Model\Stock\Item as StockItem;
13+
14+
class UpgradeSchema implements UpgradeSchemaInterface
15+
{
16+
/**
17+
* @var string
18+
*/
19+
private $productCompositeKeyVersion = '2.2.0';
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
25+
{
26+
$setup->startSetup();
27+
28+
if (version_compare($context->getVersion(), $this->productCompositeKeyVersion, '<')) {
29+
$this->upgradeProductCompositeKey($setup);
30+
}
31+
32+
$setup->endSetup();
33+
}
34+
35+
/**
36+
* @param SchemaSetupInterface $setup
37+
* @return void
38+
*/
39+
private function upgradeProductCompositeKey(SchemaSetupInterface $setup)
40+
{
41+
$oldCompositeKeyColumns = ['product_id', 'website_id'];
42+
$newCompositeKeyColumns = ['product_id', 'stock_id'];
43+
44+
$foreignKeys = $this->getForeignKeys($setup, $oldCompositeKeyColumns);
45+
// drop foreign keys
46+
$this->dropForeignKeys($setup, $foreignKeys);
47+
48+
$oldIndexName = $setup->getIdxName(
49+
$setup->getTable(StockItem::ENTITY),
50+
$oldCompositeKeyColumns,
51+
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
52+
);
53+
54+
$newIndexName = $setup->getIdxName(
55+
$setup->getTable(StockItem::ENTITY),
56+
$newCompositeKeyColumns,
57+
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
58+
);
59+
60+
// Drop a key based on the following columns: "product_id","website_id"
61+
$setup->getConnection()->dropIndex($setup->getTable(StockItem::ENTITY), $oldIndexName);
62+
63+
// Create a key based on the following columns: "product_id","stock_id"
64+
$setup->getConnection()
65+
->addIndex(
66+
$setup->getTable(StockItem::ENTITY),
67+
$newIndexName,
68+
$newCompositeKeyColumns,
69+
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
70+
);
71+
// restore deleted foreign keys
72+
$this->createForeignKeys($setup, $foreignKeys);
73+
}
74+
75+
/**
76+
* @param SchemaSetupInterface $setup
77+
* @param array $keys
78+
* @return void
79+
*/
80+
private function dropForeignKeys(SchemaSetupInterface $setup, array $keys)
81+
{
82+
foreach ($keys as $key) {
83+
$setup->getConnection()->dropForeignKey($key['TABLE_NAME'], $key['FK_NAME']);
84+
}
85+
}
86+
87+
/**
88+
* @param SchemaSetupInterface $setup
89+
* @param array $keys
90+
* @return void
91+
*/
92+
private function createForeignKeys(SchemaSetupInterface $setup, array $keys)
93+
{
94+
foreach ($keys as $key) {
95+
$setup->getConnection()->addForeignKey(
96+
$key['FK_NAME'],
97+
$key['TABLE_NAME'],
98+
$key['COLUMN_NAME'],
99+
$key['REF_TABLE_NAME'],
100+
$key['REF_COLUMN_NAME'],
101+
$key['ON_DELETE']
102+
);
103+
}
104+
}
105+
106+
/**
107+
* @param SchemaSetupInterface $setup
108+
* @param array $compositeKeys
109+
* @return array
110+
*/
111+
private function getForeignKeys(SchemaSetupInterface $setup, array $compositeKeys)
112+
{
113+
$foreignKeys = [];
114+
$allForeignKeys = $setup->getConnection()->getForeignKeys($setup->getTable(StockItem::ENTITY));
115+
foreach ($allForeignKeys as $key) {
116+
if (in_array($key['COLUMN_NAME'], $compositeKeys)) {
117+
$foreignKeys[] = $key;
118+
}
119+
}
120+
121+
return $foreignKeys;
122+
}
123+
}

app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
<!-- /ko --><br/>
1616
<!-- ko foreach: { data: currentBillingAddress().customAttributes, as: 'element' } -->
1717
<!-- ko foreach: { data: Object.keys(element), as: 'attribute' } -->
18-
<!-- ko text: element[attribute].value --><!-- /ko -->
18+
<!-- ko if: (typeof element[attribute] === "object") -->
19+
<!-- ko text: element[attribute].value --><!-- /ko -->
20+
<!-- /ko -->
21+
<!-- ko if: (typeof element[attribute] === "string") -->
22+
<!-- ko text: element[attribute] --><!-- /ko -->
23+
<!-- /ko --><br/>
1924
<!-- /ko -->
2025
<!-- /ko -->
2126
<button type="button"

app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
<!-- /ko --><br/>
1616
<!-- ko foreach: { data: address().customAttributes, as: 'element' } -->
1717
<!-- ko foreach: { data: Object.keys(element), as: 'attribute' } -->
18-
<!-- ko text: element[attribute].value --><!-- /ko -->
18+
<!-- ko if: (typeof element[attribute] === "object") -->
19+
<!-- ko text: element[attribute].value --><!-- /ko -->
20+
<!-- /ko -->
21+
<!-- ko if: (typeof element[attribute] === "string") -->
22+
<!-- ko text: element[attribute] --><!-- /ko -->
23+
<!-- /ko --><br/>
1924
<!-- /ko -->
2025
<!-- /ko -->
2126
<!-- ko if: (address().isEditable()) -->

app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
<!-- /ko --><br/>
1616
<!-- ko foreach: { data: address().customAttributes, as: 'element' } -->
1717
<!-- ko foreach: { data: Object.keys(element), as: 'attribute' } -->
18-
<!-- ko text: element[attribute].value --><!-- /ko -->
18+
<!-- ko if: (typeof element[attribute] === "object") -->
19+
<!-- ko text: element[attribute].value --><!-- /ko -->
20+
<!-- /ko -->
21+
<!-- ko if: (typeof element[attribute] === "string") -->
22+
<!-- ko text: element[attribute] --><!-- /ko -->
23+
<!-- /ko --><br/>
1924
<!-- /ko -->
2025
<!-- /ko -->
2126
<!-- /ko -->

app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function getAssociatedProducts($product)
202202
$collection = $this->getAssociatedProductCollection(
203203
$product
204204
)->addAttributeToSelect(
205-
['name', 'price', 'special_price', 'special_from_date', 'special_to_date']
205+
['name', 'price', 'special_price', 'special_from_date', 'special_to_date', 'tax_class_id']
206206
)->addFilterByRequiredOptions()->setPositionOrder()->addStoreFilter(
207207
$this->getStoreFilter($product)
208208
)->addAttributeToFilter(

app/code/Magento/Store/Model/StoreManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function isSingleStoreMode()
152152
public function getStore($storeId = null)
153153
{
154154
if (!isset($storeId) || '' === $storeId || $storeId === true) {
155-
if (!$this->currentStoreId) {
155+
if (null === $this->currentStoreId) {
156156
\Magento\Framework\Profiler::start('store.resolve');
157157
$this->currentStoreId = $this->storeResolver->getCurrentStoreId();
158158
\Magento\Framework\Profiler::stop('store.resolve');

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/AddressModal.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,20 @@ public function getErrorMessages()
6565

6666
return $result;
6767
}
68+
69+
/**
70+
* Fixture mapping.
71+
*
72+
* @param array|null $fields
73+
* @param string|null $parent
74+
* @return array
75+
*/
76+
protected function dataMapping(array $fields = null, $parent = null)
77+
{
78+
if (isset($fields['custom_attribute'])) {
79+
$this->placeholders = ['attribute_code' => $fields['custom_attribute']['code']];
80+
$this->applyPlaceholders();
81+
}
82+
return parent::dataMapping($fields, $parent);
83+
}
6884
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/AddressModal.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
</country_id>
2323
<telephone />
2424
<postcode />
25+
<custom_attribute>
26+
<selector>[name="custom_attributes[%attribute_code%]"]</selector>
27+
</custom_attribute>
2528
</fields>
2629
</mapping>

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Edit.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,20 @@ public function saveAddress()
6161
{
6262
$this->_rootElement->find($this->saveAddress)->click();
6363
}
64+
65+
/**
66+
* Fixture mapping.
67+
*
68+
* @param array|null $fields
69+
* @param string|null $parent
70+
* @return array
71+
*/
72+
protected function dataMapping(array $fields = null, $parent = null)
73+
{
74+
if (isset($fields['custom_attribute'])) {
75+
$this->placeholders = ['attribute_code' => $fields['custom_attribute']['code']];
76+
$this->applyPlaceholders();
77+
}
78+
return parent::dataMapping($fields, $parent);
79+
}
6480
}

dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAddressEdit.php

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
9+
<page name="CustomerAddressEdit" mca="customer/address/edit" module="Magento_Customer">
10+
<block name="editForm" class="Magento\Customer\Test\Block\Address\Edit" locator="#form-validate" strategy="css selector" />
11+
</page>
12+
</config>

dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,19 @@ public function fillOptions(FixtureInterface $product)
9494
{
9595
$this->getGroupedProductBlock()->fill($product);
9696
}
97+
98+
/**
99+
* Set quantity and click add to cart.
100+
* @param FixtureInterface $product
101+
* @param string|int $qty
102+
*/
103+
public function setQtyAndClickAddToCartGrouped(FixtureInterface $product, $qty)
104+
{
105+
$associatedProducts = $product->getAssociated()['products'];
106+
$groupedProductBlock = $this->getGroupedProductBlock();
107+
foreach ($associatedProducts as $product) {
108+
$groupedProductBlock->setQty($product->getId(), $qty);
109+
}
110+
$this->clickAddToCart();
111+
}
97112
}

dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Catalog/Product/View/Type/Grouped.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ public function getQty($subProductId)
6565
return $this->_rootElement->find(sprintf($this->qtySubProductById, $subProductId))->getValue();
6666
}
6767

68+
/**
69+
* Set qty to subproduct block
70+
*
71+
* @param int $subProductId
72+
* @param string|int $qty
73+
* @return void
74+
*/
75+
public function setQty($subProductId, $qty)
76+
{
77+
$this->_rootElement->find(sprintf($this->qtySubProductById, $subProductId))->setValue($qty);
78+
}
79+
6880
/**
6981
* Fill product options on view page.
7082
*

0 commit comments

Comments
 (0)