Skip to content

Commit 1a5286d

Browse files
committed
MAGETWO-52124: Simple product special price lost if use it in grouped product
1 parent 19181c3 commit 1a5286d

File tree

2 files changed

+79
-1
lines changed
  • app/code/Magento/GroupedProduct/Model/Product/Type
  • dev/tests/integration/testsuite/Magento/GroupedProduct/Pricing/Price

2 files changed

+79
-1
lines changed

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']
205+
['name', 'price', 'special_price', 'special_from_date', 'special_to_date']
206206
)->addFilterByRequiredOptions()->setPositionOrder()->addStoreFilter(
207207
$this->getStoreFilter($product)
208208
)->addAttributeToFilter(
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace testsuite\Magento\GroupedProduct\Pricing\Price;
8+
9+
use Magento\Catalog\Api\Data\ProductTierPriceInterface;
10+
use Magento\GroupedProduct\Pricing\Price\FinalPrice;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
class FinalPriceTest extends \PHPUnit_Framework_TestCase
14+
{
15+
/**
16+
* @magentoDataFixture Magento/GroupedProduct/_files/product_grouped.php
17+
* @magentoAppIsolation enabled
18+
*/
19+
public function testFinalPrice()
20+
{
21+
$productRepository = Bootstrap::getObjectManager()
22+
->get('\Magento\Catalog\Api\ProductRepositoryInterface');
23+
/** @var $product \Magento\Catalog\Model\Product */
24+
$product = $productRepository->get('grouped-product');
25+
26+
$this->assertEquals(10, $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
27+
}
28+
29+
/**
30+
* @magentoDataFixture Magento/GroupedProduct/_files/product_grouped.php
31+
* @magentoAppIsolation enabled
32+
*/
33+
public function testFinalPriceWithTearPrice()
34+
{
35+
$productRepository = Bootstrap::getObjectManager()
36+
->get('\Magento\Catalog\Api\ProductRepositoryInterface');
37+
/** @var ProductTierPriceInterface $tierPrice */
38+
$tierPrice = Bootstrap::getObjectManager()->create(ProductTierPriceInterface::class);
39+
$tierPrice->setQty(1);
40+
$tierPrice->setCustomerGroupId(\Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL);
41+
$tierPrice->setValue(5);
42+
43+
44+
/** @var $simpleProduct \Magento\Catalog\Api\Data\ProductInterface */
45+
$simpleProduct = $productRepository->get('simple');
46+
$simpleProduct->setTierPrices([
47+
$tierPrice
48+
]);
49+
$productRepository->save($simpleProduct);
50+
51+
52+
/** @var $product \Magento\Catalog\Model\Product */
53+
$product = $productRepository->get('grouped-product');
54+
$this->assertEquals(5, $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
55+
}
56+
57+
/**
58+
* @magentoDataFixture Magento/GroupedProduct/_files/product_grouped.php
59+
* @magentoAppIsolation enabled
60+
*/
61+
public function testFinalPriceWithSpecialPrice()
62+
{
63+
$productRepository = Bootstrap::getObjectManager()
64+
->get('\Magento\Catalog\Api\ProductRepositoryInterface');
65+
66+
67+
68+
/** @var $simpleProduct \Magento\Catalog\Api\Data\ProductInterface */
69+
$simpleProduct = $productRepository->get('simple');
70+
$simpleProduct->setCustomAttribute('special_price', 6);
71+
$productRepository->save($simpleProduct);
72+
73+
74+
/** @var $product \Magento\Catalog\Model\Product */
75+
$product = $productRepository->get('grouped-product');
76+
$this->assertEquals(6, $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
77+
}
78+
}

0 commit comments

Comments
 (0)