Достался сайт на Битрикс. До сих пор не сталкивался.
При добавлении товара в корзину, он добавляется в сессию.
Все данные проходят, но превью-картинка не проходит.
Добавляется данным кодом:
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/autoloader.php';
use BitrixError\BitrixError;
use EndingWord\EndingWord;
$req = json_decode(file_get_contents('php://input'), true);
$arProducts = $req['product'];
if (empty($arProducts)) {
$err400 = new BitrixError(400);
$err400->out(array('msg' => 'Не указан товар.'));
}
if (empty($_SESSION['samogonovo']['cart']['items'])) {
$_SESSION['samogonovo']['cart']['items'] = array();
}
$arDiscounts = array();
require_once $_SERVER['DOCUMENT_ROOT'] . '/cabinet/cache_discounts_sum.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/cabinet/total_sum.php';
$discountIndividual = 0;
foreach ($arDiscounts as $item) {
if ($totalSum > $item['sum']) {
$discountIndividual = $item['discount'];
}
}
$_SESSION['samogonovo']['cart']['discount_individual'] = $discountIndividual;
CModule::IncludeModule('iblock');
$cElem = new CIBlockElement;
$arFilter = array(
'IBLOCK_ID' => CFG::IB_CATALOG,
);
$arSelect = array(
'*', 'PROPERTY_PRICE', 'PROPERTY_PRICE_OLD', 'PROPERTY_DISCOUNT'
);
foreach ($arProducts as $item) {
// найдем товар и добавим в корзину, если есть
$id = (int)$item['id'];
if (!$id) {
continue;
}
$arFilter['ID'] = $id;
$arProd = $cElem->GetList(array(), $arFilter, false, false, $arSelect)->GetNext();
if (empty($arProd)) {
$err404 = new BitrixError(404);
$err404->out(array('msg' => 'Товар не найден.'));
}
if (empty($_SESSION['samogonovo']['cart']['items'][$arProd['ID']])) {
$discount = (int)$arProd['PROPERTY_DISCOUNT_VALUE'];
$price = (int)$arProd['PROPERTY_PRICE_VALUE'];
$price_old = (int)$arProd['PROPERTY_PRICE_OLD_VALUE'];
if ($discount) {
$price_old = $price;
$price = round($price - $price / 100 * $discount);
}
$img = CFG::NOPHOTO_CATALOG;
$imgSize = 'initial';
$imgColor = '#ebebeb';
if ($arElem['PREVIEW_PICTURE']) {
$img = $cFile->GetPath($arProd['PREVIEW_PICTURE']);
$imgSize = 'contain';
$imgColor = 'transparent';
}
$_SESSION['samogonovo']['cart']['items'][$arProd['ID']] = array(
'id' => $arProd['ID'],
'name' => $arProd['NAME'],
'img' => $img,
'img_size' => $imgSize,
'img_color' => $imgColor,
'url' => $arProd['DETAIL_PAGE_URL'],
'discount' => $discount,
'price' => $price,
'price_old' => $price_old,
'count' => (int)$item['count'],
);
} else {
$_SESSION['samogonovo']['cart']['items'][$arProd['ID']]['count'] += (int)$item['count'];
}
}
$sum = 0;
$amountProducts = 0;
foreach ($_SESSION['samogonovo']['cart']['items'] as $item) {
$sum += $item['price'] * $item['count'];
$amountProducts += $item['count'];
}
$ew = new EndingWord($amountProducts, array('товаров', 'товар', 'товара'));
$_SESSION['samogonovo']['cart']['amount_products'] = $amountProducts;
$_SESSION['samogonovo']['cart']['text'] = $amountProducts . ' ' . $ew->get() . ' на сумму ';
$_SESSION['samogonovo']['cart']['text'] .= number_format($sum, 0, '', ' ') . ' р.';
$result = array(
'amount_products' => $amountProducts,
'sum' => $sum,
'text_cart' => $_SESSION['samogonovo']['cart']['text'],
'msg' => 'Товар добавлен в корзину.',
);
echo json_encode($result);
//unset($_SESSION['samogonovo']['cart']);
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php');
В товаре картинка превью задана.
Подскажите, какую документацию читать? Спасибо.