Jump to content

Edit History

TinoArts

TinoArts

@EvaF Unfortunately I am still getting "No products found" error. This is the whole getQuery() function from MySQL.php, if that will be of any help to you to debug the issue:

 

    public function getQuery()
    {
        $filterToTableMapping = $this->getFieldMapping();
        $orderField = $this->computeOrderByField($filterToTableMapping);

        if ($this->getInitialPopulation() === null) {
            $referenceTable = _DB_PREFIX_ . 'product';
        } else {
            $referenceTable = '(' . $this->getInitialPopulation()->getQuery() . ')';
        }

        $query = 'SELECT ';

        $selectFields = $this->computeSelectFields($filterToTableMapping);
        $selectFields[]='warehousequantity';
        $whereConditions = $this->computeWhereConditions($filterToTableMapping);
        $joinConditions = $this->computeJoinConditions($filterToTableMapping);
        $groupFields = $this->computeGroupByFields($filterToTableMapping);

        $query .= implode(', ', $selectFields) . ' FROM ' . $referenceTable . ' p';

        foreach ($joinConditions as $joinAliasInfos) {
            foreach ($joinAliasInfos as $tableAlias => $joinInfos) {
                $query .= ' ' . $joinInfos['joinType'] . ' ' . _DB_PREFIX_ . $joinInfos['tableName'] . ' ' .
                       $tableAlias . ' ON ' . $joinInfos['joinCondition'];
            }
        }

        $query .= ' JOIN ( SELECT aps.id_product,
            concat(aps.warehouse+100000,110000000-asa.quantity ) as warehousequantity  
            FROM ' . _DB_PREFIX_ .'product_shop aps
            INNER JOIN ' . _DB_PREFIX_ .'stock_available asa ON aps.id_product = asa.id_product ) ws ON p.id_product = ws.id_product ';

        if (!empty($whereConditions)) {
            $query .= ' WHERE ' . implode(' AND ', $whereConditions);
        }

        if ($groupFields) {
            $query .= ' GROUP BY ' . implode(', ', $groupFields);
        }

        if ($orderField) {
            $query .= ' ORDER BY ' . $orderField . ' ' . strtoupper($this->getOrderDirection());
        }

        if ($this->limit !== null) {
            $query .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
        }

        return $query;
    }

 

Again, I tried to add 'SELECT * FROM ps_product_shop' right before your query and run it in phpMyAdmin like this (rest of the query is the same as yours above):

SELECT * FROM ps_product_shop JOIN ( SELECT aps.id_product,
            concat(aps.warehouse+100000,110000000-asa.quantity ) as warehousequantity  
            FROM ps_product_shop aps
            INNER JOIN ps_stock_available asa ON aps.id_product = asa.id_product ) ws ON p.id_product = ws.id_product

But I am getting this error:

#1054 - Unknown column 'p.id_product' in 'on clause'

 

TinoArts

TinoArts

