19 private $itemsPerOperation = 500;
26 private $tierpriceResource;
33 private $metadataPool;
45 $this->tierpriceResource = $tierpriceResource;
46 $this->metadataPool = $metadataPool;
55 public function get(array $ids)
57 $select = $this->tierpriceResource->getConnection()->select()->from($this->tierpriceResource->getMainTable());
58 return $this->tierpriceResource->getConnection()->fetchAll(
59 $select->where($this->getEntityLinkField() .
' IN (?)', $ids)
72 $connection = $this->tierpriceResource->getConnection();
75 foreach (array_chunk(
$prices, $this->itemsPerOperation) as $pricesBunch) {
76 $this->tierpriceResource->getConnection()->insertOnDuplicate(
77 $this->tierpriceResource->getMainTable(),
79 [
'value',
'percentage_value']
85 throw new \Magento\Framework\Exception\CouldNotSaveException(
86 __(
'Could not save Tier Prices'),
102 $connection = $this->tierpriceResource->getConnection();
105 foreach (array_chunk($ids, $this->itemsPerOperation) as $idsBunch) {
106 $this->tierpriceResource->getConnection()->delete(
107 $this->tierpriceResource->getMainTable(),
112 foreach (array_chunk(
$prices, $this->itemsPerOperation) as $pricesBunch) {
113 $this->tierpriceResource->getConnection()->insertMultiple(
114 $this->tierpriceResource->getMainTable(),
121 throw new \Magento\Framework\Exception\CouldNotSaveException(
122 __(
'Could not replace Tier Prices'),
135 public function delete(array $ids)
137 $connection = $this->tierpriceResource->getConnection();
140 foreach (array_chunk($ids, $this->itemsPerOperation) as $idsBunch) {
141 $this->tierpriceResource->getConnection()->delete(
142 $this->tierpriceResource->getMainTable(),
143 [
'value_id IN (?)' => $idsBunch]
149 throw new \Magento\Framework\Exception\CouldNotDeleteException(
150 __(
'Could not delete Tier Prices'),
163 return $this->metadataPool->getMetadata(\
Magento\Catalog\Api\Data\ProductInterface::class)
__construct(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice $tierpriceResource, \Magento\Framework\EntityManager\MetadataPool $metadataPool)
replace(array $prices, array $ids)