我会将产品列出到指定的类别,但它可以正常工作。我认为它在SQL查询中的任何地方都有错误...
$query = "
SELECT
cat.`name_".$language."` AS catname,
cat.category_id AS category_id,
prod.`name_".$language."` AS prodname,
prod.product_id AS product_id
FROM
`#__jshopping_products` AS prod
INNER JOIN
`#__jshopping_products_to_categories` AS pr_cat
ON
pr_cat.product_id = prod.product_id
LEFT JOIN
`#__jshopping_categories` AS cat
ON
pr_cat.category_id = cat.category_id
WHERE
prod.product_publish = '1'
AND
cat.category_publish='1'
AND
pr_cat.product_id = prod.product_id
";
$db->setQuery($query);
$row = $db->loadObjectList();
foreach ($row as $value) {
print_r("Katname: ".$value->catname."<br>Produkte zur Kategorie: ".$value->prodname."<br><br>");
}
sql tables
categories
category_id, name
products
product_id, name
products_to_categories
category_id, product_id
print_r显示:
Katname: Wandbilder
Produkte: Acryl Schild
Katname: Dekoration
Produkte: Pappdisplay
Katname: Wandbilder
Produkte: Pappdisplay
Katname: Dekoration
Produkte: Foto-Tischläufer & Tischdecke
...
我会打印例如。
Katname: Wandbilder Produkte: Acryl Schild, Pappdisplay, ...
Katname: Dekoration Produkte: Pappdisplay, Foto-Tischläufer & Tischdecke, ...
....
有人可以帮忙吗?
答案 0 :(得分:0)
$query = "
SELECT
cat.
name_".$language."
AS catname,
cat.category_id AS category_id
FROM
#__jshopping_categories
AS cat
name_".$language."
#__jshopping_categories