Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
elementprice.php
1<?php
8
9class ElementPrice extends Base
10{
14 public function __construct($id)
15 {
16 parent::__construct($id);
17 }
18
26 public function resolve($entity)
27 {
28 return parent::resolve($entity);
29 }
30
38 public function setFields(array $fields)
39 {
40 parent::setFields($fields);
41 if (
42 is_array($this->fields)
43 //&& $this->fields["MEASURE"] > 0
44 )
45 {
46 //$this->fields["MEASURE"] = new ElementCatalogMeasure($this->fields["MEASURE"]);
47 //TODO
48 }
49 }
50
57 protected function loadFromDatabase()
58 {
59 if (!isset($this->fields))
60 {
61 $pricesList =\CPrice::getListEx(array(), array(
62 "=PRODUCT_ID" => $this->id,
63 "+<=QUANTITY_FROM" => 1,
64 "+>=QUANTITY_TO" => 1,
65 ), false, false, array("PRICE", "CURRENCY", "CATALOG_GROUP_ID", "CATALOG_GROUP_CODE"));
66 $this->fields = array();
67 while ($priceInfo = $pricesList->fetch())
68 {
69 $priceId = $priceInfo["CATALOG_GROUP_ID"];
70 $price = \CCurrencyLang::currencyFormat($priceInfo["PRICE"], $priceInfo["CURRENCY"], true);
71 $this->addField($priceId, $priceId, $price);
72 $this->addField($priceInfo["CATALOG_GROUP_CODE"], $priceId, $price);
73 }
74 }
75 return is_array($this->fields);
76 }
77}