I have a custom attribute called PLU, and I want to select ALL product from the database with the PLU VALUE in MySQL query, how can I do that?

enter image description here


1] eav_attribute Check ur attribute_code for PLU & take attribute_id

2] Depend on your attribute type (Text, Integer, Decimal, etc..), you can find in following tables


Below is the query

SELECT * FROM catalog_product_entity_XXX WHERE attribute_id = '<Your Id>'.

Here entity_id is your Product Id

| improve this answer | |
  • 1
    Thanks, This is absolutely working for me. :) have a great day! – Harry Alive Jan 17 '17 at 18:01
  • It's saying i don't have enough reputation to upvote, may be i should talk more.. – Harry Alive Jan 18 '17 at 19:03
  • Do you know how to select * the SKU and PLU and listed the way like Magento does in MYSQL? Thank you – Harry Alive Jan 18 '17 at 19:05
  • To accept @Ankit Shah answer, you can click on the check box underneath the arrows. That will also help boost you reputation IIRC. – frostshoxx Jan 18 '17 at 19:09

I assume you will loop through retrieved products at some point, so you can try to use magento2 style to retrieve them:

$productCollection->addAttributeToSelect('PLU') ->addAttributeToFilter('PLU',['notnull'=> true]);

I assumed you already have a $productCollection object added with dependency injection or with using object manager. While the above answer is also correct, I provided this one in case you need more info about each product found

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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