【问题标题】:mySQL: How can I get the attribute_id of a product attribute?mySQL:如何获取产品属性的attribute_id?
【发布时间】:2011-10-23 13:38:03
【问题描述】:

我正在构建(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 的后端中找不到一些产品属性的相应属性 ID。有没有办法查看所有属性及其对应的attribute_id?

【问题讨论】:

    标签: mysql magento magento-1.4 magento-1.5 entity-attribute-value


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-16
      • 2016-05-10
      • 1970-01-01
      • 2014-07-16
      • 1970-01-01
      相关资源
      最近更新 更多