R
R
Rob1n Bobin2018-02-20 09:40:57
1C-Bitrix
Rob1n Bobin, 2018-02-20 09:40:57

Passing product properties to cart D7 how to solve wiping problem?

Hello!
There is a problem with the new D7 kernel.
I have a property details in the product card.
5a8bc0f21590c410096420.png
The transfer of product properties to the basket is carried out in the following way:

$props = array();
$basketPropRes = Sale\Internals\BasketPropertyTable::getList(array(
  'filter' => array(
    "BASKET_ID" => $arBasket["ID"],
  ),
));
while ($property = $basketPropRes->fetch()) {
  unset($property["BASKET_ID"]);
  $props[] = $property;
}
$item = $basket->createItem('catalog', $_REQUEST["prod"]);
$basketPropertyCollection = $item->getPropertyCollection();
$basketPropertyCollection->setProperty($props);
$basketPropertyCollection->save();

When the $props array is printed out, the result is:
Array
(
    [0] => Array
        (
            [ID] => 279563
            [NAME] => Склад
            [VALUE] => 20
            [CODE] => STORE
            [SORT] => 100
        )

    [1] => Array
        (
            [ID] => 279564
            [NAME] => Название склада
            [VALUE] => Склад СПб Центральный
            [CODE] => STORE_NAME
            [SORT] => 100
        )

    [2] => Array
        (
            [ID] => 279565
            [NAME] => Артикул
            [VALUE] => 327320097
            [CODE] => CML2_ARTICLE
            [SORT] => 100
        )

    [3] => Array
        (
            [ID] => 279566
            [NAME] => Реквизиты
            [VALUE] => Gerep
            [CODE] => CML2_TRAITS
            [SORT] => 100
        )

    [4] => Array
        (
            [ID] => 279567
            [NAME] => Реквизиты
            [VALUE] => a29c8f2f-b5b8-11e4-8e7b-00155dc0ba09
            [CODE] => CML2_TRAITS
            [SORT] => 100
        )

    [5] => Array
        (
            [ID] => 279568
            [NAME] => Реквизиты
            [VALUE] => Товар (пр. ТМЦ)
            [CODE] => CML2_TRAITS
            [SORT] => 100
        )

    [6] => Array
        (
            [ID] => 279569
            [NAME] => Реквизиты
            [VALUE] => Товар
            [CODE] => CML2_TRAITS
            [SORT] => 100
        )

)

But when I output the saved properties
dump($basketPropertyCollection->getPropertyValues());

I get only four properties instead of six, and the props property is overwritten:
Array
(
    [STORE] => Array
        (
            [CODE] => STORE
            [ID] => 295667
            [VALUE] => 20
            [SORT] => 100
            [NAME] => Склад
        )

    [STORE_NAME] => Array
        (
            [CODE] => STORE_NAME
            [ID] => 295668
            [VALUE] => Склад СПб Центральный
            [SORT] => 100
            [NAME] => Название склада
        )

    [CML2_ARTICLE] => Array
        (
            [CODE] => CML2_ARTICLE
            [ID] => 295669
            [VALUE] => 327320097
            [SORT] => 100
            [NAME] => Артикул
        )

    [CML2_TRAITS] => Array
        (
            [CODE] => CML2_TRAITS
            [ID] => 295673
            [VALUE] => Товар
            [SORT] => 100
            [NAME] => Реквизиты
        )

)

I don’t understand what to do, in the old method an array was simply passed and there were no problems, now something is going wrong. Can someone tell me what the problem is or how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-02-20
@vaajnur

note [CODE] => CML2_TRAITS all 3 attributes are the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question