We are currently using the autocomplete product references to select a product that is associated with a separate content type. Currently this list is a global list that shows all available products, however we would like to limit the return from the autocomplete callback to only show the products that the logged in user created. This can be easily accomplished within a separate module if I could only hook_query_alter the query created within _commerce_product_match_products_standard. But in order to do this, I would like to have a tag added that would allow any module to alter this query from within the autocomplete callback. Then I could do something like this...

/**
* Implementation of hook_query_commerce_product_access_alter().
*/
function mymodule_query_commerce_product_match_alter(QueryAlterableInterface $query) {
  global $user;
  // If the user does not have access to administer product entities then restrict this list.
  if (!user_access('administer commerce_product entities')) {
    $query->where('cp.uid=' . $user->uid);
  }
}

Patch to follow.

Files: 
CommentFileSizeAuthor
#1 1866310-add-product-match-query-alter-2.patch658 bytestravist
PASSED: [[SimpleTest]]: [MySQL] 3,570 pass(es).
[ View ]

Comments

StatusFileSize
new658 bytes
PASSED: [[SimpleTest]]: [MySQL] 3,570 pass(es).
[ View ]

Here is the patch that allows this to happen.

Status:Active» Needs review

Here is the patch that allows this to happen.

Assigned:travist» Unassigned
Status:Needs review» Fixed

Great idea. Welcome to the committers log. : )

Awesome. Thanks Ryan.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.