Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
elementskuprice.php
1<?php
8
9class ElementSkuPrice extends Base
10{
14 public function __construct($id)
15 {
16 parent::__construct($id);
17 }
18
26 public function setFields(array $fields)
27 {
28 parent::setFields($fields);
29 if (
30 is_array($this->fields)
31 //&& $this->fields["MEASURE"] > 0
32 )
33 {
34 //$this->fields["MEASURE"] = new ElementCatalogMeasure($this->fields["MEASURE"]);
35 //TODO
36 }
37 }
38
45 protected function loadFromDatabase()
46 {
47 if (!isset($this->fields))
48 {
49 $this->fields = array();
50 $pricesList =\CPrice::getListEx(array(), array(
51 "=PRODUCT_ID" => $this->id,
52 "+<=QUANTITY_FROM" => 1,
53 "+>=QUANTITY_TO" => 1,
54 ), false, false, array("PRICE", "CURRENCY", "CATALOG_GROUP_ID", "CATALOG_GROUP_CODE"));
55 $this->fields = array();
56 while ($priceInfo = $pricesList->fetch())
57 {
58 $priceId = $priceInfo["CATALOG_GROUP_ID"];
59 $price = \CCurrencyLang::currencyFormat($priceInfo["PRICE"], $priceInfo["CURRENCY"], true);
60 $this->fields[$priceId][] = $price;
61 $this->addField($priceId, $priceId, $price);
62 $this->addField($priceInfo["CATALOG_GROUP_CODE"], $priceId, $price);
63 }
64 }
65 return is_array($this->fields);
66 }
67}