Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #18207: [Forwardport] Make sure all linked products (related, upsells, crosss� (by @hostep)
 - #18205: [Forwardport] Fix module uninstall shell command and composer removal w/out regression (by @mage2pratik)
 - #18122: Update db schema comments (by @hryvinskyi)
 - #18211: [Forwardport] [CatalogUrlRewrite] Covering the CategoryProcessUrlRewriteMovingObserver by Unit Test (by @eduard13)
 - #18198: [Forwardport] [remove] rich snippet declaration on grouped product (by @AurelienLavorel)
 - #18202: [Forwardport] Current password autocomplete for admin login (by @mage2pratik)
 - #18203: [Forwardport] [2.2] return $this from setters in Analytics/ReportXml/DB/SelectBuilder.php (by @mage2pratik)
 - #18187: Replace sort callbacks to spaceship operator in vendor files (by @mage2pratik)
 - #17685: Replacing deprecated methods from Magento_Backend module. (by @tiagosampaio)
 - #18141: [Forwardport] Update time12h javascript validation rule to be compatible with js minify (by @mage2pratik)
 - magento-engcom/magento2ce#2159: #18009: [Forwardport] Cannot create a numeric value attribute option using the REST API. (by @p-bystritsky)
 - #16351: Magento_Sales integration tests: Fix addresses in order_list fixture (by @evktalo)


Fixed GitHub Issues:
 - #13720: Only 2 related products are showing in backend . (reported by @dipind4u) has been fixed in #18207 by @hostep in 2.3-develop branch
   Related commits:
     1. 74e1ea9
     2. d5b6231

 - #14050: Import related products issue (reported by @estellehuang) has been fixed in #18207 by @hostep in 2.3-develop branch
   Related commits:
     1. 74e1ea9
     2. d5b6231

 - #5797: [2.1.0] module:uninstall can remove code it uses itself (reported by @hostep) has been fixed in #18205 by @mage2pratik in 2.3-develop branch
   Related commits:
     1. 8b9fff5
     2. fa4289f

 - #17780: Module uninstall does not work with composer (reported by @Thundar) has been fixed in #18205 by @mage2pratik in 2.3-develop branch
   Related commits:
     1. 8b9fff5
     2. fa4289f

 - #18009: Cannot create a numeric value attribute option using the REST API (reported by @sidm) has been fixed in magento-engcom/magento2ce#2159 by @p-bystritsky in 2.3-develop branch
   Related commits:
     1. 3b9e963
  • Loading branch information
Stanislav Idolov committed Sep 26, 2018
2 parents 76e18b9 + fc350e8 commit ab5c07d
Show file tree
Hide file tree
Showing 34 changed files with 462 additions and 220 deletions.
33 changes: 25 additions & 8 deletions app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* Responsible for Select object creation, works as a builder. Returns Select as result;
*
* Used in SQL assemblers.
*/
class SelectBuilder
Expand Down Expand Up @@ -85,11 +86,13 @@ public function getJoins()
* Set joins conditions
*
* @param array $joins
* @return void
* @return $this
*/
public function setJoins($joins)
{
$this->joins = $joins;

return $this;
}

/**
Expand All @@ -106,11 +109,13 @@ public function getConnectionName()
* Set connection name
*
* @param string $connectionName
* @return void
* @return $this
*/
public function setConnectionName($connectionName)
{
$this->connectionName = $connectionName;

return $this;
}

/**
Expand All @@ -127,11 +132,13 @@ public function getColumns()
* Set columns
*
* @param array $columns
* @return void
* @return $this
*/
public function setColumns($columns)
{
$this->columns = $columns;

return $this;
}

/**
Expand All @@ -148,11 +155,13 @@ public function getFilters()
* Set filters
*
* @param array $filters
* @return void
* @return $this
*/
public function setFilters($filters)
{
$this->filters = $filters;

return $this;
}

/**
Expand All @@ -169,11 +178,13 @@ public function getFrom()
* Set from condition
*
* @param array $from
* @return void
* @return $this
*/
public function setFrom($from)
{
$this->from = $from;

return $this;
}

/**
Expand Down Expand Up @@ -236,11 +247,13 @@ public function getGroup()
* Set group
*
* @param array $group
* @return void
* @return $this
*/
public function setGroup($group)
{
$this->group = $group;

return $this;
}

/**
Expand All @@ -257,11 +270,13 @@ public function getParams()
* Set parameters
*
* @param array $params
* @return void
* @return $this
*/
public function setParams($params)
{
$this->params = $params;

return $this;
}

