Answer the question
In order to leave comments, you need to log in
How to get the values of the product properties in the cart?
I need to get product properties in order to create an excel document.
foreach ($basketItems as $basketItem) {
$item = $basketItem; //$basketItems = $basket->getBasketItems();
$name = $item->getField('NAME');
$price = $item->getPrice();
$price1 = $item->getFinalPrice();
$quantity = $item->getQuantity();
$MODIFICATION = getBasketPropertyValue($item,'MODIFICATION');
$SERVICE_CODE = getBasketPropertyValue($item,'SERVICE_CODE');
$REESTR = getBasketPropertyValue($item,'REESTR');
$OTDEL = getBasketPropertyValue($item,'OTDEL');
$WITHOUT_NDS = getBasketPropertyValue($item,'WITHOUT_NDS');
/*
$MODIFICATION = $item->getField('MODIFICATION');
$SERVICE_CODE = $item->getField('SERVICE_CODE');
$REESTR = $item->getField('REESTR');
$OTDEL = $item->getField('OTDEL');
$WITHOUT_NDS = $item->getField('WITHOUT_NDS');
$MODIFICATION = $properties->getItemById(494);
$SERVICE_CODE = $properties->getItemById(495);
$REESTR = $properties->getItemById(496);
$OTDEL = $properties->getItemById(497);
$WITHOUT_NDS = $properties->getItemById(498);
*/
}
function getBasketPropertyValue(\Bitrix\Sale\BasketItem $item,$code) {
foreach ($item->getPropertyCollection() as $property) {
if($property->getField('CODE')!=$code)
continue;
return $property->getField('VALUE');
}
return false;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question