Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/catalog/lib/product/store/ |
Upload File : |
<?php namespace Bitrix\Catalog\Product\Store; use Bitrix\Catalog\EO_StoreBatch; use Bitrix\Catalog\EO_StoreBatch_Collection; use Bitrix\Catalog\StoreBatchTable; use Bitrix\Currency\CurrencyManager; use Bitrix\Main\ArgumentException; use Bitrix\Main\Loader; use Bitrix\Main\ObjectPropertyException; use Bitrix\Main\SystemException; /** * Class Batch * * @package Bitrix\Catalog\Product\Store */ class BatchManager { private int $productId; public function __construct(int $productId) { $this->productId = $productId; } /** * @return int */ public function getProductId(): int { return $this->productId; } /** * Get store product batches collection. * * @param array|null $filter * @return EO_StoreBatch_Collection * @throws ArgumentException * @throws ObjectPropertyException * @throws SystemException */ public function getStoreCollection(array $filter = null): EO_StoreBatch_Collection { $filter['=ELEMENT_ID'] = $this->getProductId(); return StoreBatchTable::getList([ 'filter' => $filter, 'order' => ['ID' => 'ASC'], ]) ->fetchCollection() ; } /** * Get current available store product batches collection. * * @param int $storeId * @return EO_StoreBatch_Collection * @throws ArgumentException * @throws ObjectPropertyException * @throws SystemException */ public function getAvailableStoreCollection(int $storeId): EO_StoreBatch_Collection { return $this->getStoreCollection([ '>AVAILABLE_AMOUNT' => 0, '=STORE_ID' => $storeId, ]); } /** * Calculate product cost price by quantity. * * @param float $quantity * @param int $storeId * @param string|null $currency * @return float * @throws \Bitrix\Main\LoaderException */ public function calculateCostPrice(float $quantity, int $storeId, string $currency = null): float { if (empty($currency) && Loader::includeModule('currency')) { $currency = CurrencyManager::getBaseCurrency(); } return (new CostPriceCalculator($this))->calculate($quantity, $storeId, $currency); } }