8
8
namespace Magento \Catalog \Model \Product \Type ;
9
9
10
10
use Magento \Catalog \Model \Product ;
11
- use Magento \Catalog \Model \Product \Price \TierPriceBuilder ;
12
11
use Magento \Customer \Api \GroupManagementInterface ;
13
12
use Magento \Framework \Pricing \PriceCurrencyInterface ;
14
13
use Magento \Store \Model \Store ;
@@ -94,11 +93,6 @@ class Price
94
93
*/
95
94
private $ tierPriceExtensionFactory ;
96
95
97
- /**
98
- * @var TierPriceBuilder
99
- */
100
- private $ tierPriceBuilder ;
101
-
102
96
/**
103
97
* Constructor
104
98
*
@@ -109,10 +103,9 @@ class Price
109
103
* @param \Magento\Framework\Event\ManagerInterface $eventManager
110
104
* @param PriceCurrencyInterface $priceCurrency
111
105
* @param GroupManagementInterface $groupManagement
112
- * @param \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory @deprecated
106
+ * @param \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory
113
107
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
114
- * @param ProductTierPriceExtensionFactory|null $tierPriceExtensionFactory @deprecated
115
- * @param TierPriceBuilder $tierPriceBuilder
108
+ * @param ProductTierPriceExtensionFactory|null $tierPriceExtensionFactory
116
109
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
117
110
*/
118
111
public function __construct (
@@ -125,8 +118,7 @@ public function __construct(
125
118
GroupManagementInterface $ groupManagement ,
126
119
\Magento \Catalog \Api \Data \ProductTierPriceInterfaceFactory $ tierPriceFactory ,
127
120
\Magento \Framework \App \Config \ScopeConfigInterface $ config ,
128
- ProductTierPriceExtensionFactory $ tierPriceExtensionFactory = null ,
129
- ?TierPriceBuilder $ tierPriceBuilder = null
121
+ ProductTierPriceExtensionFactory $ tierPriceExtensionFactory = null
130
122
) {
131
123
$ this ->_ruleFactory = $ ruleFactory ;
132
124
$ this ->_storeManager = $ storeManager ;
@@ -139,8 +131,6 @@ public function __construct(
139
131
$ this ->config = $ config ;
140
132
$ this ->tierPriceExtensionFactory = $ tierPriceExtensionFactory ?: ObjectManager::getInstance ()
141
133
->get (ProductTierPriceExtensionFactory::class);
142
- $ this ->tierPriceBuilder = $ tierPriceBuilder ?: ObjectManager::getInstance ()
143
- ->get (TierPriceBuilder::class);
144
134
}
145
135
146
136
/**
@@ -379,7 +369,28 @@ protected function getAllCustomerGroupsId()
379
369
*/
380
370
public function getTierPrices ($ product )
381
371
{
382
- return $ this ->tierPriceBuilder ->getTierPrices ($ product );
372
+ $ prices = [];
373
+ $ tierPrices = $ this ->getExistingPrices ($ product , 'tier_price ' );
374
+ foreach ($ tierPrices as $ price ) {
375
+ /** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
376
+ $ tierPrice = $ this ->tierPriceFactory ->create ()
377
+ ->setExtensionAttributes ($ this ->tierPriceExtensionFactory ->create ());
378
+ $ tierPrice ->setCustomerGroupId ($ price ['cust_group ' ]);
379
+ if (array_key_exists ('website_price ' , $ price )) {
380
+ $ value = $ price ['website_price ' ];
381
+ } else {
382
+ $ value = $ price ['price ' ];
383
+ }
384
+ $ tierPrice ->setValue ($ value );
385
+ $ tierPrice ->setQty ($ price ['price_qty ' ]);
386
+ if (isset ($ price ['percentage_value ' ])) {
387
+ $ tierPrice ->getExtensionAttributes ()->setPercentageValue ($ price ['percentage_value ' ]);
388
+ }
389
+ $ websiteId = isset ($ price ['website_id ' ]) ? $ price ['website_id ' ] : $ this ->getWebsiteForPriceScope ();
390
+ $ tierPrice ->getExtensionAttributes ()->setWebsiteId ($ websiteId );
391
+ $ prices [] = $ tierPrice ;
392
+ }
393
+ return $ prices ;
383
394
}
384
395
385
396
/**
0 commit comments