/**
Expand All @@ -278,10 +293,12 @@ public function getHaving()
* Set having condition
*
* @param array $having
* @return void
* @return $this
*/
public function setHaving($having)
{
$this->having = $having;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public function testCreate()
['link-type' => 'right', 'table' => 'attribute', 'condition' => 'neq'],
];
$groups = ['id', 'name'];
$this->selectBuilder->setConnectionName($connectionName);
$this->selectBuilder->setFrom($from);
$this->selectBuilder->setColumns($columns);
$this->selectBuilder->setFilters([$filter]);
$this->selectBuilder->setJoins($joins);
$this->selectBuilder->setGroup($groups);
$this->selectBuilder->setConnectionName($connectionName)
->setFrom($from)
->setColumns($columns)
->setFilters([$filter])
->setJoins($joins)
->setGroup($groups);
$this->resourceConnectionMock->expects($this->once())
->method('getConnection')
->with($connectionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
data-validate="{required:true}"
value=""
placeholder="<?= /* @escapeNotVerified */ __('password') ?>"
autocomplete="new-password"
autocomplete="off"
/>
</div>
</div>
Expand Down
38 changes: 19 additions & 19 deletions app/code/Magento/Bundle/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
<table name="catalog_product_bundle_price_index" resource="default" engine="innodb"
comment="Catalog Product Bundle Price Index">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
<column xsi:type="int" name="customer_group_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Customer Group Id"/>
comment="Customer Group ID"/>
<column xsi:type="decimal" name="min_price" scale="4" precision="12" unsigned="false" nullable="false"
comment="Min Price"/>
<column xsi:type="decimal" name="max_price" scale="4" precision="12" unsigned="false" nullable="false"
Expand Down Expand Up @@ -153,11 +153,11 @@
<table name="catalog_product_bundle_stock_index" resource="default" engine="innodb"
comment="Catalog Product Bundle Stock Index">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="smallint" name="stock_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Stock Id"/>
comment="Stock ID"/>
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Option Id"/>
<column xsi:type="smallint" name="stock_status" padding="6" unsigned="false" nullable="true" identity="false"
Expand All @@ -172,13 +172,13 @@
<table name="catalog_product_index_price_bundle_idx" resource="default" engine="innodb"
comment="Catalog Product Index Price Bundle Idx">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="int" name="customer_group_id" padding="11" unsigned="false" nullable="false"
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="smallint" name="tax_class_id" padding="5" unsigned="true" nullable="true" identity="false"
default="0" comment="Tax Class Id"/>
default="0" comment="Tax Class ID"/>
<column xsi:type="smallint" name="price_type" padding="5" unsigned="true" nullable="false" identity="false"
comment="Price Type"/>
<column xsi:type="decimal" name="special_price" scale="4" precision="12" unsigned="false" nullable="true"
Expand Down Expand Up @@ -206,13 +206,13 @@
<table name="catalog_product_index_price_bundle_tmp" resource="default" engine="memory"
comment="Catalog Product Index Price Bundle Tmp">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="int" name="customer_group_id" padding="11" unsigned="false" nullable="false"
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="smallint" name="tax_class_id" padding="5" unsigned="true" nullable="true" identity="false"
default="0" comment="Tax Class Id"/>
default="0" comment="Tax Class ID"/>
<column xsi:type="smallint" name="price_type" padding="5" unsigned="true" nullable="false" identity="false"
comment="Price Type"/>
<column xsi:type="decimal" name="special_price" scale="4" precision="12" unsigned="false" nullable="true"
Expand Down Expand Up @@ -240,11 +240,11 @@
<table name="catalog_product_index_price_bundle_sel_idx" resource="default" engine="innodb"
comment="Catalog Product Index Price Bundle Sel Idx">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="int" name="customer_group_id" padding="11" unsigned="false" nullable="false"
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Option Id"/>
<column xsi:type="int" name="selection_id" padding="10" unsigned="true" nullable="false" identity="false"
Expand All @@ -268,11 +268,11 @@
<table name="catalog_product_index_price_bundle_sel_tmp" resource="default" engine="memory"
comment="Catalog Product Index Price Bundle Sel Tmp">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="int" name="customer_group_id" padding="11" unsigned="false" nullable="false"
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Option Id"/>
<column xsi:type="int" name="selection_id" padding="10" unsigned="true" nullable="false" identity="false"
Expand All @@ -296,11 +296,11 @@
<table name="catalog_product_index_price_bundle_opt_idx" resource="default" engine="innodb"
comment="Catalog Product Index Price Bundle Opt Idx">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="int" name="customer_group_id" padding="11" unsigned="false" nullable="false"
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Option Id"/>
<column xsi:type="decimal" name="min_price" scale="4" precision="12" unsigned="false" nullable="true"
Expand All @@ -323,11 +323,11 @@
<table name="catalog_product_index_price_bundle_opt_tmp" resource="default" engine="memory"
comment="Catalog Product Index Price Bundle Opt Tmp">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false"
comment="Entity Id"/>
comment="Entity ID"/>
<column xsi:type="int" name="customer_group_id" padding="11" unsigned="false" nullable="false"
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Website Id"/>
comment="Website ID"/>
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Option Id"/>
<column xsi:type="decimal" name="min_price" scale="4" precision="12" unsigned="false" nullable="true"
Expand Down
25 changes: 13 additions & 12 deletions app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Magento\Catalog\Model\ProductLink\Converter\ConverterPool;
use Magento\Framework\Exception\NoSuchEntityException;

/**
* Provides a collection of linked product items (crosssells, related, upsells, ...)
*/
class CollectionProvider
{
/**
Expand Down Expand Up @@ -47,22 +50,20 @@ public function getCollection(\Magento\Catalog\Model\Product $product, $type)

$products = $this->providers[$type]->getLinkedProducts($product);
$converter = $this->converterPool->getConverter($type);
$output = [];
$sorterItems = [];
foreach ($products as $item) {
$output[$item->getId()] = $converter->convert($item);
$itemId = $item->getId();
$sorterItems[$itemId] = $converter->convert($item);
$sorterItems[$itemId]['position'] = $sorterItems[$itemId]['position'] ?? 0;
}

foreach ($output as $item) {
$itemPosition = $item['position'];
if (!isset($sorterItems[$itemPosition])) {
$sorterItems[$itemPosition] = $item;
} else {
$newPosition = $itemPosition + 1;
$sorterItems[$newPosition] = $item;
}
}
ksort($sorterItems);
usort($sorterItems, function ($itemA, $itemB) {
$posA = intval($itemA['position']);
$posB = intval($itemB['position']);

return $posA <=> $posB;
});

return $sorterItems;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ public function testGetCollection()
$linkedProductOneMock = $this->createMock(Product::class);
$linkedProductTwoMock = $this->createMock(Product::class);
$linkedProductThreeMock = $this->createMock(Product::class);
$linkedProductFourMock = $this->createMock(Product::class);
$linkedProductFiveMock = $this->createMock(Product::class);

$linkedProductOneMock->expects($this->once())->method('getId')->willReturn(1);
$linkedProductTwoMock->expects($this->once())->method('getId')->willReturn(2);
$linkedProductThreeMock->expects($this->once())->method('getId')->willReturn(3);
$linkedProductFourMock->expects($this->once())->method('getId')->willReturn(4);
$linkedProductFiveMock->expects($this->once())->method('getId')->willReturn(5);

$this->converterPoolMock->expects($this->once())
->method('getConverter')
Expand All @@ -71,9 +75,11 @@ public function testGetCollection()
[$linkedProductOneMock, ['name' => 'Product One', 'position' => 10]],
[$linkedProductTwoMock, ['name' => 'Product Two', 'position' => 2]],
[$linkedProductThreeMock, ['name' => 'Product Three', 'position' => 2]],
[$linkedProductFourMock, ['name' => 'Product Four', 'position' => null]],
[$linkedProductFiveMock, ['name' => 'Product Five']],
];

$this->converterMock->expects($this->exactly(3))->method('convert')->willReturnMap($map);
$this->converterMock->expects($this->exactly(5))->method('convert')->willReturnMap($map);

$this->providerMock->expects($this->once())
->method('getLinkedProducts')
Expand All @@ -82,14 +88,18 @@ public function testGetCollection()
[
$linkedProductOneMock,
$linkedProductTwoMock,
$linkedProductThreeMock
$linkedProductThreeMock,
$linkedProductFourMock,
$linkedProductFiveMock,
]
);

$expectedResult = [
2 => ['name' => 'Product Two', 'position' => 2],
3 => ['name' => 'Product Three', 'position' => 2],
10 => ['name' => 'Product One', 'position' => 10],
0 => ['name' => 'Product Four', 'position' => 0],
1 => ['name' => 'Product Five', 'position' => 0],
2 => ['name' => 'Product Three', 'position' => 2],
3 => ['name' => 'Product Two', 'position' => 2],
4 => ['name' => 'Product One', 'position' => 10],
];

$actualResult = $this->model->getCollection($this->productMock, 'crosssell');
Expand Down
Loading

0 comments on commit ab5c07d

Please sign in to comment.