Привет, помогите с сортировкой акций вот сайт http://www.komandor-marine.ru/Спецпредложения:special.php PHP: <?php class ControllerModuleSpecial extends Controller { protected function index($setting) { $this->language->load('module/special'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['button_cart'] = $this->language->get('button_cart'); $this->load->model('catalog/product'); $this->load->model('tool/image'); $this->data['products'] = array(); $data = array( 'sort' => 'pd.name', 'order' => 'ASC', 'start' => 0, 'limit' => $setting['limit'] ); $results = $this->model_catalog_product->getProductSpecials($data); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']); } else { $image = false; } if (($this->config->get('config_customer_price') && $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'))); } 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'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = $result['rating']; } else { $rating = false; } $options = $this->config->get('attribute_to_text_options'); if (isset($options['show_catalog_attributes'])) { $this->load->model('catalog/attributes_to_text'); $description = $this->model_catalog_attributes_to_text->getText($result['product_id'], $options); } $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, 'description' => $description, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']), ); } if (!empty($this->data['products'][0])) { $temp = $this->data['products'][0]; $this->data['products'][] = $temp; unset($this->data['products'][0]); } if (!empty($this->data['products'][1])) { $temp = $this->data['products'][1]; $this->data['products'][] = $temp; unset($this->data['products'][1]); } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/special.tpl')) { $this->template = $this->config->get('config_template') . '/template/module/special.tpl'; } else { $this->template = 'default/template/module/special.tpl'; } $this->render(); } } ?> пробывал менять 'sort' => 'pd.name', на 'sort' => 'p.price', и 'sort' => 'pd.price', - не помогло
catalog/controller/product/special.php поменяйте Код: $sort = 'p.sort_order' на Код: $sort = 'p.price'
Уважаемый, не стоит хамить. Лучше замените HTML: if (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { $sort = 'p.sort_order'; } на Код: if (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { $sort = 'ps.price'; } в special.php и все наладится
я не хамлю, просто реально там нету PHP: if (isset($this->request->get['sort'])) {$sort = $this->request->get['sort'];} else {$sort = 'p.sort_order';} вот мой special.php PHP: <?php class ControllerModuleSpecial extends Controller { protected function index($setting) { $this->language->load('module/special'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['button_cart'] = $this->language->get('button_cart'); $this->load->model('catalog/product'); $this->load->model('tool/image'); $this->data['products'] = array(); $data = array( 'sort' => 'pd.name', 'order' => 'ASC', 'start' => 0, 'limit' => $setting['limit'] ); $results = $this->model_catalog_product->getProductSpecials($data); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']); } else { $image = false; } if (($this->config->get('config_customer_price') && $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'))); } 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'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = $result['rating']; } else { $rating = false; } $options = $this->config->get('attribute_to_text_options'); if (isset($options['show_catalog_attributes'])) { $this->load->model('catalog/attributes_to_text'); $description = $this->model_catalog_attributes_to_text->getText($result['product_id'], $options); } $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, 'description' => $description, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']), ); } if (!empty($this->data['products'][0])) { $temp = $this->data['products'][0]; $this->data['products'][] = $temp; unset($this->data['products'][0]); } if (!empty($this->data['products'][1])) { $temp = $this->data['products'][1]; $this->data['products'][] = $temp; unset($this->data['products'][1]); } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/special.tpl')) { $this->template = $this->config->get('config_template') . '/template/module/special.tpl'; } else { $this->template = 'default/template/module/special.tpl'; } $this->render(); } } ?>
Мы говорим о class ControllerModuleSpecial - тоесть модуле "Спец. предложений"... Найди свой кусок кода в данном контроллере и замени на: Код: $data = array( 'sort' => 'p.price-ASC', 'order' => 'ASC', 'start' => 0, 'limit' => $setting['limit'] );
заменил PHP: $data = array('sort' => 'pd.name','order' => 'ASC','start' => 0,'limit' => $setting['limit']); на PHP: $data = array('sort' => 'pd.name','order' => 'ASC','start' => 0,'limit' => $setting['limit']); не помогло
По цене можно сортировать по 2 методам: 1. по цене товара 2. по цене акционого товара(скидка) Если первый метод то делаем так: Открываем файл catalog/model/catalog/product.php в нем ищем функцию getProductSpecials и в ней массив sort_data, в него после строки PHP: 'p.model', вставляем строку PHP: 'p.price', и потом в файле catalog/controller/module/special.php строку PHP: 'sort' => 'pd.name', меняем на PHP: 'sort' => 'p.price', Если второй метод то в файле catalog/controller/module/special.php строку PHP: 'sort' => 'pd.name', меняем на PHP: 'ps.price', Если нужно соберу vqmod