I’m building (php + mySQL) an app which uses product specs in order to generate product title outside Magento.
Currently my code is like this:
//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>';
}
The code above doesn’t have all the attributes I need, so I’ve looked in the Magento database using phpMyAdmin, but I couldn’t find the corresponding attribute_id of some product attributes that I’m seeing in Magento’s backend. Is there a way to view all the attributes and their corresponding attribute_id’s?
You can find ids of all eav attributes in
eav_attributetable. But I suggest you to select data fromcatalog_product_flat_1(2,3,...)table in your case. Each product attribute is added there as separate column by indexer. That’s why there is no need to run query with many joins.