6 declare(strict_types=1);
13 use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
14 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
26 private $productRepository;
31 private $objectManager;
36 private $productCollectionFactory;
44 $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
45 $this->productCollectionFactory = $this->objectManager->create(CollectionFactory::class);
53 public function testTierPrice()
55 $tierPriceValue = 9.00;
57 $tierPrice = $this->objectManager->create(ProductTierPriceInterfaceFactory::class)
59 $tierPrice->setCustomerGroupId(Group::CUST_GROUP_ALL);
60 $tierPrice->setQty(1.00);
61 $tierPrice->setValue($tierPriceValue);
62 $tierPriceManagement = $this->objectManager->create(ScopedProductTierPriceManagementInterface::class);
63 $tierPriceManagement->add(
'simple333', $tierPrice);
71 $tierPrice =
$product->getPriceInfo()
72 ->getPrice(TierPrice::PRICE_CODE)
75 $this->assertEquals($tierPriceValue, $tierPrice);
77 $tierPrice =
$product->getTierPrice(1);
78 $this->assertEquals($tierPriceValue, $tierPrice);
81 $this->assertEquals($tierPriceValue,
$tierPrices[0][
'price']);
83 $minPrice =
$product->getData(
'min_price');
84 $this->assertEquals($tierPriceValue, $minPrice);
static getObjectManager()