Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
bundlecollection.php
1<?php
2
3namespace Bitrix\Sale;
4
8
14{
16 protected $parentBasketItem = null;
17
21 public function setParentBasketItem(BasketItem $basketItem)
22 {
23 $this->parentBasketItem = $basketItem;
24 }
25
29 public function getParentBasketItem()
30 {
32 }
33
37 protected function getEntityParent()
38 {
39 return $this->getParentBasketItem();
40 }
41
47 public function addItem(CollectableEntity $item)
48 {
49 return parent::addItem($item);
50 }
51
57 public static function getList(array $parameters)
58 {
59 $registry = Registry::getInstance(static::getRegistryType());
60
62 $basketClassName = $registry->getBasketClassName();
63
64 return $basketClassName::getList($parameters);
65 }
66
77 public function deleteItem($index)
78 {
80 if ($order = $this->getOrder())
81 {
83 $item = $this->getItemByIndex($index);
84
85 $order->onBeforeBasketItemDelete($item);
86 }
87
88 return parent::deleteItem($index);
89 }
90
95 public static function createBundleCollectionObject()
96 {
97 $registry = Registry::getInstance(static::getRegistryType());
98 $bundleCollectionClassName = $registry->getBundleCollectionClassName();
99
100 return new $bundleCollectionClassName();
101 }
102
110 public function loadFromDb(array $filter)
111 {
112 $select = array("ID", "LID", "MODULE", "PRODUCT_ID", "QUANTITY", "WEIGHT",
113 "DELAY", "CAN_BUY", "PRICE", "CUSTOM_PRICE", "BASE_PRICE", 'PRODUCT_PRICE_ID', "CURRENCY", 'BARCODE_MULTI',
114 "RESERVED", "RESERVE_QUANTITY", "NAME", "CATALOG_XML_ID", "VAT_RATE", "NOTES", "DISCOUNT_PRICE",
115 "PRODUCT_PROVIDER_CLASS", "CALLBACK_FUNC", "ORDER_CALLBACK_FUNC", "PAY_CALLBACK_FUNC", "CANCEL_CALLBACK_FUNC",
116 "DIMENSIONS", "TYPE", "SET_PARENT_ID", "DETAIL_PAGE_URL", "FUSER_ID", 'MEASURE_CODE', 'MEASURE_NAME', 'ORDER_ID',
117 'DATE_INSERT', 'DATE_UPDATE', 'PRODUCT_XML_ID', 'SUBSCRIBE', 'RECOMMENDATION', 'VAT_INCLUDED', 'SORT'
118 );
119
120 $itemList = array();
121
122 $res = static::getList(array(
123 "filter" => $filter,
124 "select" => $select,
125 "order" => array('SORT' => 'ASC', 'ID' => 'ASC'),
126 ));
127 while ($item = $res->fetch())
128 {
129 $itemList[$item['ID']] = $item;
130 }
131
132 $this->loadFromArray($itemList);
133
134 return $this;
135 }
136
151 public function createClone(\SplObjectStorage $cloneEntity = null)
152 {
153 if ($cloneEntity === null)
154 {
155 $cloneEntity = new \SplObjectStorage();
156 }
157
159 $bundleClone = parent::createClone($cloneEntity);
160
162 if ($parentBasketItem = $this->parentBasketItem)
163 {
164 if (!$cloneEntity->contains($parentBasketItem))
165 {
166 $cloneEntity[$parentBasketItem] = $parentBasketItem->createClone($cloneEntity);
167 }
168
169 if ($cloneEntity->contains($parentBasketItem))
170 {
171 $bundleClone->parentBasketItem = $cloneEntity[$parentBasketItem];
172 }
173 }
174
175 return $bundleClone;
176 }
177
181 public function getBasket()
182 {
183 $collection = $this;
184
185 while($collection && $collection instanceof BundleCollection)
186 {
187 $entityParent = $collection->getEntityParent();
188 $collection = $entityParent->getCollection();
189 }
190
191 if ($collection instanceof BasketBase)
192 {
193 return $collection;
194 }
195
196 return null;
197 }
198
202 public static function getRegistryType()
203 {
205 }
206
222 public function onItemModify(Internals\CollectableEntity $item, $name = null, $oldValue = null, $value = null)
223 {
224 if (!($item instanceof BasketItemBase))
225 throw new Main\ArgumentTypeException($item);
226
227 $result = new Result();
228
230 $order = $this->getOrder();
231 if ($order)
232 {
233 $shipmentCollection = $order->getShipmentCollection();
234 if ($shipmentCollection)
235 {
236 $r = $shipmentCollection->onBasketModify(EventActions::UPDATE, $item, $name, $oldValue, $value);
237 if (!$r->isSuccess())
238 {
239 $result->addErrors($r->getErrors());
240 }
241 }
242 }
243
244 return $result;
245 }
246}
setParentBasketItem(BasketItem $basketItem)
addItem(CollectableEntity $item)
onItemModify(CollectableEntity $item, $name=null, $oldValue=null, $value=null)
static getInstance($type)
Definition registry.php:183