|
12 | 12 | $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
13 | 13 |
|
14 | 14 | /** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */
|
15 |
| -$categoryLinkManagement = $objectManager->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); |
| 15 | +$categoryLinkManagement = $objectManager->get(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); |
16 | 16 |
|
17 | 17 | $tierPrices = [];
|
18 | 18 | /** @var \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory */
|
19 | 19 | $tierPriceFactory = $objectManager->get(\Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class);
|
20 |
| -$tierPrices[] = $tierPriceFactory->create( |
21 |
| - [ |
22 |
| - 'data' => [ |
23 |
| - 'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, |
24 |
| - 'qty' => 2, |
25 |
| - 'value' => 8 |
26 |
| - ] |
27 |
| - ] |
28 |
| -); |
29 |
| -$tierPrices[] = $tierPriceFactory->create( |
30 |
| - [ |
31 |
| - 'data' => [ |
32 |
| - 'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, |
33 |
| - 'qty' => 5, |
34 |
| - 'value' => 5 |
35 |
| - ] |
36 |
| - ] |
37 |
| -); |
38 |
| -$tierPrices[] = $tierPriceFactory->create( |
39 |
| - [ |
40 |
| - 'data' => [ |
41 |
| - 'customer_group_id' => \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID, |
42 |
| - 'qty' => 3, |
43 |
| - 'value' => 5 |
44 |
| - ] |
45 |
| - ] |
46 |
| -); |
47 | 20 | /** @var $tpExtensionAttributes */
|
48 |
| -$tpExtensionAttributesFactory = $objectManager->create(ProductTierPriceExtensionFactory::class); |
49 |
| -$tpExtensionAttributes = $tpExtensionAttributesFactory->create()->setPercentageValue(50); |
| 21 | +$tpExtensionAttributesFactory = $objectManager->get(ProductTierPriceExtensionFactory::class); |
50 | 22 |
|
51 |
| -$tierPrices[] = $tierPriceFactory->create( |
52 |
| - [ |
53 |
| - 'data' => [ |
54 |
| - 'customer_group_id' => \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID, |
55 |
| - 'qty' => 10 |
56 |
| - ] |
57 |
| - ] |
58 |
| -)->setExtensionAttributes($tpExtensionAttributes); |
59 |
| - |
60 |
| -$tierPrices = []; |
61 |
| -/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory */ |
62 |
| -$tierPriceFactory = $objectManager->get(\Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class); |
| 23 | +$adminWebsite = $objectManager->get(\Magento\Store\Api\WebsiteRepositoryInterface::class)->get('admin'); |
| 24 | +$tierPriceWebsiteId = $tpExtensionAttributesFactory->create()->setWebsiteId($adminWebsite->getId()); |
63 | 25 | $tierPrices[] = $tierPriceFactory->create(
|
64 | 26 | [
|
65 | 27 | 'data' => [
|
|
68 | 30 | 'value' => 8
|
69 | 31 | ]
|
70 | 32 | ]
|
71 |
| -); |
| 33 | +)->setExtensionAttributes($tierPriceWebsiteId); |
72 | 34 | $tierPrices[] = $tierPriceFactory->create(
|
73 | 35 | [
|
74 | 36 | 'data' => [
|
|
77 | 39 | 'value' => 5
|
78 | 40 | ]
|
79 | 41 | ]
|
80 |
| -); |
| 42 | +)->setExtensionAttributes($tierPriceWebsiteId); |
81 | 43 | $tierPrices[] = $tierPriceFactory->create(
|
82 | 44 | [
|
83 | 45 | 'data' => [
|
|
86 | 48 | 'value' => 5
|
87 | 49 | ]
|
88 | 50 | ]
|
89 |
| -); |
90 |
| -/** @var $tpExtensionAttributes */ |
91 |
| -$tpExtensionAttributesFactory = $objectManager->create(ProductTierPriceExtensionFactory::class); |
92 |
| -$tpExtensionAttributes = $tpExtensionAttributesFactory->create()->setPercentageValue(50); |
| 51 | +)->setExtensionAttributes($tierPriceWebsiteId); |
| 52 | + |
| 53 | +$tierPricePercentageValue = $tpExtensionAttributesFactory->create() |
| 54 | + ->setPercentageValue(50) |
| 55 | + ->setWebsiteId($adminWebsite->getId()); |
93 | 56 |
|
94 | 57 | $tierPrices[] = $tierPriceFactory->create(
|
95 | 58 | [
|
|
98 | 61 | 'qty' => 10
|
99 | 62 | ]
|
100 | 63 | ]
|
101 |
| -)->setExtensionAttributes($tpExtensionAttributes); |
| 64 | +)->setExtensionAttributes($tierPricePercentageValue); |
102 | 65 |
|
103 | 66 | /** @var $product \Magento\Catalog\Model\Product */
|
104 | 67 | $product = $objectManager->create(\Magento\Catalog\Model\Product::class);
|
|
0 commit comments