[email protected] Posted June 27, 2019 Share Posted June 27, 2019 Buenas. Estoy buscando la consulta de donde sale la lista de productos de una categoría. El template que lo muestra veo que es TEMPLATE\templates\catalog\_partials\products.tpl pero esa consulta de donde sale? muchas gracias. Link to comment Share on other sites More sharing options...
UniArt Posted July 10, 2019 Share Posted July 10, 2019 Si es para listar productos en un modulo o algo así de normal puedes usar getProducts() en ->classes->product.php-> public static function getProducts. public static function getProducts( $id_lang, $start, $limit, $order_by, $order_way, $id_category = false, $only_active = false, Context $context = null ) { if (!$context) { $context = Context::getContext(); } $front = true; if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) { $front = false; } if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) { die(Tools::displayError()); } if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') { $order_by_prefix = 'p'; } elseif ($order_by == 'name') { $order_by_prefix = 'pl'; } elseif ($order_by == 'position') { $order_by_prefix = 'c'; } if (strpos($order_by, '.') > 0) { $order_by = explode('.', $order_by); $order_by_prefix = $order_by[0]; $order_by = $order_by[1]; } $sql = 'SELECT p.*, product_shop.*, pl.* , m.`name` AS manufacturer_name, s.`name` AS supplier_name FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') . ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` ' . Shop::addSqlRestrictionOnLang('pl') . ') LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) LEFT JOIN `' . _DB_PREFIX_ . 'supplier` s ON (s.`id_supplier` = p.`id_supplier`)' . ($id_category ? 'LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c ON (c.`id_product` = p.`id_product`)' : '') . ' WHERE pl.`id_lang` = ' . (int) $id_lang . ($id_category ? ' AND c.`id_category` = ' . (int) $id_category : '') . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . ($only_active ? ' AND product_shop.`active` = 1' : '') . ' ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way) . ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : ''); $rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); if ($order_by == 'price') { Tools::orderbyPrice($rq, $order_way); } foreach ($rq as &$row) { $row = Product::getTaxesInformations($row); } return $rq; } Tambien puedes encontrar algo aqui: protected function getAjaxProductSearchVariables() en classes->controller->ProductListingFrontController.php que al parecer es donde se genera la variable $listing del tpl que mencionas: protected function getAjaxProductSearchVariables() { $search = $this->getProductSearchVariables(); $rendered_products_top = $this->render('catalog/_partials/products-top', array('listing' => $search)); $rendered_products = $this->render('catalog/_partials/products', array('listing' => $search)); $rendered_products_bottom = $this->render('catalog/_partials/products-bottom', array('listing' => $search)); $data = array_merge( array( 'rendered_products_top' => $rendered_products_top, 'rendered_products' => $rendered_products, 'rendered_products_bottom' => $rendered_products_bottom, ), $search ); if (!empty($data['products']) && is_array($data['products'])) { $data['products'] = $this->prepareProductArrayForAjaxReturn($data['products']); } return $data; } Espero haber ayudado más que enredar, a saber donde están las cosas en PS 1.7.... 1 Link to comment Share on other sites More sharing options...
[email protected] Posted July 10, 2019 Author Share Posted July 10, 2019 Ante todo muchisimas gracias @UniArt por el aporte. Lo voy a estudiar con calma en cuanto pueda, ya que estas fechas es un lio. Un saludo. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now