I'm using Drupal Commerce and stuck in this problem. I'm creating a custom module that will display a product title and some info.

I want that product to be linked to its node page, and product Object is all I have to my resources. I'm thinking of getting the product URL or alias using product_id but I don't know how. I already searched it but there's nothing clear on the search results I got.

Any suggestions?

1 Answer 1


After trial and error I found a solution. Here's what I did.

        //$product is the product object that I mentioned above
        $wrapper = entity_metadata_wrapper('commerce_product', $product);
        $nodes   = $wrapper->field_product_node->value();
        $path    = drupal_get_path_alias("node/".$nodes[0]->nid);
        $product->path = $path;

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.