Comments

damienmckenna’s picture

rvallejo: Would you be interested in merging your Metatag:Commerce into the main Metatag module as a submodule to house all of the Commerce integration?

rvallejo’s picture

Sounds good to me. I'd like to get the generic integration down (twitter and open graph product tags), and then work on further Drupal Commerce integration. I'm happy to hear others feedback and suggestions.

For anyone else, the Metatag Commerce module Damiem mentioned is a sandbox I recently created at https://drupal.org/sandbox/rvallejo/2102725.

guile2912’s picture

The metatag Commerce module does not work "out of the box" in drupal commerce, because commerce does not display "commerce_product", it displays nodes that reference "commerce_product" thought its field_product.

So here is a very small patch for metatag thats adds hook alter on "metatag_entity_view" so that we can deflect the entity metadata works on from the node, to its first "commerce_product" and have Metatag Commerce module work out of the box, with this kind of code :

function hook_metatag_entity_view_alter(&$entity, &$entity_type, $view_mode, $langcode) {
  if(isset($entity->field_product) && isset($entity->field_product[LANGUAGE_NONE][0])){

    $entity_id = $entity->field_product[LANGUAGE_NONE][0]['product_id'];
    $entity_type = 'commerce_product';
    $entity = entity_load('commerce_product', array($entity_id) );
    $entity = $entity[$entity_id];
  }
}
rvallejo’s picture

@guile2912: Looks like a good start—I had to make a slight adjustment to the field name, as for me it's 'field_products' instead of 'field_product'. Conceivably, someone could name the field whatever they want and it would be good to make this work regardless, so long as there is a product reference field. It also looks to me like it may not work with multi-language sites, but honestly I haven't played with any locale-enabled D7 sites at all yet, let alone locale-enabled commerce sites, to know the ins and outs. I would imagine some sort of language check could be added in.

Also, as is probably expected, adding the hook_metatag_entity_view_alter function overrides any product display node meta tags with the product meta tags (display node tags aren't used at all). This may be fine, but it might be a good idea to make products inherit their display node's tags as well. I'd have to look more into the metatag structure to figure this one out, but this seems like a good start at least.

I'll see if I can make this work generically regarding field names and commit the new function to my sandbox (hopefully within the next week, depending on when I can fit it in my schedule). I think once product entity tags are working this should be functional enough to add as a submodule included in the Metatag project as Damien suggested, along with the drupal_alter patch applied to the main Metatag module.

Any thoughts, Damien?

damienmckenna’s picture

I've personally got three goals for the Commerce integration:

  • Work out if there are additional meta tags that would be useful to support.
  • Work out what should be default values for these meta tags and document them to help people who are building their own Commerce sites.
  • Provide out-of-the-box default values for Commerce Kickstart based on the above.

I really appreciate your work to help on the Commerce integration, I'll loop back to this again once I get the next beta out.

damienmckenna’s picture

Component: User interface » Other tags
Issue summary: View changes
damienmckenna’s picture

Component: Other tags » Integration with other module
guile2912’s picture

Maybe we could push this one line patch that justs adds a new hook, and allows Drupal commerce to work with Metatags.
The detail of the code that will then use this hook, in other modules, is an other story ^^

Just this one line and we have clean a solution taht can open lots of doors.

Thank you.

damienmckenna’s picture

Title: Improve Commerce integration » Identify new/missing/incomplete ecommerce-related meta tags
Component: Integration with other module » Other tags
Category: Task » Feature request

I've added a new issue to split this up into smaller pieces:

This task will focus on identifying any missing meta tags that would be useful to have for ecommerce.

damienmckenna’s picture

Status: Active » Fixed

I think this one is good enough, lets leave it for #2219945: Provide turn-key solution for Commerce Kickstart.

omarlopesino’s picture

omarlopesino’s picture

damienmckenna’s picture

Status: Fixed » Needs work

@mistermoper: Lets keep the new tags to this issue, leave the other one for creating default values.

Lets stick with this new thing, but I think it'd be worthwhile moving the product meta tags into a new "Open Graph - Products" group, given there are so many of them. Thanks.

omarlopesino’s picture

StatusFileSize
new6.44 KB

Yeah, by that way the metatags are more organized.
I attach the patch moving it into a group,

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new6.89 KB

I updated some of the descriptions and moved all of the meta tags to the bottom of metatag_opengraph_metatag_info().

  • DamienMcKenna committed 36263bf on 7.x-1.x
    Issue #2103321 by mistermoper, DamienMcKenna: Added 24 more Open Graph...

  • DamienMcKenna committed 13b92b2 on 7.x-1.x
    Revert "Issue #2103321 by mistermoper, DamienMcKenna: Added 24 more Open...
  • DamienMcKenna committed e35837e on 7.x-1.x authored by mistermoper
    Issue #2103321 by mistermoper, DamienMcKenna: Added 24 more Open Graph...
damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks mistermoper!

Status: Fixed » Closed (fixed)

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