public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
 {
     $orderByPriceFinal = empty($orderBy) ? Tools::getValue($this->table . 'Orderby', 'id_' . $this->table) : $orderBy;
     $orderWayPriceFinal = empty($orderWay) ? Tools::getValue($this->table . 'Orderway', 'ASC') : $orderWay;
     if ($orderByPriceFinal == 'price_final') {
         $orderBy = 'id_' . $this->table;
         $orderWay = 'ASC';
     }
     parent::getList($id_lang, $orderBy, $orderWay, $start, $limit);
     /* update product quantity with attributes ...*/
     if ($this->_list) {
         $nb = count($this->_list);
         for ($i = 0; $i < $nb; $i++) {
             Attribute::updateQtyProduct($this->_list[$i]);
         }
         /* update product final price */
         for ($i = 0; $i < $nb; $i++) {
             $this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], $usetax = true, $id_product_attribute = NULL, $decimals = 6, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1, $forceAssociatedTax = true);
         }
     }
     if ($orderByPriceFinal == 'price_final') {
         if (strtolower($orderWayPriceFinal) == 'desc') {
             uasort($this->_list, 'cmpPriceDesc');
         } else {
             uasort($this->_list, 'cmpPriceAsc');
         }
     }
     for ($i = 0; $this->_list and $i < $nb; $i++) {
         $this->_list[$i]['price_final'] = $this->_list[$i]['price_tmp'];
         unset($this->_list[$i]['price_tmp']);
     }
 }
