K
K
Kirill Gorelov2017-10-23 22:11:38
1C-Bitrix
Kirill Gorelov, 2017-10-23 22:11:38

Bitrix not adding product to cart?

Guys, after importing from 1s to Bitrix, the goods stopped being added to the cart. I have already checked everything, and the number of goods, and the currency, and a bunch of other things, but the product is not added, what else can I see?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Maksimenko, 2017-10-24
@olegprof

Execute the code in the Bitrix PHP command line (substituting the product id with your own):

//<?php

$productId = -1;

if (!\Bitrix\Main\Loader::includeModule('catalog')) {
    throw new \Bitrix\Main\SystemException('Ошибка подключения модуля "catalog"');
}

$addResult = Add2BasketByProductID(
    $productId, 
    1, 
    [
        'LID' => 's1',
    ], 
    []
);

if (!$addResult) {

    $strError = '';

    /** @global $APPLICATION $ex */
    if ($ex = $APPLICATION->GetException()) {
        $strError = $ex->GetString();
    }

    echo sprintf('Ошибка добавления товара %s в корзину: %s', $productId, $strError);

} else {

    echo sprintf('Товар %s успешно добавлен в корзину', $productId);

}

If there is an error in adding a product, it will be clear from what it is.

A
Artyom Luchnikov, 2017-10-23
@lu4nik

I can assume that the goods were not registered in the sales catalog module during import. To check, you can search for these products in the b_catalog_product table. If they are not there, then the goods are not registered in the sales catalog and cannot be added to the basket.
Also check if the infoblock is a trade catalog.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question