This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Добавление изменение свойства товара корзины (D7)
John edited this page Nov 9, 2016
·
7 revisions
$basket = \Bitrix\Sale\Basket::loadItemsForFUser(
\Bitrix\Sale\Fuser::getId(),
\Bitrix\Main\Context::getCurrent()->getSite()
);
// массив объектов \Bitrix\Sale\BasketItem
$basketItems = $basket->getBasketItems();
$basketItem = $basketItems[0]; //current($basketItems);
// Свойства записи, массив объектов Sale\BasketPropertyItem
$basketPropertyCollection = $basketItem->getPropertyCollection();
$props = [];
$props[] = [
'NAME' => 'Внешний ID',
'CODE' => 'VNESHNIY_ID',
'VALUE' => 1,
];
$basketPropertyCollection->setProperty($props);
//$basketItem - объект \Bitrix\Sale\BasketItem
$basketPropertyCollection->setBasketItem($basketItem);
//Сохранение
$basketPropertyCollection->save()
//Какая то другая коллекция свойств товара (\Bitrix\Sale\BasketPropertiesCollection)
$newBasketPropertiesCollection;
foreach($basketPropertyCollection as $property)
{
//Привязка свойства к коллекции
$property->create($newBasketPropertiesCollection);
//Сохранение
$property->save();
}