@EvaF Unfortunately I am still getting "No products found" error. This is the whole getQuery() function from MySQL.php, if that will be of any help to you to debug the issue:

 

    public function getQuery()
    {
        $filterToTableMapping = $this->getFieldMapping();
        $orderField = $this->computeOrderByField($filterToTableMapping);

        if ($this->getInitialPopulation() === null) {
            $referenceTable = _DB_PREFIX_ . 'product';
        } else {
            $referenceTable = '(' . $this->getInitialPopulation()->getQuery() . ')';
        }

        $query = 'SELECT ';

        $selectFields = $this->computeSelectFields($filterToTableMapping);
        $selectFields[]='warehousequantity';
        $whereConditions = $this->computeWhereConditions($filterToTableMapping);
        $joinConditions = $this->computeJoinConditions($filterToTableMapping);
        $groupFields = $this->computeGroupByFields($filterToTableMapping);

        $query .= implode(', ', $selectFields) . ' FROM ' . $referenceTable . ' p';

        foreach ($joinConditions as $joinAliasInfos) {
            foreach ($joinAliasInfos as $tableAlias => $joinInfos) {
                $query .= ' ' . $joinInfos['joinType'] . ' ' . _DB_PREFIX_ . $joinInfos['tableName'] . ' ' .
                       $tableAlias . ' ON ' . $joinInfos['joinCondition'];
            }
        }

        $query .= ' JOIN ( SELECT aps.id_product,
            concat(aps.warehouse+100000,110000000-asa.quantity ) as warehousequantity  
            FROM ' . _DB_PREFIX_ .'product_shop aps
            INNER JOIN ' . _DB_PREFIX_ .'stock_available asa ON aps.id_product = asa.id_product ) ws ON p.id_product = ws.id_product ';

        if (!empty($whereConditions)) {
            $query .= ' WHERE ' . implode(' AND ', $whereConditions);
        }

        if ($groupFields) {
            $query .= ' GROUP BY ' . implode(', ', $groupFields);
        }

        if ($orderField) {
            $query .= ' ORDER BY ' . $orderField . ' ' . strtoupper($this->getOrderDirection());
        }

        if ($this->limit !== null) {
            $query .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
        }

        return $query;
    }

 

Again, I tried to add 'SELECT * FROM ps_product_shop' right before your query and run it in phpMyAdmin like this:

SELECT * FROM ps_stock_available JOIN ( SELECT aps.id_product,
            concat(aps.warehouse+100000,110000000-asa.quantity ) as warehousequantity  
            FROM ps_product_shop aps
            INNER JOIN ps_stock_available asa ON aps.id_product = asa.id_product ) ws ON p.id_product = ws.id_product

But I am getting this error:

#1054 - Unknown column 'p.id_product' in 'on clause'

 

TinoArts

TinoArts

@EvaF Unfortunately I am still getting "No products found" error. This is the whole getQuery() function from MySQL.php, if that will be of any help to you to debug the issue:

 

    public function getQuery()
    {
        $filterToTableMapping = $this->getFieldMapping();
        $orderField = $this->computeOrderByField($filterToTableMapping);

        if ($this->getInitialPopulation() === null) {
            $referenceTable = _DB_PREFIX_ . 'product';
        } else {
            $referenceTable = '(' . $this->getInitialPopulation()->getQuery() . ')';
        }

        $query = 'SELECT ';

        $selectFields = $this->computeSelectFields($filterToTableMapping);
        $selectFields[]='warehousequantity';
        $whereConditions = $this->computeWhereConditions($filterToTableMapping);
        $joinConditions = $this->computeJoinConditions($filterToTableMapping);
        $groupFields = $this->computeGroupByFields($filterToTableMapping);

        $query .= implode(', ', $selectFields) . ' FROM ' . $referenceTable . ' p';

        foreach ($joinConditions as $joinAliasInfos) {
            foreach ($joinAliasInfos as $tableAlias => $joinInfos) {
                $query .= ' ' . $joinInfos['joinType'] . ' ' . _DB_PREFIX_ . $joinInfos['tableName'] . ' ' .
                       $tableAlias . ' ON ' . $joinInfos['joinCondition'];
            }
        }

        $query .= ' JOIN ( SELECT aps.id_product,
            concat(aps.warehouse+100000,110000000-asa.quantity ) as warehousequantity  
            FROM ' . _DB_PREFIX_ .'product_shop aps
            INNER JOIN ' . _DB_PREFIX_ .'stock_available asa ON aps.id_product = asa.id_product ) ws ON p.id_product = ws.id_product ';

        if (!empty($whereConditions)) {
            $query .= ' WHERE ' . implode(' AND ', $whereConditions);
        }

        if ($groupFields) {
            $query .= ' GROUP BY ' . implode(', ', $groupFields);
        }

        if ($orderField) {
            $query .= ' ORDER BY ' . $orderField . ' ' . strtoupper($this->getOrderDirection());
        }

        if ($this->limit !== null) {
            $query .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
        }

        return $query;
    }

 

×
×
  • Create New...