2

I am looking to get a collection of attribute text values (not option values) from this particular table: catalog_product_entity_varchar given a particular attribute_id (and entity_type_id). Preferably I would like to use magento collection models and not include any other information apart what is on this table.

I would like to follow this up by querying a particular value from this table as well as using LIKE based wildcards queries.

2 Answers 2

2

You can build a query using sql rather than the normal magento collection with the follow snippet.

$resource = Mage::getSingleton('core/resource');
/** @var Magento_Db_Adapter_Pdo_Mysql $readConnection */
$readConnection = $resource->getConnection('core_read');
$results = $readConnection->fetchAssoc('SELECT * FROM catalog_product_entity_varchar');

Obviously you should select only column you need and add the appropriate where etc but this will give you an array with all the information you need. It might not be the "best" idea but it will be functioning.

0
<pre>
$attributes = Mage::getSingleton('eav/config')
    ->getEntityType(Mage_Catalog_Model_Product::ENTITY)
    ->getAttributeCollection()
    ->addSetInfo();
</pre>

It will give you the collection of all attribute. And Through getName() ,you will get the label of respective attribute.

2
  • Sorry, I were looking to obtain values for these attributes. For example, if an attribute color used in 6 products each of which had the respective color values: Red, blue, pink, purple, green, white - then I would like to have a list of those colors taking into account this attribute is a text attribute. Every new product might have its own different color and it will add to that list.
    – Raj
    Jun 17, 2014 at 15:29
  • You can only do this if you will get the product collection. You need to get the color value from each product and make a separate list for this. Jun 18, 2014 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.