Answer the question
In order to leave comments, you need to log in
Can you help me find a bug in PHP code?
Good afternoon everyone,
Now I am redoing one module for Opencart and the task is to connect to the database.
Any ideas why it doesn't work?
The information that I pull out of the database is in category_description>type_prefix .
Here is the original code:
public function getProducts($allowed_categories, $vendor_required = false) {
$query = $this->db->query("SELECT p.*, pd.name, pd.description, m.name AS manufacturer, p2c.category_id, IFNULL (ps.price, p.price) AS price, ps.price AS special, wcd.unit AS weight_unit,
GROUP_CONCAT(DISTINCT CAST(pr.related_id AS CHAR) SEPARATOR ',') AS rel
FROM " . DB_PREFIX . "product p JOIN " . DB_PREFIX . "product_to_category AS p2c ON (p.product_id = p2c.product_id)
" . ($vendor_required ? '' : 'LEFT ') . "JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m. manufacturer_id)
LEFT JOIN " .DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
...
GROUP BY p.product_id");
return $query->rows;
}
public function getProducts($allowed_categories, $vendor_required = false) {
$query = $this->db->query("SELECT p.*, pd.name, pd.description, pd.type_prefix , m.name AS manufacturer, p2c .category_id, IFNULL(ps.price, p.price) AS price, ps.price AS special, wcd.unit AS weight_unit,
GROUP_CONCAT(DISTINCT CAST(pr.related_id AS CHAR) SEPARATOR ',') AS rel
FROM " . DB_PREFIX . "product p JOIN " . DB_PREFIX . "product_to_category AS p2c ON (p.product_id = p2c.product_id)
" . ($vendor_required ? '' : 'LEFT ') . "JOIN " . DB_PREFIX . "manufacturer m ON (p. manufacturer_id = m.manufacturer_id)
LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN " . DB_PREFIX . "category_description pd ON (p.type_prefix = pd.type_prefix)
...
GROUP BY p.product_id");
return $query->rows;
}
$allowed = array('url', 'price', 'currencyId', 'categoryId', 'picture', 'store', 'pickup', 'delivery', 'name', 'typePrefix', 'vendor', 'vendorCode', ‘model’...
$data['currencyId'] = $currency_default['code'];
$data['categoryId'] = $product['category_id'];
$data['typePrefix'] = $oc_category_description['type_prefix’]; //Вот сюда. Здесь пытался вывести значение.
$data['vendor'] = $product['manufacturer'];
$data['vendorCode'] = $product['model'];
Answer the question
In order to leave comments, you need to log in
LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN " . DB_PREFIX . "category_description pd ON (p.type_prefix = pd.type_prefix)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question