2021-05-31 16:33:02 +03:00
|
|
|
<?php
|
|
|
|
|
2024-04-29 11:44:31 +03:00
|
|
|
/**
|
|
|
|
* @category Integration
|
|
|
|
* @package Intaro\RetailCrm\Repository
|
|
|
|
* @author RetailCRM <integration@retailcrm.ru>
|
|
|
|
* @license MIT
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see http://retailcrm.ru/docs
|
|
|
|
*/
|
|
|
|
|
2021-05-31 16:33:02 +03:00
|
|
|
namespace Intaro\RetailCrm\Repository;
|
|
|
|
|
2021-09-08 16:31:17 +03:00
|
|
|
use Bitrix\Catalog\MeasureTable;
|
|
|
|
use Bitrix\Main\ArgumentException;
|
|
|
|
use Bitrix\Main\ObjectPropertyException;
|
|
|
|
use Bitrix\Main\SystemException;
|
2021-05-31 16:33:02 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class MeasureRepository
|
|
|
|
* @package Intaro\RetailCrm\Repository
|
|
|
|
*/
|
|
|
|
class MeasureRepository
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Получает доступные в Битриксе единицы измерения для товаров
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function getMeasures(): array
|
|
|
|
{
|
|
|
|
$measures = [];
|
2021-09-08 16:31:17 +03:00
|
|
|
|
|
|
|
try {
|
|
|
|
$resMeasures = MeasureTable::query()
|
|
|
|
->addSelect('ID')
|
|
|
|
->addSelect('MEASURE_TITLE')
|
|
|
|
->addSelect('SYMBOL_INTL')
|
|
|
|
->addSelect('SYMBOL')
|
|
|
|
->fetchAll();
|
|
|
|
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($resMeasures as $resMeasure) {
|
|
|
|
$measures[$resMeasure['ID']] = $resMeasure;
|
2021-05-31 16:33:02 +03:00
|
|
|
}
|
2021-09-08 16:31:17 +03:00
|
|
|
|
2021-05-31 16:33:02 +03:00
|
|
|
return $measures;
|
|
|
|
}
|
|
|
|
}
|