0

I created an EAV attribute on product entity, this attribute named user_id and has the ID of the user who's added the product.

After works, I crashed on this point, I need to join tables to get products added by a specific user.

So, I try with this code

->join(
      array(
           'product' => 'catalog_product_entity'),
           'product.user_id = 2',
            array()
      );

but always I get this error Unknown column 'user_id'

is there any solution?

2
  • what is the type of this EAV attribute? int|text|varchar| Jun 3, 2019 at 17:11
  • @vitoriodachef int type
    – sayou
    Jun 4, 2019 at 9:50

1 Answer 1

0

Late in the party but whoever is seeing this nowadays: you need to explicitly add your custom attribute to the collection, then filter it, like that:

$userProducts = $this->productsCollectionFactory->create()
    ->addAttributeToSelect(["user_id"])
    ->addAttributeToFilter("user_id", 2);

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.