Exemplo n.º 2
0
 public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
 {
     global $cookie;
     $orderByPriceFinal = empty($orderBy) ? $cookie->__get($this->table . 'Orderby') ? $cookie->__get($this->table . 'Orderby') : 'id_' . $this->table : $orderBy;
     $orderWayPriceFinal = empty($orderWay) ? $cookie->__get($this->table . 'Orderway') ? $cookie->__get($this->table . 'Orderby') : 'ASC' : $orderWay;
     if ($orderByPriceFinal == 'price_final') {
         $orderBy = 'id_' . $this->table;
         $orderWay = 'ASC';
     }
     parent::getList($id_lang, $orderBy, $orderWay, $start, $limit);
     /* update product quantity with attributes ...*/
     if ($this->_list) {
         $nb = count($this->_list);
         for ($i = 0; $i < $nb; $i++) {
             Attribute::updateQtyProduct($this->_list[$i]);
         }
         /* update product final price */
         for ($i = 0; $i < $nb; $i++) {
             $this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, NULL, 6, NULL, false, true, 1, true);
         }
     }
     if ($orderByPriceFinal == 'price_final') {
         if (strtolower($orderWayPriceFinal) == 'desc') {
             uasort($this->_list, 'cmpPriceDesc');
         } else {
             uasort($this->_list, 'cmpPriceAsc');
         }
     }
     for ($i = 0; $this->_list and $i < $nb; $i++) {
         $this->_list[$i]['price_final'] = $this->_list[$i]['price_tmp'];
         unset($this->_list[$i]['price_tmp']);
     }
 }
 public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
 {
     parent::getList((int) $id_lang, $orderBy, $orderWay, $start, $limit);
     if (sizeof($this->_list)) {
         $this->_productAttachements = Attachment::getProductAttached((int) $id_lang, $this->_list);
     }
 }
 public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
 {
     global $cookie;
     return parent::getList((int) $cookie->id_lang, !Tools::getValue($this->table . 'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table . 'Orderway') ? 'DESC' : NULL);
 }
Exemplo n.º 5
0
 public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
 {
     global $cookie;
     parent::getList((int) $cookie->id_lang, !$cookie->__get($this->table . 'Orderby') ? 'position' : NULL, !$cookie->__get($this->table . 'Orderway') ? 'ASC' : NULL);
 }
Exemplo n.º 6
0
    public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
    {
        parent::getList($id_lang, $orderBy, $orderWay, $start, $limit);
        global $cookie;
        /* Manage default params values */
        if (empty($limit)) {
            $limit = !isset($cookie->{$this->table . '_pagination'}) ? $this->_pagination[0] : ($limit = $cookie->{$this->table . '_pagination'});
        }
        if (!Validate::isTableOrIdentifier($this->table)) {
            die('filter is corrupted');
        }
        if (empty($orderBy)) {
            $orderBy = Tools::getValue($this->table . 'Orderby', 'id_' . $this->table);
        }
        if (empty($orderWay)) {
            $orderWay = Tools::getValue($this->table . 'Orderway', 'ASC');
        }
        $limit = intval(Tools::getValue('pagination', $limit));
        $cookie->{$this->table . '_pagination'} = $limit;
        /* Check params validity */
        if (!Validate::isOrderBy($orderBy) or !Validate::isOrderWay($orderWay) or !is_numeric($start) or !is_numeric($limit) or !Validate::isUnsignedId($id_lang)) {
            die(Tools::displayError('get list params is not valid'));
        }
        /* Determine offset from current page */
        if ((isset($_POST['submitFilter' . $this->table]) or isset($_POST['submitFilter' . $this->table . '_x']) or isset($_POST['submitFilter' . $this->table . '_y'])) and !empty($_POST['submitFilter' . $this->table]) and is_numeric($_POST['submitFilter' . $this->table])) {
            $start = intval($_POST['submitFilter' . $this->table] - 1) * $limit;
        }
        /* Cache */
        $this->_lang = intval($id_lang);
        $this->_orderBy = $orderBy;
        $this->_orderWay = Tools::strtoupper($orderWay);
        /* SQL table : orders, but class name is Order */
        $sqlTable = $this->table == 'order' ? 'orders' : $this->table;
        /* Query in order to get results number */
        $queryTotal = Db::getInstance()->getRow('
		SELECT COUNT(a.`id_' . $this->table . '`) AS total
		FROM `' . _DB_PREFIX_ . $sqlTable . '` a
		' . ($this->lang ? 'LEFT JOIN `' . _DB_PREFIX_ . $this->table . '_lang` b ON (b.`id_' . $this->table . '` = a.`id_' . $this->table . '` AND b.`id_lang` = ' . intval($id_lang) . ')' : '') . ' 
		' . (isset($this->_join) ? $this->_join . ' ' : '') . '
		WHERE 1 ' . (isset($this->_where) ? $this->_where . ' ' : '') . (($this->deleted or $this->table == 'currency') ? 'AND a.`deleted` = 0 ' : '') . $this->_filter . ' 
		' . (isset($this->_group) ? $this->_group . ' ' : '') . '
		' . (isset($this->addressType) ? 'AND a.id_' . strval($this->addressType) . ' != 0' : ''));
        $this->_listTotal = intval($queryTotal['total']);
        /* Query in order to get results with all fields */
        $this->_list = Db::getInstance()->ExecuteS('
		SELECT a.*' . ($this->lang ? ', b.*' : '') . (isset($this->_select) ? ', ' . $this->_select . ' ' : '') . ' 
		FROM `' . _DB_PREFIX_ . $sqlTable . '` a 
		' . ($this->lang ? 'LEFT JOIN `' . _DB_PREFIX_ . $this->table . '_lang` b ON (b.`id_' . $this->table . '` = a.`id_' . $this->table . '` AND b.`id_lang` = ' . intval($id_lang) . ')' : '') . ' 
		' . (isset($this->_join) ? $this->_join . ' ' : '') . '
		WHERE 1 ' . (isset($this->_where) ? $this->_where . ' ' : '') . (($this->deleted or $this->table == 'currency') ? 'AND a.`deleted` = 0 ' : '') . $this->_filter . ' 
		' . (isset($this->_group) ? $this->_group . ' ' : '') . '
		' . (isset($this->addressType) ? 'AND a.id_' . strval($this->addressType) . ' != 0' : '') . '
		ORDER BY ' . ($orderBy == 'id_' . $this->table ? 'a.' : '') . '`' . pSQL($orderBy) . '` ' . pSQL($orderWay) . ' 
		LIMIT ' . intval($start) . ',' . intval($limit));
    }