gpt4 book ai didi

mySQL:如何获取产品属性的 attribute_id?

转载 作者:行者123 更新时间:2023-11-29 07:05:01 24 4
gpt4 key购买 nike

我正在构建 (php + mySQL) 一个使用产品规范的应用程序,以便在 Magento 之外生成产品标题。目前我的代码是这样的:

    //select attributes
$sql = "SELECT DISTINCT P.entity_id, P.sku, V.value AS Name, T2.value AS ShortDesc, D.value AS Price
FROM catalog_product_entity AS P INNER JOIN
catalog_product_entity_varchar AS V ON P.entity_id = V.entity_id AND V.attribute_id = 60 LEFT JOIN
catalog_product_entity_text AS T2 ON P.entity_id = T2.entity_id AND T2.attribute_id = 62 LEFT JOIN
catalog_product_entity_decimal AS D ON P.entity_id = D.entity_id AND D.attribute_id = 64";

//Run the query
$query = mysql_query($sql);

//Loop through and print each products info
while($row = mysql_fetch_array($query))
{
echo '<p>';
echo $row['entity_id']." - ".$row['sku']." - ".$row['Name']." - ".$row['ShortDesc']." - ".$row['Price'];
echo '</p>';
}

上面的代码没有我需要的所有属性,所以我使用 phpMyAdmin 查看了 Magento 数据库,但我找不到我在 Magento 后端看到的某些产品属性的相应 attribute_id。有没有办法查看所有属性及其对应的 attribute_id?

最佳答案

您可以在 eav_attribute 表中找到所有 eav 属性的 ID。但我建议您根据您的情况从 catalog_product_flat_1(2,3,...) 表中选择数据。索引器将每个产品属性添加为单独的列。这就是为什么不需要使用许多连接运行查询的原因。

关于mySQL:如何获取产品属性的 attribute_id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7866453/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com