required) { if (!strlen($this->value)) return $this->error = $this->requiredError(); } if (is_scalar($this->value) && @strlen($this->value)) { if (strlen($this->match)) { if ($this->match == "email") { if (!$this->checkEmail($this->value)) return $this->error = $this->standardError(); } else { if (!preg_match($this->match, $this->value)) return $this->error = $this->standardError(); } } if ($this->getAttribute('input-data-source')) return; if (is_array($this->options)) { if (!isset($this->options[$this->value])) { $OK = false; foreach ($this->options as $k => $v) if (is_array($v)) if (isset($v[$this->value])) $OK = true; if (!$OK) return $this->error = $this->standardError(); } } } } } } addType('page:review', 'Список отзывов'); return array( "table" => "talk", "title" => "Отзыв", "create" => "Создать отзыв", ); } function getPanel() { return array( "page" => array( "href" => "?a=page&p=" . urlencode($this->id), "title" => "Свойства отзыва", "image" => "edit", "can" => "page|edit", ), "delete" => array( "href" => "?a=delete&p=" . urlencode($this->id), "title" => "Удалить отзыв", "image" => "delete", "can" => "delete", ), ); } function save() { if (!$this->title) $this->title = 'Отзыв от клиента ' . $this->author; if (!$this->parent) if ($this->info['parent-id']) $this->parent = $this->info['parent-id']; return parent::save(); } } } info['description']) && strlen($Page->description)) $Page->info['description'] = $Page->description; if (!$Auth->admin) { $Data->query("UPDATE `catalog` SET `views` = COALESCE(`views`, 0) + 1 WHERE `id` = " . $Data->quote($Page->id)); } $Parent = $Main->load($Page->parent); $images = $Page->getInfo('image'); if (!is_array($images)) $images = array(); $video = $Page->video; $predzakaz = false; # Предложения (размеры) $offers = array(); # Предложения комплекта $offers2 = array(); $colorList = $colorItemList = array(); $recomendationList = array(); if ($Page->group_name) { $sql = $Data->select("`catalog`.*", "`catalog`", "(`catalog`.`type`='price' OR (`catalog`.`type`='bundle' AND `catalog`.`parent`<>'shop')) AND `catalog`.`shared`='Y' AND `catalog`.`menu`='Y' AND `catalog`.`parent`={$Data->quote($Page->parent)} AND `catalog`.`group_name`={$Data->quote($Page->group_name)} AND `catalog`.`color_name`<>''", "`catalog`.`order`"); $sql->addJoin("`dict`", "`dict`.`type`='color' AND `dict`.`title`=`catalog`.`color_name`", array('left' => true))->addWhat("`dict`.`value` `color_hex`")->addGroup("`catalog`.`id`"); $sql->addWhat("`dict`.`id` `color_id`"); foreach ($Data->getRows("$sql") as $row) { $Item = $Main->load($row); /* $colorItem = null; if ($row['color_id']) { $colorItem = $Main->load($row['color_id'], 'color'); } */ # 02.08.2024 - Артем # Мы добавили определенный товар, и у него берем группу товаров для которых показываем принт в цвете. Если нужно конкретные, то нужно будет поменять код. /* $productsGroupName = array(); $colorPrint = null; if (!empty($valueProductsId = $colorItem->getInfo('products-print'))) { foreach ($valueProductsId as $productId) { $sqlProductGroup = $Main->create("sql")->select("`catalog`.`group_name`", "`catalog`", "`catalog`.`id`={$Data->quote($productId)} AND `catalog`.`type`='price'"); $valueProductGroup = $Data->dLookup($sqlProductGroup); if (!in_array($Page->group_name, $productsGroupName)) $productsGroupName[] = $valueProductGroup; } } if (in_array($Page->group_name, $productsGroupName)) $colorPrint = $colorItem->getInfo('print'); */ $colorList[] = array( 'href' => $Item->href(), 'color' => $row['color_hex'] ? (strlen($row['color_hex']) === 6 ? '#' : '') . $row['color_hex'] : 'transparent', # 14.08.2024 Сергей # Берём картинку принта из свойств товара 'print' => $Item->getInfo('print_image'), 'title' => $Item->color_name, ); $colorItemList[] = $Item; } } elseif ($Page->color_name) { $color_hex = null; $colorItem = null; if ($colorRow = $Data->getRow("SELECT * FROM `dict` WHERE `type`='color' AND `title`={$Data->quote($Page->color_name)}")) { $colorItem = $Main->load($colorRow); $color_hex = $colorItem->value; } $colorList[] = array( 'href' => $Page->href(), 'color' => $color_hex ? (strlen($color_hex) === 6 ? '#' : '') . $color_hex : 'transparent', # 14.08.2024 Сергей # Берём картинку принта из свойств товара 'print' => $Page->getInfo('print_image'), 'title' => $Page->color_name, ); } # Компоненты комплекта (обычно это price, но менеджеры могут косячить и добавлять offer; считаем, что оба варианта норм) $components = array(); $offer2 = array(); $Offer2 = array(); if ($Page->type === 'bundle') { # Структура массива offers2: # offers2[ID компонента][ID предложения] = Объект (предложение или товар – можно заказать) if (is_array($Page->info['components'])) foreach ($Page->info['components'] as $id) if ($Item = $Main->load($id)) { $components[$Item->id] = $Item; $offers2[$Item->id] = array(); if ($Item->variants_count) { $sql = $Data->select("`catalog`.*", "`catalog`", "`catalog`.`parent`={$Data->quote($Item->id)} AND `catalog`.`shared`='Y' AND `catalog`.`menu`='Y' AND `catalog`.`size`<>''"); $sql->addJoin("`dict`", "`catalog`.`size`=`dict`.`value` AND `dict`.`type`='size'", array('left' => true)); $sql->setOrder("COALESCE(`dict`.`order`, 9999), `catalog`.`order`"); foreach ($Data->getRows("$sql") as $row) { $offers2[$Item->id][$row['id']] = $Main->load($row); } } else { $offers2[$Item->id][$Item->id] = $Item; } # Выбранное предложение ID $_offer = @array_shift(array_keys($offers2[$Item->id])); # Выбранное предложение Объект $_Offer = $offers2[$Item->id][$_offer]; # То же самое в виде массива $offer2[] = $_offer; $Offer2[$_Offer->id] = $_Offer; } $offers[$Page->id] = $Page; } elseif ($Page->variants_count) { $sql = $Data->select("`catalog`.*", "`catalog`", "`catalog`.`parent`={$Data->quote($Page->id)} AND `catalog`.`shared`='Y' AND `catalog`.`menu`='Y' AND `catalog`.`size`<>''"); $sql->addJoin("`dict`", "`catalog`.`size`=`dict`.`value` AND `dict`.`type`='size'", array('left' => true)); $sql->setOrder("COALESCE(`dict`.`order`, 9999), `catalog`.`order`"); foreach ($Data->getRows("$sql") as $row) { //echo ''; $offers[$row['id']] = $Main->load($row); } } else { $offers[$Page->id] = $Page; } $utm_arr = $_GET; if(!empty($_SESSION['cart'])){ if($utm_arr['retarget'] === 'true' && !empty(array_intersect_key($_SESSION['cart'], $offers))){ unset($utm_arr['retarget']); $http_string = '?sale5&' . http_build_query($utm_arr); return $Main->redirect('/checkout/' . $http_string, 302); } } # Возможно, вам понравится: # Товары из этого же раздела (кроме этого товара) $sqlRec = $Data->select("`catalog`.*", "`catalog`", "`catalog`.`parent`={$Data->quote($Page->parent)} AND `catalog`.`shared`='Y' AND `catalog`.`menu`='Y' AND `catalog`.`id`<>{$Data->quote($Page->id)}"); $sqlRec->addJoin("`order`", "`catalog`.`id`=`order`.`id` AND `order`.`parent`={$Data->quote($Page->parent)}", array('left' => true)); $sqlRec->setOrder("CASE WHEN `order`.`order` IS NOT NULL THEN `order`.`order` ELSE 9999+`catalog`.`order` END"); $sqlRec->setLimit(16); foreach ($Data->getRows($sqlRec) as $row) $recomendationList[] = $Main->load($row); # Ищем первый элемент с quantity > 0 $offer = @array_shift(array_keys(array_filter($offers, function($value) { return $value->quantity > 0; }))); # Если не нашли, берем первый элемент из исходного массива if ($offer === null) { $offer = @array_shift(array_keys($offers)); } # Выбранное предложение Объект $Offer = $offers[$offer]; $randomItems_rows = $Data->getRows("SELECT * FROM `catalog` WHERE `type`='price' AND `menu`='Y' AND `shared`='Y' AND `price`>0 ORDER BY RAND() LIMIT 4"); $Like = $App->get('like'); $isLike = $Like->isLike($Page->id); # Список товаров, которые входят в образ $obrazList = array(); if ($Page->type === 'bundle') { # Это и есть образ if (is_array($Page->info['components'])) { foreach ($Page->info['components'] as $id) if ($id !== $Page->id) $obrazList[$id] = $id; } } else { # Список комплектов, в которые входит данный товар $sql = $Data->select("`catalog`.*", "`catalog`", "`catalog`.`type`='bundle' AND `catalog`.`shared`='Y' AND `catalog`.`menu`='Y'"); $sql->addJoin("`order`", "`catalog`.`id`=`order`.`id` AND `order`.`parent`={$Data->quote($Page->id)}", array('left' => true)); $sql->setOrder("CASE WHEN `order`.`order` IS NOT NULL THEN `order`.`order` ELSE 9999+`catalog`.`order` END"); $sql->addInfo('components')->addWhere("`info_components`.`order`=1 AND `info_components`.`value`={$Data->quote($Page->id)}"); # Для каждого комплекта foreach ($Data->getRows("$sql") as $row) { $Bundle = $Main->load($row); $Bundle->openInfo(); if (is_array($Bundle->info['components'])) { foreach ($Bundle->info['components'] as $id) if ($id !== $Page->id) $obrazList[$id] = $id; } } # Список товаров в комплектах } if ($obrazList) $obrazList = array_values($obrazList); # Товары "Актуально в сезон" # Александр, 17.12.2024 # Новая просьба: Возможность добавлять несколько категорий в раздел "Актуально в сезон", if ($Parent->get('info-actual-items__active')) { if (is_array($actualItemsCatalogLinks = $Parent->get('info-actual-items__catalog-link'))) { # массив для хранения товаров по категориям $allCategoryItems = []; # Запрашиваем товары для каждой категории foreach ($actualItemsCatalogLinks as $actualItemsCatalogLink) { if ($actualItemsCatalogLink) { $sqlActualItems = $Page->getCatalogSql(); $sqlActualItems->addWhere("`catalog`.`shared`='Y' AND catalog.`menu`='Y'"); $sqlActualItems->addWhere('`catalog`.`parent`='. $Data->quote($actualItemsCatalogLink) .''); # Ограничение для каждой категории $sqlActualItems->setLimit('10'); $catalogItems = $Data->getRows($sqlActualItems); if ($catalogItems) { # Сохраняем товары категории в отдельный массив $allCategoryItems[] = $catalogItems; } } } # массив для хранения перемешанных товаров $mixedItems = []; # Макс. кол-вл товаров для каждой категории $maxItemsPerCategory = 10; // Перемешиваем товары из всех категорий for ($i = 0; $i < $maxItemsPerCategory; $i++) { foreach ($allCategoryItems as $categoryItems) { if (isset($categoryItems[$i])) { $mixedItems[] = $categoryItems[$i]; } } } // Не знал как перемешать массив, что бы каждый раз товары в актуальном появлялись по разному shuffle($mixedItems); //Ограничение кол-ва товаров $actualItems = array_slice($mixedItems, 0, 20); } } $Retailcrm = $App->get('api_retailcrm'); $Auth = $App->Auth(); $User = $Auth->me(); $UserLoyalty = null; $UserRID = 53287; if ($User && $User->r_loyalty_id) { $UserLoyalty = $Retailcrm->loadUserLoyalty($User); $UserRID = $User->r_id; } // if (!$UserRID) return; $data = []; $data['site'] = $Retailcrm->site; $orderData = []; $orderData['privilegeType'] = 'loyalty_level'; $orderData['discountManualAmount'] = (double)0; $orderData['discountManualPercent'] = (double)0; $orderData['customer'] = []; $orderData['customer']['id'] = (int)$UserRID; $orderData['items'] = []; $item = []; if ($cartItem['article'] !== '001' && $cartItem['article'] !== '002' && $cartItem['article'] !== '003') { // && round($Offer->price_sale) <= 0 $item['initialPrice'] = (double)round($Offer->price); $item['quantity'] = (float)1; $item['discountManualAmount'] = (double)0; } $orderData['items'][] = $item; $orderData['delivery'] = []; $orderData['delivery']['cost'] = 0; $data['order'] = $orderData; $data['order'] = json_encode($data['order'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); // Кэшируем расчёт лояльности (3-й параметр true): результат зависит только от цены и // уровня (id покупателя), поэтому одинаков для всех — не дёргаем RetailCRM на каждый просмотр $r = $Retailcrm->apiCall('loyalty/calculate', $data, true); $orderData['customer']['id'] = (int)53287; $data['order'] = $orderData; $data['order'] = json_encode($data['order'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $r1 = $Retailcrm->apiCall('loyalty/calculate', $data, true); $orderData['customer']['id'] = (int)53288; $data['order'] = $orderData; $data['order'] = json_encode($data['order'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $r2 = $Retailcrm->apiCall('loyalty/calculate', $data, true); $orderData['customer']['id'] = (int)53289; $data['order'] = $orderData; $data['order'] = json_encode($data['order'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $r3 = $Retailcrm->apiCall('loyalty/calculate', $data, true); $orderData['customer']['id'] = (int)53290; $data['order'] = $orderData; $data['order'] = json_encode($data['order'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $r4 = $Retailcrm->apiCall('loyalty/calculate', $data, true); $orderData['customer']['id'] = (int)53291; $data['order'] = $orderData; $data['order'] = json_encode($data['order'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $r5 = $Retailcrm->apiCall('loyalty/calculate', $data, true); // if (is_array($r) && $r['success']) { // return $r; // } // $itemLoyalty = getItemLoyalty(); // echo ''; // echo ''; // echo ''; // echo ''; // echo ''; // echo ''; // echo ''; // echo ''; // echo ''; // echo ''; ?>
Удлинённая рубашка с поясом (2)
'; print ''; print '
'; print '
'; $first = false; } } ?> Удлинённая рубашка с поясом (2)
$image) { ?> */ ?> Удлинённая рубашка с поясом (2) '; print ''; print '
'; $first = false; } } } } else { ?> Удлинённая рубашка с поясом (2)