My products have multiple variations as enitities (size, color etc). I want to display a flag link on a product display page. When a visitor uses it, I want them to be able to flag the selected variation, not the node. Is it possible? Here is a related discussion on drupal.org: http://drupal.org/node/1050872

2 Answers 2


I wrote a way to use Flag for product variations here: http://drupal.org/node/1911568

Here is my solution:

  1. Add a flag "add to wishlist" for commerce_product entity type.
  2. Install computed field module.
  3. Add a computed field to the product (not the display content type)
  4. In Display Code (PHP) area of the field:

    $entity_id = array_shift(entity_extract_ids($entity_type,$entity)); $display_output = flag_create_link('add_to_wishlist', $entity_id);

(Computed Code (PHP) part can be left empty, we dont want to store anything in database) 5. Go to Manage Display of the product and set the newly created computed field's format: "unsanitized" and make sure it is visible. 6. Go to Manage Display of the product display content type (not the product) and use your product's wishlist computed field there.

Now you can create a view to display a user's products in his wishlist. It is straitforward. You just add any field, add a relation: your flag and tweak the view as you like. You can also use view's menu system to create tabs on the user profile: http://drupal.org/node/326580

  • So, how would this be different from a flag on the product display node?
    – nizz0k
    May 30, 2014 at 19:37

In case anyone comes here looking for a solution, I have created a module that will do this without needing you to do any custom coding.

Have a look at Commerce Product Reference Flag.

Your Answer

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

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