Hi,

I am working with commerce module in drupal 7.

I have installed metatag module. It working as expected for drupal default entities like node, taxonomy etc.

But when I try to add meta tags for commerce products, it fails to save the meta tags alone.

Do I need to do any additional settings?

Also my site is built with multilingual properties.

will the metatag module only supports node, taxonomy, user?

Please advise.

Comments

damienmckenna’s picture

Assigned: jnavane » Unassigned
Category: Bug report » Support request
Priority: Major » Normal
Status: Needs work » Active
Issue tags: -API clean-up

Please try updating to 1.6 and let me know how it goes.

FYI you shouldn't assign an issue to yourself unless you're actively working on it, which isn't applicable for this type of request.

damienmckenna’s picture

Status: Active » Postponed (maintainer needs more info)
jnavane’s picture

Thanks for your update.

Updated version (1.6) doesn't help.

We have a node page with multiple commerce products referred with it. We need to add meta tag for product entities as well (rather than node level). We have a view to load the particular product variation by accessing their product ids. By using the meta tag module we can able to see the meta tag options in product add/edit page. When we are providing values for meta tag attributes, they are not updating.

Please let me know if you need any other information.

damienmckenna’s picture

Version: 7.x-1.5 » 7.x-1.x-dev

Please help clarify exactly what you're doing - are these products being loaded through a view that is then displayed on a node page?

jnavane’s picture

Yes. you are correct.

For your reference

custom node page url : www.mysite.com/custompath/product/product-name - It loads node page with default product with multiple product variations. (Need to load meta tag from viewing node id)

product page url: www.mysite.com/custompath/product/product-name?pid=12345 - It loads particular product based on the product if we provided. (Need to load meta tag from viewing product id)

We are loading the products using views.

FYI. We are not using default node view page (node/nid) for this. We have implemented, custom menu callback to load the nodes and products using views.

Thanks.

damienmckenna’s picture

Status: Postponed (maintainer needs more info) » Fixed

Ah, in that case It's kinda working by design - Metatag doesn't have any architecture to automatically load tags from entity A when you're viewing a completely unrelated page B.

What you could do is try using #2396693: Add Token support to insert values from the Views results to insert values from the Views results into Metatag:Views.

jnavane’s picture

Thanks for your update,

Main purpose of this issue thread is, I can't save meta tags for commerce products (add/edit forms at the admin end).

when I try to add meta tags for commerce products, it fails to save meta tags.

Please advise.

jnavane’s picture

Status: Fixed » Active
damienmckenna’s picture

Title: Drupal 7 commerce meta tags not updating » Drupal 7 commerce meta tags not saving correctly
Component: User interface » Integration with other module
Category: Support request » Bug report
Parent issue: » #2505213: Plan for Metatag 7.x-1.7 release

Argh! I've just reproduced this problem myself! Dangit.

Thanks for reporting the problem, I'll see about doing up a fix.

damienmckenna’s picture

For some reason metatag_metatags_form_submit() isn't being triggered. Oh bother.

damienmckenna’s picture

Title: Drupal 7 commerce meta tags not saving correctly » Metatag values not saving correctly for Commerce entities
Project: Metatag » Commerce Core
Component: Integration with other module » Contributed modules

I'm (temporarily) moving this over to the Commerce issue queue to see if anyone might have suggestions as to what the problem is.

rszrama’s picture

Could it be because the Product UI module's product edit form is wrapping another base product edit form? I'm not familiar with how the Metatag module alters forms to add its submit handlers.

damienmckenna’s picture

@rszrama: Thanks for the update. I didn't have time to dig into Commerce much yet.

FYI Metatag uses a tag-team of metatag_field_attach_form() and metatag_form_alter() to add itself onto the entity form.

rszrama’s picture

Hmm, ok, I'll check it out if I get a minute; are you checking for button level submit handlers vs. just using form level submit handlers?

damienmckenna’s picture

Right now it's checking for form-level submit handlers, but I noticed that doing so means the Metatag form submission callback is never triggered.

rszrama’s picture

Should we move this back to the Metatag queue then? I'm not sure what the general policy is for modules blanket altering other modules' forms, but I see two options:

  1. Check to see if any submit elements in the form you're altering use button level submit handlers and alter Metatag's in there instead of the form level submit array, or
  2. Wrap the form somehow to seed $form['#submit'] with your callback and then convince other modules to check for submit handlers in that array and append them to their button level submit arrays where appropriate.

If I'm not mistaken, there are places in Commerce where I've done that to preserve form level handlers in button level submit arrays.

I'm guessing the first option is more easily achievable, but it does depend on ensuring the button you're altering isn't a delete / cancel button. You can probably avoid that by checking to see if the button has #limit_validation_errors set on it, but you may also just depend on only altering the #submit arrays of submit elements actually named submit. That's a fairly strong pattern.

damienmckenna’s picture

Project: Commerce Core » Metatag
Component: Contributed modules » Integration with other module

Moving the issue back to Metatag's queue.

I've updated the form handling to check for the alternative submission handler, that part works correctly now, but the bigger issue is that the $form_state['values']['metatags'] items aren't being added to the entity object, as happens with other entities. I suspect I need to do something with Entity API.

jnavane’s picture

Thanks for your updates.

You are correct. For some reasons, we are not getting metatag values ($form_state['values']['metatags']) in hook_entity_update and hook_entity_insert functions.

damienmckenna’s picture

manikaprasanth’s picture

Status: Active » Needs review
StatusFileSize
new2.48 KB

Hi Damien,

I added a separate submit handler for commerce product , and it's works fine for me. Here is the patch for I created based on it.

damienmckenna’s picture

Status: Needs review » Fixed

I've confirmed this worked. Yay! Thanks manikaprasanth!

jnavane’s picture

Issue summary: View changes

damienmckenna’s picture

Status: Fixed » Needs review
StatusFileSize
new2.91 KB

This needed a little additional work to tidy it up.

damienmckenna’s picture

StatusFileSize
new3.19 KB

A little more tweaking.

  • DamienMcKenna committed f2876a1 on 7.x-1.x
    Issue #2518690 by DamienMcKenna: Improvements to Commerce Product...
damienmckenna’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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