File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -15,27 +15,24 @@ public function __construct(
1515 ) {
1616 }
1717
18- public function getCustomerPrice (int $ productId , int $ customerId , int $ quantity = 1 ): ?float
18+ public function getCustomerPrice (int $ productId , int $ customerId , float $ quantity = 1 ): ?float
1919 {
2020 $ this ->customerPricingCollection
2121 ->clear ()
2222 ->getSelect ()
23- ->reset (Zend_Db_Select::WHERE );
23+ ->reset (Zend_Db_Select::WHERE )
24+ ->reset (Zend_Db_Select::ORDER );
2425
2526 $ customerPrices = $ this ->customerPricingCollection
2627 ->addFieldToFilter ('product_id ' , ['eq ' => $ productId ])
2728 ->addFieldToFilter ('customer_id ' , ['eq ' => $ customerId ])
28- ->load ()
29+ ->addFieldToFilter ('quantity ' , ['lteq ' => $ quantity ])
30+ ->setOrder ('quantity ' )
2931 ->getItems ();
3032
31- usort (
32- $ customerPrices ,
33- fn (CustomerPricing $ a , CustomerPricing $ b ): int => $ a ->getData ('quantity ' ) <=> $ b ->getData ('quantity ' )
34- );
35-
3633 foreach ($ customerPrices as $ price ) {
37- if ($ quantity >= $ price ->getData ('quantity ' )) {
38- return $ price ->getData ('price ' );
34+ if ($ quantity >= ( float ) $ price ->getData ('quantity ' )) {
35+ return ( float ) $ price ->getData ('price ' );
3936 }
4037 }
4138
You can’t perform that action at this time.
0 commit comments