如何通过 PHP 从数据库中获取完整的 url 类别和产品列表?
How to get list of full url categories and products in it, via PHP from database?
我想通过 Php 从数据库中获取 Opencart 3.0.3.2 中完整的 url 产品列表:
示例:
http://example.com/index.php?route=product/product&path=20_27&product_id=39
http://example.com/index.php?route=product/product&path=25_28&product_id=40
http://example.com/index.php?route=product/product&path=25&product_id=41
http://example.com/index.php?route=product/product&path=24_28&product_id=42
...
等等。
当然,如果你告诉我如何获取它并以.xlsx 格式保存,那就太好了。让所有产品井然有序,即使没有数字顺序。只是链接!
在数据库中我有:'products_in_category' table 我有两列:
Product_id Category_id
28 20
28 24
29 20
29 24
30 25
30 24
32 26
.... and so on
如您所见,由于此产品在 'Parent category' 和 'subcategory'
上链接,因此重复出现相同的产品
但我需要没有重复的产品的完整路径!
期待结果 -> 文件 .xlsx(Excel) * 太棒了!或者只是 .txt 文件:
http://example.com/index.php?route=product/product&path=20_27&product_id=39
http://example.com/index.php?route=product/product&path=25_28&product_id=40
http://example.com/index.php?route=product/product&path=25&product_id=41
http://example.com/index.php?route=product/product&path=24_28&product_id=42
...
期待结果
您可以使用此 sql 语句
SELECT CONCAT("http://example.com/index.php?route=product/product&path=", GROUP_CONCAT(category_id SEPARATOR '_'), "&product_id=", product_id) AS 'Product_links' FROM `oc_product_to_category` GROUP BY product_id
我想通过 Php 从数据库中获取 Opencart 3.0.3.2 中完整的 url 产品列表:
示例:
http://example.com/index.php?route=product/product&path=20_27&product_id=39
http://example.com/index.php?route=product/product&path=25_28&product_id=40
http://example.com/index.php?route=product/product&path=25&product_id=41
http://example.com/index.php?route=product/product&path=24_28&product_id=42
...
等等。
当然,如果你告诉我如何获取它并以.xlsx 格式保存,那就太好了。让所有产品井然有序,即使没有数字顺序。只是链接!
在数据库中我有:'products_in_category' table 我有两列:
Product_id Category_id
28 20
28 24
29 20
29 24
30 25
30 24
32 26
.... and so on
如您所见,由于此产品在 'Parent category' 和 'subcategory'
上链接,因此重复出现相同的产品但我需要没有重复的产品的完整路径!
期待结果 -> 文件 .xlsx(Excel) * 太棒了!或者只是 .txt 文件:
http://example.com/index.php?route=product/product&path=20_27&product_id=39
http://example.com/index.php?route=product/product&path=25_28&product_id=40
http://example.com/index.php?route=product/product&path=25&product_id=41
http://example.com/index.php?route=product/product&path=24_28&product_id=42
...
期待结果
您可以使用此 sql 语句
SELECT CONCAT("http://example.com/index.php?route=product/product&path=", GROUP_CONCAT(category_id SEPARATOR '_'), "&product_id=", product_id) AS 'Product_links' FROM `oc_product_to_category` GROUP BY product_id