SAnet1989 Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Подскажите пож. в чем может быть проблема? делаю выгрузку из 1с, на фтп как положено выгрузились картинки. в базе тоже прописались. а на странице с товарами их нету Надіслати Поділитися на інших сайтах More sharing options...
Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, А по пути http://ВАШ_САЙТ/image/catalog/products/4357.jpg она доступна? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 5 минут назад, Eldaeron сказал: SAnet1989, А по пути http://ВАШ_САЙТ/image/catalog/products/4357.jpg она доступна? Да открывает, пробовал тоже. Понять не могу почему не отображает в товарах, всю голову сломал Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 <img src="" alt="тест" title="тест" class="img-responsive" /> и строку в коде показывает, но не прописывает путь Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Ссылка на сайт будет? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Отправил в ЛС Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Ну, ссылка на картинку вообще не выводится. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 я пути переделал - к примеру вот кажет image/cache/catalog/new/4357.jpg Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 31 минуту назад, mazein сказал: Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Еще раз повторяю))) ссылки в базе прописываются как надо. В браузере они отображаются. Вопрос в чем. Не могу понять почему они не отображаются в товарах, то-бишь в код не заносится эта ссылка. Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 7 минут назад, SAnet1989 сказал: Еще раз повторяю))) ссылки в базе прописываются как надо. Не спорю. 7 минут назад, SAnet1989 сказал: В браузере они отображаются. Ну покажите эту ссылку. Надіслати Поділитися на інших сайтах More sharing options... Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, в вашем случае надо смотреть логи ошибок, тогда можно сказать. Да и на странице товаров невижу тега <img> для картинок в общем, затерли чем-то. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options... agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options... Створіть аккаунт або увійдіть для коментування Ви повинні бути користувачем, щоб залишити коментар Створити обліковий запис Зареєструйтеся для отримання облікового запису. Це просто! Зареєструвати аккаунт Вхід Уже зареєстровані? Увійдіть тут. Вхід зараз Share More sharing options... Передплатники 0 Перейти до списку тем Зараз на сторінці 0 користувачів Ні користувачів, які переглядиють цю сторінку Последние темы Последние дополнения Последние новости Вся активність Головна Opencart 2.x Opencart 2.x: Загальні питання Не присваиваются изображения к товарам Покупцям Оплата розширень фізичними особами Оплата розширень юридичними особами Політика повернень Розробникам Регламент розміщення розширень Регламент продажу та підтримки розширень Віртуальний обліковий запис автора Політика просування оголошень API каталогу розширень Вирішення спорів щодо авторських прав Корисна інформація Публічна оферта Політика повернень Політика конфіденційності Платіжна політика Політика передачі особистих даних Політика прозорості Останні розширення SP Telegram повідомлення FREE Автор: spectre Відключити порожні категорії Автор: spectre SEO Автор тексту категорії / фільтра / блогу з датою оновлення контенту + мікророзмітка Автор: radaevich Промо банери в категоріях товарів Автор: IHOR1989 Trend - адаптивний універсальний шаблон Автор: DSV × Уже зареєстровані? Ввійти Реєстрація Ваші замовлення Назад Придбані модулі та шаблони Ваші рахунки Лист очікувань Альтернативні контакти Форум Новини ocStore Назад Офіційний сайт Демо ocStore 3.0.3.2 Демо ocStore 2.3.0.2.4 Завантажити ocStore Документація Історія версій ocStore Блоги Модулі Шаблони Назад Безкоштовні шаблони Платні шаблони Де купувати модулі? Послуги FAQ OpenCart.Pro Назад Демо Купити Порівняння × Створити... Important Information На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність. Я даю згоду
SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 5 минут назад, Eldaeron сказал: SAnet1989, А по пути http://ВАШ_САЙТ/image/catalog/products/4357.jpg она доступна? Да открывает, пробовал тоже. Понять не могу почему не отображает в товарах, всю голову сломал Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 <img src="" alt="тест" title="тест" class="img-responsive" /> и строку в коде показывает, но не прописывает путь Надіслати Поділитися на інших сайтах More sharing options...
mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Ссылка на сайт будет? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Отправил в ЛС Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Ну, ссылка на картинку вообще не выводится. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 я пути переделал - к примеру вот кажет image/cache/catalog/new/4357.jpg Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 31 минуту назад, mazein сказал: Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Еще раз повторяю))) ссылки в базе прописываются как надо. В браузере они отображаются. Вопрос в чем. Не могу понять почему они не отображаются в товарах, то-бишь в код не заносится эта ссылка. Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 7 минут назад, SAnet1989 сказал: Еще раз повторяю))) ссылки в базе прописываются как надо. Не спорю. 7 минут назад, SAnet1989 сказал: В браузере они отображаются. Ну покажите эту ссылку. Надіслати Поділитися на інших сайтах More sharing options... Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, в вашем случае надо смотреть логи ошибок, тогда можно сказать. Да и на странице товаров невижу тега <img> для картинок в общем, затерли чем-то. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options... agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options... Створіть аккаунт або увійдіть для коментування Ви повинні бути користувачем, щоб залишити коментар Створити обліковий запис Зареєструйтеся для отримання облікового запису. Це просто! Зареєструвати аккаунт Вхід Уже зареєстровані? Увійдіть тут. Вхід зараз Share More sharing options... Передплатники 0 Перейти до списку тем Зараз на сторінці 0 користувачів Ні користувачів, які переглядиють цю сторінку Последние темы Последние дополнения Последние новости Вся активність Головна Opencart 2.x Opencart 2.x: Загальні питання Не присваиваются изображения к товарам Покупцям Оплата розширень фізичними особами Оплата розширень юридичними особами Політика повернень Розробникам Регламент розміщення розширень Регламент продажу та підтримки розширень Віртуальний обліковий запис автора Політика просування оголошень API каталогу розширень Вирішення спорів щодо авторських прав Корисна інформація Публічна оферта Політика повернень Політика конфіденційності Платіжна політика Політика передачі особистих даних Політика прозорості Останні розширення SP Telegram повідомлення FREE Автор: spectre Відключити порожні категорії Автор: spectre SEO Автор тексту категорії / фільтра / блогу з датою оновлення контенту + мікророзмітка Автор: radaevich Промо банери в категоріях товарів Автор: IHOR1989 Trend - адаптивний універсальний шаблон Автор: DSV × Уже зареєстровані? Ввійти Реєстрація Ваші замовлення Назад Придбані модулі та шаблони Ваші рахунки Лист очікувань Альтернативні контакти Форум Новини ocStore Назад Офіційний сайт Демо ocStore 3.0.3.2 Демо ocStore 2.3.0.2.4 Завантажити ocStore Документація Історія версій ocStore Блоги Модулі Шаблони Назад Безкоштовні шаблони Платні шаблони Де купувати модулі? Послуги FAQ OpenCart.Pro Назад Демо Купити Порівняння × Створити... Important Information На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність. Я даю згоду
SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Отправил в ЛС Надіслати Поділитися на інших сайтах More sharing options...
mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Ну, ссылка на картинку вообще не выводится. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 я пути переделал - к примеру вот кажет image/cache/catalog/new/4357.jpg Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 31 минуту назад, mazein сказал: Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Еще раз повторяю))) ссылки в базе прописываются как надо. В браузере они отображаются. Вопрос в чем. Не могу понять почему они не отображаются в товарах, то-бишь в код не заносится эта ссылка. Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 7 минут назад, SAnet1989 сказал: Еще раз повторяю))) ссылки в базе прописываются как надо. Не спорю. 7 минут назад, SAnet1989 сказал: В браузере они отображаются. Ну покажите эту ссылку. Надіслати Поділитися на інших сайтах More sharing options... Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, в вашем случае надо смотреть логи ошибок, тогда можно сказать. Да и на странице товаров невижу тега <img> для картинок в общем, затерли чем-то. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options... agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options... Створіть аккаунт або увійдіть для коментування Ви повинні бути користувачем, щоб залишити коментар Створити обліковий запис Зареєструйтеся для отримання облікового запису. Це просто! Зареєструвати аккаунт Вхід Уже зареєстровані? Увійдіть тут. Вхід зараз Share More sharing options... Передплатники 0 Перейти до списку тем Зараз на сторінці 0 користувачів Ні користувачів, які переглядиють цю сторінку Последние темы Последние дополнения Последние новости Вся активність Головна Opencart 2.x Opencart 2.x: Загальні питання Не присваиваются изображения к товарам Покупцям Оплата розширень фізичними особами Оплата розширень юридичними особами Політика повернень Розробникам Регламент розміщення розширень Регламент продажу та підтримки розширень Віртуальний обліковий запис автора Політика просування оголошень API каталогу розширень Вирішення спорів щодо авторських прав Корисна інформація Публічна оферта Політика повернень Політика конфіденційності Платіжна політика Політика передачі особистих даних Політика прозорості Останні розширення SP Telegram повідомлення FREE Автор: spectre Відключити порожні категорії Автор: spectre SEO Автор тексту категорії / фільтра / блогу з датою оновлення контенту + мікророзмітка Автор: radaevich Промо банери в категоріях товарів Автор: IHOR1989 Trend - адаптивний універсальний шаблон Автор: DSV
SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 я пути переделал - к примеру вот кажет image/cache/catalog/new/4357.jpg Надіслати Поділитися на інших сайтах More sharing options...
mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 31 минуту назад, mazein сказал: Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Еще раз повторяю))) ссылки в базе прописываются как надо. В браузере они отображаются. Вопрос в чем. Не могу понять почему они не отображаются в товарах, то-бишь в код не заносится эта ссылка. Надіслати Поділитися на інших сайтах More sharing options... mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 7 минут назад, SAnet1989 сказал: Еще раз повторяю))) ссылки в базе прописываются как надо. Не спорю. 7 минут назад, SAnet1989 сказал: В браузере они отображаются. Ну покажите эту ссылку. Надіслати Поділитися на інших сайтах More sharing options... Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, в вашем случае надо смотреть логи ошибок, тогда можно сказать. Да и на странице товаров невижу тега <img> для картинок в общем, затерли чем-то. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options... agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options... Створіть аккаунт або увійдіть для коментування Ви повинні бути користувачем, щоб залишити коментар Створити обліковий запис Зареєструйтеся для отримання облікового запису. Це просто! Зареєструвати аккаунт Вхід Уже зареєстровані? Увійдіть тут. Вхід зараз Share More sharing options... Передплатники 0 Перейти до списку тем Зараз на сторінці 0 користувачів Ні користувачів, які переглядиють цю сторінку Последние темы Последние дополнения Последние новости Вся активність Головна Opencart 2.x Opencart 2.x: Загальні питання Не присваиваются изображения к товарам
SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 31 минуту назад, mazein сказал: Вы разницу понимаете, между не выводятся ссылки, и неправильные ссылки? Еще раз повторяю))) ссылки в базе прописываются как надо. В браузере они отображаются. Вопрос в чем. Не могу понять почему они не отображаются в товарах, то-бишь в код не заносится эта ссылка. Надіслати Поділитися на інших сайтах More sharing options...
mazein Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 7 минут назад, SAnet1989 сказал: Еще раз повторяю))) ссылки в базе прописываются как надо. Не спорю. 7 минут назад, SAnet1989 сказал: В браузере они отображаются. Ну покажите эту ссылку. Надіслати Поділитися на інших сайтах More sharing options... Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, в вашем случае надо смотреть логи ошибок, тогда можно сказать. Да и на странице товаров невижу тега <img> для картинок в общем, затерли чем-то. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options... agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options... Створіть аккаунт або увійдіть для коментування Ви повинні бути користувачем, щоб залишити коментар Створити обліковий запис Зареєструйтеся для отримання облікового запису. Це просто! Зареєструвати аккаунт Вхід Уже зареєстровані? Увійдіть тут. Вхід зараз Share More sharing options... Передплатники 0 Перейти до списку тем Зараз на сторінці 0 користувачів Ні користувачів, які переглядиють цю сторінку
Eldaeron Опубліковано: 31 травня 2017 Share Опубліковано: 31 травня 2017 SAnet1989, в вашем случае надо смотреть логи ошибок, тогда можно сказать. Да и на странице товаров невижу тега <img> для картинок в общем, затерли чем-то. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options... agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options... SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options... thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options... Створіть аккаунт або увійдіть для коментування Ви повинні бути користувачем, щоб залишити коментар Створити обліковий запис Зареєструйтеся для отримання облікового запису. Це просто! Зареєструвати аккаунт Вхід Уже зареєстровані? Увійдіть тут. Вхід зараз Share More sharing options... Передплатники 0
SAnet1989 Опубліковано: 31 травня 2017 Автор Share Опубліковано: 31 травня 2017 Нашел кусок кода. вроде все прописано норм <div class="product-thumb"> <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a></div> <div> Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Через админку он прописывает изображения и на сайте отображается. Стоит сделать автоматическую выгрузку и 1с то он выгрузит все, но изображения не будут показываться, хотя в базе ссылки пути прописываются нормально Надіслати Поділитися на інших сайтах More sharing options...
agefremov Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 Сравните пути изображения в БД у вручную добавленного товара и из импорта. Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 19 минут назад, agefremov сказал: Сравните пути изображения в БД у вручную добавленного товара и из импорта. Сравнивал, все хорошо. Прописывает верно. Даже браузер проверял. В папке на фтп все залито Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 Странно вообще. А если через админку к товару прикрепить изображение с этой же папки то отобржается хорошо. Вот только почему в базе oc_product_image пустой? Надіслати Поділитися на інших сайтах More sharing options...
thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 32 минуты назад, SAnet1989 сказал: Вот только почему в базе oc_product_image пустой? это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 2 минуты назад, thentru сказал: это таблица с данными по доп изображениям товара. Пустая - значит доп фото у товаров у вас нет основное фото хранится в oc_product я так и не понял: у вас не отображаются все фото товара, или только основное/дополнительные? и то и другое Надіслати Поділитися на інших сайтах More sharing options...
thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 4 минуты назад, thentru сказал: по этому пути файлы есть? покажите их /system/storage/modification/catalog/controller/product/product.php /system/storage/modification/catalog/model/catalog/product.php если нет, то /catalog/controller/product/product.php /catalog/model/catalog/product.php <?php class ControllerProductProduct extends Controller { private $error = array(); public function index() { $this->load->language('product/product'); $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); $this->load->model('catalog/category'); if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path) ); } } // Set the last category breadcrumb $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url) ); } } $this->load->model('catalog/manufacturer'); if (isset($this->request->get['manufacturer_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer') ); $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); if ($manufacturer_info) { $data['breadcrumbs'][] = array( 'text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url) ); } } if (isset($this->request->get['search']) || isset($this->request->get['tag'])) { $url = ''; if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url) ); } if (isset($this->request->get['product_id'])) { $product_id = (int)$this->request->get['product_id']; } else { $product_id = 0; } $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']) ); $this->document->setTitle($product_info['meta_title']); $this->document->setDescription($product_info['meta_description']); $this->document->setKeywords($product_info['meta_keyword']); $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical'); $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); if ($product_info['meta_h1']) { $data['heading_title'] = $product_info['meta_h1']; } else { $data['heading_title'] = $product_info['name']; } $data['text_select'] = $this->language->get('text_select'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_reward'] = $this->language->get('text_reward'); $data['text_points'] = $this->language->get('text_points'); $data['text_stock'] = $this->language->get('text_stock'); $data['text_discount'] = $this->language->get('text_discount'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_option'] = $this->language->get('text_option'); $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']); $data['text_write'] = $this->language->get('text_write'); $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true)); $data['text_note'] = $this->language->get('text_note'); $data['text_tags'] = $this->language->get('text_tags'); $data['text_related'] = $this->language->get('text_related'); $data['text_payment_recurring'] = $this->language->get('text_payment_recurring'); $data['text_loading'] = $this->language->get('text_loading'); $data['entry_qty'] = $this->language->get('entry_qty'); $data['entry_name'] = $this->language->get('entry_name'); $data['entry_review'] = $this->language->get('entry_review'); $data['entry_rating'] = $this->language->get('entry_rating'); $data['entry_good'] = $this->language->get('entry_good'); $data['entry_bad'] = $this->language->get('entry_bad'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_upload'] = $this->language->get('button_upload'); $data['button_continue'] = $this->language->get('button_continue'); $this->load->model('catalog/review'); $data['tab_description'] = $this->language->get('tab_description'); $data['tab_attribute'] = $this->language->get('tab_attribute'); $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']); $data['product_id'] = (int)$this->request->get['product_id']; $data['manufacturer'] = $product_info['manufacturer']; $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']); $data['model'] = $product_info['model']; $data['reward'] = $product_info['reward']; $data['points'] = $product_info['points']; $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); if ($product_info['quantity'] <= 0) { $data['stock'] = $product_info['stock_status']; } elseif ($this->config->get('config_stock_display')) { $data['stock'] = $product_info['quantity']; } else { $data['stock'] = $this->language->get('text_instock'); } $this->load->model('tool/image'); $this->load->model('extension/module/quickpay'); $this->model_extension_module_quickpay->createQuickpayliveprice(); $limit_days_new_product = 31; $limit_viewed_popular_product = 50; $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; $this->load->language('extension/module/langtemplates'); IF (isset($modules['settemplate_kolvo_prosmotr_product_popular_stikers'])) {$limit_viewed_popular_product = $modules['settemplate_kolvo_prosmotr_product_popular_stikers'];} IF (isset($modules['settemplate_kolvo_dney_product_new_stikers'])) {$limit_days_new_product = $modules['settemplate_kolvo_dney_product_new_stikers'];} $resul = $this->model_catalog_product->getProduct($product_id); $timestamp = mktime($hours, $minutes, $seconds, $month,$day - $limit_days_new_product, $year); If ($resul['price']!=0) {$priceecho=round((($resul['price'] - $resul['special'])/$resul['price'])*100, 0);} else {$priceecho='';} if ((float)$resul['special']) {if ($resul['price'] > 0) {$data['sale'] = '<div class="stiker-special-product">' .$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$data['sale'] = false;}} else {$data['sale'] = false;} if (($resul['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$data['new'] = '<div class="stiker-new-product">'.$this->language->get('new_stikers').'</div>';} else {$data['new'] = false;} if (($resul['viewed']) > ($limit_viewed_popular_product)) {$data['popular'] = '<div class="stiker-popular-product">'.$this->language->get('popular_stikers').'</div>';} else {$data['popular'] = false;} if ($resul['image']) { $data['thumb1'] = $this->model_tool_image->resize($resul['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } else { $data['thumb1'] = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')); } $ress = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($ress as $res) { $data['imags'][] = array( 'popup' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), 'thumb_zoom' => $this->model_tool_image->resize($res['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')) ); } $showzoom="1"; $display_new_stickers='1'; $display_popular_stickers='1'; $display_special_stickers='1'; IF (isset($modules['settemplate_zoom_setting_product'])) {$showzoom=$modules['settemplate_zoom_setting_product'];} IF (isset($modules['settemplate_new_stikers_product'])) {$display_new_stickers=$modules['settemplate_new_stikers_product'];} IF (isset($modules['settemplate_special_stikers_product'])) {$display_special_stickers=$modules['settemplate_special_stikers_product'];} IF (isset($modules['settemplate_popular_stikers_product'])) {$display_popular_stickers=$modules['settemplate_popular_stikers_product'];} $options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $data['showzoom']='1'; $data['display_new_stickers']='1'; $data['display_special_stickers']='1'; $data['display_popular_stickers']='1'; $data['display_new_stickers_featured']='1'; $data['display_special_stickers_featured']='1'; $data['display_popular_stickers_featured']='1'; $data['image_additional_hover_module_setting_featured']="1"; $data['quickpay_module_setting_featured']="1"; $data['quickview_module_setting_featured']="1"; $data['on_off_rating_featured'] = "2"; $data['description_module_setting_featured']="1"; $data['cheaper_module_setting_featured']="1"; IF (isset($modules['settemplate_new_stikers_f_module'])) {$data['display_new_stickers_featured'] = $modules['settemplate_new_stikers_f_module'];} IF (isset($modules['settemplate_special_stikers_f_module'])) {$data['display_special_stickers_featured'] = $modules['settemplate_special_stikers_f_module'];} IF (isset($modules['settemplate_popular_stikers_f_module'])) {$data['display_popular_stickers_featured'] = $modules['settemplate_popular_stikers_f_module'];} IF (isset($modules['settemplate_hover_module_f_setting'])) {$data['image_additional_hover_module_setting_featured'] = $modules['settemplate_hover_module_f_setting'];} IF (isset($modules['settemplate_quickpay_module_f_setting'])) {$data['quickpay_module_setting_featured'] = $modules['settemplate_quickpay_module_f_setting'];} IF (isset($modules['settemplate_divshadow_module_f_status'])) {$data['quickview_module_setting_featured'] = $modules['settemplate_divshadow_module_f_status'];} IF (isset($modules['settemplate_on_off_rating_f'])) {$data['on_off_rating_featured'] = $modules['settemplate_on_off_rating_f'];} IF (isset($modules['settemplate_description_module_f_setting'])) {$data['description_module_setting_featured'] = $modules['settemplate_description_module_f_setting'];} IF (isset($modules['settemplate_cheaper_module_f_setting'])) {$data['cheaper_module_setting_featured'] = $modules['settemplate_cheaper_module_f_setting'];} $data['ozenka_pokupatelei'] = $this->language->get('ozenka_pokupatelei'); $data['tab_review_product'] = $this->language->get('tab_review_product'); $data['tab_related'] = $this->language->get('tab_related'); $data['add_review'] = $this->language->get('add_review'); $data['senks_review'] = $this->language->get('senks_review'); $data['naideno'] = $this->language->get('naideno'); $data['tovarov'] = $this->language->get('tovarov'); $data['text_st'] = $this->language->get('text_st'); $data['reviews_kolvo'] = $this->language->get('reviews_kolvo'); $data['text_or'] = $this->language->get('text_or'); $data['text_select'] = $this->language->get('text_select'); $data['td_more'] = $this->language->get('td_more'); $data['quick_button'] = $this->language->get('quick_button'); $data['quick_pay'] = $this->language->get('quick_pay'); $data['text_cheaper'] = $this->language->get('text_cheaper'); if ($product_info['image']) { $data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')); } else { $data['popup'] = ''; } if ($product_info['image']) { $data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_thumb_width'), $this->config->get($this->config->get('config_theme') . '_image_thumb_height')); } else { $data['thumb'] = ''; } $data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_popup_width'), $this->config->get($this->config->get('config_theme') . '_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')) ); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['price'] = false; } if ((float)$product_info['special']) { $data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $data['special'] = false; } if ($this->config->get('config_tax')) { $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']); } else { $data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $data['discounts'] = array(); foreach ($discounts as $discount) { $data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) ); } $data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { $product_option_value_data = array(); foreach ($option['product_option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) { $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']); } else { $price = false; } $product_option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'quantity' => $option_value['quantity'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->resize($option_value['image'], 50, 50), 'price' => $price, 'price_prefix' => $option_value['price_prefix'] ); } } $data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'value' => $option['value'], 'required' => $option['required'] ); } if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; } $data['review_status'] = $this->config->get('config_review_status'); if ($this->config->get('config_review_guest') || $this->customer->isLogged()) { $data['review_guest'] = true; } else { $data['review_guest'] = false; } if ($this->customer->isLogged()) { $data['customer_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); } else { $data['customer_name'] = ''; } $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $data['rating'] = (int)$product_info['rating']; // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha')); } else { $data['captcha'] = ''; } $data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']); $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')); } if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } if ($product_info['image']) {$imageaddit = $this->model_tool_image->resize($product_info['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} else {$imageaddit = $this->model_tool_image->resize('no_image.jpg', $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height'));} $imgs = $this->model_catalog_product->getProductImages($product_id); $imgt = array(); foreach ($imgs as $imgi) { $imgt[] = array( 'popup' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_related_width'), $this->config->get($this->config->get('config_theme') . '_image_related_height')), 'thumb' => $this->model_tool_image->resize($imgi['image'], $this->config->get($this->config->get('config_theme') . '_image_additional_width'), $this->config->get($this->config->get('config_theme') . '_image_additional_height')), ); } If ($product_info['price']!=0) {$priceecho=round((($product_info['price'] - $product_info['special'])/$product_info['price'])*100, 0);} else {$priceecho='';} if ((float)$product_info['special']) {if ($product_info['price'] > 0) {$sale = '<div class="stiker-module-special">'.$this->language->get('special_stikers').$priceecho. '<span>%</span>' . '</div>';} else {$sale = false;}} else {$sale = false;} if (($product_info['date_available']) > strftime('%Y-%m-%d',$timestamp)) {$new = '<div class="stiker-module-new">'.$this->language->get('new_stikers').'</div>';} else {$new = false;} if (($product_info['viewed']) > ($limit_viewed_popular_product)) {$popular = '<div class="stiker-module-popular">'.$this->language->get('popular_stikers').'</div>';} else {$popular = false;} $review_tots = $this->model_catalog_review->getTotalReviewsByProductId($product_id); $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'imageaddit' => $imageaddit, 'images' => $imgt, 'sale' => $sale, 'new' => $new, 'popular' => $popular, 'review_tot' => (int)$review_tots, 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) ); } $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $data['tags'][] = array( 'tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)) ); } } $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']); $this->model_catalog_product->updateViewed($this->request->get['product_id']); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('product/product', $data)); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['search'])) { $url .= '&search=' . $this->request->get['search']; } if (isset($this->request->get['tag'])) { $url .= '&tag=' . $this->request->get['tag']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['sub_category'])) { $url .= '&sub_category=' . $this->request->get['sub_category']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); $this->response->setOutput($this->load->view('error/not_found', $data)); } } public function review() { $this->load->language('product/product'); $this->load->model('catalog/review'); $data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->load->language('extension/module/langtemplates'); $data['napisal'] = $this->language->get('napisal'); $data['ot'] = $this->language->get('ot'); $data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $data['reviews'][] = array( 'author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int)$result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5)); $this->response->setOutput($this->load->view('product/review', $data)); } public function write() { $this->load->language('product/product'); $json = array(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { $json['error'] = $this->language->get('error_rating'); } // Captcha if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) { $captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate'); if ($captcha) { $json['error'] = $captcha; } } if (!isset($json['error'])) { $this->load->model('catalog/review'); $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } public function getRecurringDescription() { $this->load->language('product/product'); $this->load->model('catalog/product'); if (isset($this->request->post['product_id'])) { $product_id = $this->request->post['product_id']; } else { $product_id = 0; } if (isset($this->request->post['recurring_id'])) { $recurring_id = $this->request->post['recurring_id']; } else { $recurring_id = 0; } if (isset($this->request->post['quantity'])) { $quantity = $this->request->post['quantity']; } else { $quantity = 1; } $product_info = $this->model_catalog_product->getProduct($product_id); $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id); $json = array(); if ($product_info && $recurring_info) { if (!$json) { $frequencies = array( 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), ); if ($recurring_info['trial_status'] == 1) { $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' '; } else { $trial_text = ''; } $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); if ($recurring_info['duration']) { $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } else { $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']); } $json['success'] = $text; } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } } Надіслати Поділитися на інших сайтах More sharing options...
SAnet1989 Опубліковано: 6 червня 2017 Автор Share Опубліковано: 6 червня 2017 (змінено) <?php class ModelCatalogProduct extends Model { public function updateViewed($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'"); } public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return array( 'product_id' => $query->row['product_id'], 'name' => $query->row['name'], 'description' => $query->row['description'], 'meta_title' => $query->row['meta_title'], 'meta_h1' => $query->row['meta_h1'], 'meta_description' => $query->row['meta_description'], 'meta_keyword' => $query->row['meta_keyword'], 'tag' => $query->row['tag'], 'model' => $query->row['model'], 'sku' => $query->row['sku'], 'upc' => $query->row['upc'], 'ean' => $query->row['ean'], 'jan' => $query->row['jan'], 'isbn' => $query->row['isbn'], 'mpn' => $query->row['mpn'], 'location' => $query->row['location'], 'quantity' => $query->row['quantity'], 'stock_status' => $query->row['stock_status'], 'image' => $query->row['image'], 'manufacturer_id' => $query->row['manufacturer_id'], 'manufacturer' => $query->row['manufacturer'], 'price' => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']), 'special' => $query->row['special'], 'reward' => $query->row['reward'], 'points' => $query->row['points'], 'tax_class_id' => $query->row['tax_class_id'], 'date_available' => $query->row['date_available'], 'weight' => $query->row['weight'], 'weight_class_id' => $query->row['weight_class_id'], 'length' => $query->row['length'], 'width' => $query->row['width'], 'height' => $query->row['height'], 'length_class_id' => $query->row['length_class_id'], 'subtract' => $query->row['subtract'], 'rating' => round($query->row['rating']), 'reviews' => $query->row['reviews'] ? $query->row['reviews'] : 0, 'minimum' => $query->row['minimum'], 'sort_order' => $query->row['sort_order'], 'status' => $query->row['status'], 'date_added' => $query->row['date_added'], 'date_modified' => $query->row['date_modified'], 'viewed' => $query->row['viewed'] ); } else { return false; } } public function getProducts($data = array()) { $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $sql .= " GROUP BY p.product_id"; $sort_data = array( 'pd.name', 'p.model', 'p.quantity', 'p.price', 'rating', 'p.sort_order', 'p.date_added' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductSpecials($data = array()) { $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; $sort_data = array( 'pd.name', 'p.model', 'ps.price', 'rating', 'p.sort_order' ); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; } if (isset($data['order']) && ($data['order'] == 'DESC')) { $sql .= " DESC, LCASE(pd.name) DESC"; } else { $sql .= " ASC, LCASE(pd.name) ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $product_data = array(); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getLatestProducts($limit) { $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getPopularProducts($limit) { $product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getBestSellerProducts($limit) { $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit); if (!$product_data) { $product_data = array(); $query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data); } return $product_data; } public function getProductAttributes($product_id) { $product_attribute_group_data = array(); $product_attribute_group_query = $this->db->query("SELECT ag.attribute_group_id, agd.name FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_group ag ON (a.attribute_group_id = ag.attribute_group_id) LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE pa.product_id = '" . (int)$product_id . "' AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY ag.attribute_group_id ORDER BY ag.sort_order, agd.name"); foreach ($product_attribute_group_query->rows as $product_attribute_group) { $product_attribute_data = array(); $product_attribute_query = $this->db->query("SELECT a.attribute_id, ad.name, pa.text FROM " . DB_PREFIX . "product_attribute pa LEFT JOIN " . DB_PREFIX . "attribute a ON (pa.attribute_id = a.attribute_id) LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE pa.product_id = '" . (int)$product_id . "' AND a.attribute_group_id = '" . (int)$product_attribute_group['attribute_group_id'] . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pa.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY a.sort_order, ad.name"); foreach ($product_attribute_query->rows as $product_attribute) { $product_attribute_data[] = array( 'attribute_id' => $product_attribute['attribute_id'], 'name' => $product_attribute['name'], 'text' => $product_attribute['text'] ); } $product_attribute_group_data[] = array( 'attribute_group_id' => $product_attribute_group['attribute_group_id'], 'name' => $product_attribute_group['name'], 'attribute' => $product_attribute_data ); } return $product_attribute_group_data; } public function getProductOptions($product_id) { $product_option_data = array(); $product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order"); foreach ($product_option_query->rows as $product_option) { $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order"); foreach ($product_option_value_query->rows as $product_option_value) { $product_option_value_data[] = array( 'product_option_value_id' => $product_option_value['product_option_value_id'], 'option_value_id' => $product_option_value['option_value_id'], 'name' => $product_option_value['name'], 'image' => $product_option_value['image'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'price' => $product_option_value['price'], 'price_prefix' => $product_option_value['price_prefix'], 'weight' => $product_option_value['weight'], 'weight_prefix' => $product_option_value['weight_prefix'] ); } $product_option_data[] = array( 'product_option_id' => $product_option['product_option_id'], 'product_option_value' => $product_option_value_data, 'option_id' => $product_option['option_id'], 'name' => $product_option['name'], 'type' => $product_option['type'], 'value' => $product_option['value'], 'required' => $product_option['required'] ); } return $product_option_data; } public function getProductDiscounts($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC"); return $query->rows; } public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC"); return $query->rows; } public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { $product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } public function getProductLayoutId($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'"); if ($query->num_rows) { return $query->row['layout_id']; } else { return 0; } } public function getCategories($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; } public function getTotalProducts($data = array()) { $sql = "SELECT COUNT(DISTINCT p.product_id) AS total"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)"; } else { $sql .= " FROM " . DB_PREFIX . "product_to_category p2c"; } if (!empty($data['filter_filter'])) { $sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)"; } else { $sql .= " LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)"; } } else { $sql .= " FROM " . DB_PREFIX . "product p"; } $sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"; if (!empty($data['filter_category_id'])) { if (!empty($data['filter_sub_category'])) { $sql .= " AND cp.path_id = '" . (int)$data['filter_category_id'] . "'"; } else { $sql .= " AND p2c.category_id = '" . (int)$data['filter_category_id'] . "'"; } if (!empty($data['filter_filter'])) { $implode = array(); $filters = explode(',', $data['filter_filter']); foreach ($filters as $filter_id) { $implode[] = (int)$filter_id; } $sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")"; } } if (!empty($data['filter_name']) || !empty($data['filter_tag'])) { $sql .= " AND ("; if (!empty($data['filter_name'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_name']))); foreach ($words as $word) { $implode[] = "pd.name LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } if (!empty($data['filter_description'])) { $sql .= " OR pd.description LIKE '%" . $this->db->escape($data['filter_name']) . "%'"; } } if (!empty($data['filter_name']) && !empty($data['filter_tag'])) { $sql .= " OR "; } if (!empty($data['filter_tag'])) { $implode = array(); $words = explode(' ', trim(preg_replace('/\s+/', ' ', $data['filter_tag']))); foreach ($words as $word) { $implode[] = "pd.tag LIKE '%" . $this->db->escape($word) . "%'"; } if ($implode) { $sql .= " " . implode(" AND ", $implode) . ""; } } if (!empty($data['filter_name'])) { $sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.upc) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.ean) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.jan) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.isbn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; $sql .= " OR LCASE(p.mpn) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'"; } $sql .= ")"; } if (!empty($data['filter_manufacturer_id'])) { $sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getProfile($product_id, $recurring_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring r JOIN " . DB_PREFIX . "product_recurring pr ON (pr.recurring_id = r.recurring_id AND pr.product_id = '" . (int)$product_id . "') WHERE pr.recurring_id = '" . (int)$recurring_id . "' AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "'"); return $query->row; } public function getProfiles($product_id) { $query = $this->db->query("SELECT rd.* FROM " . DB_PREFIX . "product_recurring pr JOIN " . DB_PREFIX . "recurring_description rd ON (rd.language_id = " . (int)$this->config->get('config_language_id') . " AND rd.recurring_id = pr.recurring_id) JOIN " . DB_PREFIX . "recurring r ON r.recurring_id = rd.recurring_id WHERE pr.product_id = " . (int)$product_id . " AND status = '1' AND pr.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' ORDER BY sort_order ASC"); return $query->rows; } public function getTotalProductSpecials() { $query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW()))"); if (isset($query->row['total'])) { return $query->row['total']; } else { return 0; } } } Змінено 6 червня 2017 користувачем SAnet1989 Надіслати Поділитися на інших сайтах More sharing options...
thentru Опубліковано: 6 червня 2017 Share Опубліковано: 6 червня 2017 тут не вижу ничего особого дайте ссылку на сайт Надіслати Поділитися на інших сайтах More sharing options...
Recommended Posts