Skip to content

Commit fa99b34

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-69496: Impossible specify Bundle option title on store view level with changes to more than one store view
1 parent f5ed165 commit fa99b34

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Bundle\Model\Product;
8+
9+
/**
10+
* Test class for \Magento\Bundle\Model\Product\SaveHandler
11+
* The tested class used indirectly
12+
*
13+
* @magentoDataFixture Magento/Bundle/_files/product.php
14+
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
15+
* @magentoDbIsolation enabled
16+
* @magentoAppIsolation enabled
17+
*/
18+
class SaveHandlerTest extends \PHPUnit_Framework_TestCase
19+
{
20+
/**
21+
* @var \Magento\Framework\ObjectManagerInterface
22+
*/
23+
private $objectManager;
24+
25+
/**
26+
* @var \Magento\Store\Model\Store
27+
*/
28+
private $store;
29+
30+
/**
31+
* @var \Magento\Catalog\Api\ProductRepositoryInterface
32+
*/
33+
private $productRepository;
34+
35+
protected function setUp()
36+
{
37+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
38+
$this->store = $this->objectManager->create(\Magento\Store\Model\Store::class);
39+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
40+
$this->productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
41+
}
42+
43+
public function testOptionTitlesOnDifferentStores() {
44+
/**
45+
* @var \Magento\Bundle\Model\Product\OptionList $optionList
46+
*/
47+
$optionList = $this->objectManager->create('\Magento\Bundle\Model\Product\OptionList');
48+
49+
$secondStoreId = $this->store->load('fixture_second_store')->getId();
50+
$thirdStoreId = $this->store->load('fixture_third_store')->getId();
51+
52+
$product = $this->productRepository->get('bundle-product', true, $secondStoreId, true);
53+
$options = $optionList->getItems($product);
54+
$title = $options[0]->getTitle();
55+
$newTitle = $title . ' ' . $this->store->load('fixture_second_store')->getCode();
56+
$options[0]->setTitle($newTitle);
57+
$extension = $product->getExtensionAttributes();
58+
$extension->setBundleProductOptions($options);
59+
$product->setExtensionAttributes($extension);
60+
$product->save();
61+
62+
$product = $this->productRepository->get('bundle-product', true, $thirdStoreId, true);
63+
$options = $optionList->getItems($product);
64+
$newTitle = $title . ' ' . $this->store->load('fixture_third_store')->getCode();
65+
$options[0]->setTitle($newTitle);
66+
$extension = $product->getExtensionAttributes();
67+
$extension->setBundleProductOptions($options);
68+
$product->setExtensionAttributes($extension);
69+
$product->save();
70+
71+
$product = $this->productRepository->get('bundle-product', false, $secondStoreId, true);
72+
$options = $optionList->getItems($product);
73+
$this->assertEquals(1, count($options));
74+
$this->assertEquals(
75+
$title . ' ' . $this->store->load('fixture_second_store')->getCode(),
76+
$options[0]->getTitle()
77+
);
78+
}
79+
}

0 commit comments

Comments
 (0)