24 return (mb_strpos($basketCode,
'n') === 0);
28 protected function getExistsItem($moduleId, $productId, array $properties = array())
38 public function itemsDataPreparation()
40 foreach($this->formData[
"PRODUCT"] as $basketCode => $productData)
42 if($productData[
"IS_SET_ITEM"] ==
"Y")
45 if(!isset($productData[
"PROPS"]) || !is_array($productData[
"PROPS"]))
46 $productData[
"PROPS"] = array();
48 if(self::isBasketItemNew($basketCode) ==
true)
50 $item = $this->
createItem($basketCode, $productData);
55 $item = $this->getItemFromBasket($basketCode, $productData);
59 $this->builder->getErrorsContainer()->addError(
new Error(
'basketItem - is not exists ['.$basketCode.
']'));
60 throw new BuildingException();
64 foreach ($productData[
"PROPS"] as &$prop)
66 unset($prop[
'BASKET_ID']);
69 if(!empty($productData[
"PROPS"]) && is_array($productData[
"PROPS"]))
72 $property = $item->getPropertyCollection();
74 if(!$property->isPropertyAlreadyExists($productData[
"PROPS"]))
75 $property->setProperty($productData[
"PROPS"]);
87 public function setItemsFields()
92 foreach ($basket as $basketItem)
94 $basketCode = $basketItem->getBasketCode();
95 if(isset($this->formData[
'PRODUCT'][$basketCode]))
97 $itemFields = $this->formData[
'PRODUCT'][$basketCode];
99 if(isset($itemFields[
'OFFER_ID']))
101 $itemFields[
'PRODUCT_ID'] = $itemFields[
'OFFER_ID'];
104 if(isset($itemFields[
'PRICE']))
106 $itemFields[
'CUSTOM_PRICE'] =
'Y';
109 $fields = array_intersect_key($itemFields, array_flip($basketItem::getAvailableFields()));
111 $r = $basketItem->setFields($fields);
112 if($r->isSuccess() ==
false)
115 throw new BuildingException();
128 foreach ($basket as $basketItem)
130 if(self::isBasketItemNew($basketItem->getBasketCode()))
132 $strategy = RefreshFactory::createSingle($basketItem->getBasketCode());
133 $basket->refresh($strategy);