Skip to content

Commit 165dc27

Browse files
committed
MAGETWO-52124: Simple product special price lost if use it in grouped product
1 parent 33ab2f8 commit 165dc27

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\GroupedProduct\Setup;
7+
8+
use Magento\Catalog\Model\ResourceModel\Product\Relation;
9+
use Magento\Framework\DB\Adapter\AdapterInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Framework\Setup\UpgradeDataInterface;
13+
use Magento\GroupedProduct\Model\ResourceModel\Product\Link;
14+
15+
class UpgradeData implements UpgradeDataInterface
16+
{
17+
/**
18+
* @var Relation
19+
*/
20+
private $relationProcessor;
21+
22+
/**
23+
* UpgradeData constructor
24+
* @param Relation $relationProcessor
25+
*/
26+
public function __construct(Relation $relationProcessor)
27+
{
28+
$this->relationProcessor = $relationProcessor;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
35+
{
36+
$setup->startSetup();
37+
38+
if (version_compare($context->getVersion(), '2.0.1', '<')) {
39+
$connection = $setup->getConnection();
40+
$select = $connection->select()
41+
->from(
42+
$this->relationProcessor->getTable('catalog_product_link'),
43+
['product_id', 'linked_product_id']
44+
)
45+
->where('link_type_id = ?', Link::LINK_TYPE_GROUPED);
46+
47+
$connection->query(
48+
$connection->insertFromSelect(
49+
$select, $this->relationProcessor->getMainTable(),
50+
['parent_id', 'child_id'],
51+
AdapterInterface::INSERT_IGNORE
52+
)
53+
);
54+
}
55+
56+
$setup->endSetup();
57+
}
58+
}

app/code/Magento/GroupedProduct/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_GroupedProduct" setup_version="2.0.0">
9+
<module name="Magento_GroupedProduct" setup_version="2.0.1">
1010
<sequence>
1111
<module name="Magento_Catalog"/>
1212
<module name="Magento_CatalogInventory"/>

0 commit comments

Comments
 (0)