Hi, I apologize if I'm missing something simple, but I haven't been able to figure out a way in Views to display the node title (as opposed to the product type title) in the cart views. No combination of relationships seems to expose any fields for the node. I see that the node path is exposed by the "display path", so I'm sure I could get at the title with some preprocessing/overiding, but I wanted to make sure I can't do this the easy way before I dive into the code. Thanks for the great modules!

Comments

rszrama’s picture

Status: Active » Closed (works as designed)

You just need to make it a View of Content instead of Commerce Products. Look at the default Cart block for an example.

craigtockman’s picture

Did you ever find a solution for this. I'm having the same issue.

brockfanning’s picture

Sorry, I had settled for a simpler DIY approach (custom module) before I got rszrama's response. It sounds promising though. Has making a View of "Content" instead of "Commerce Products" not worked for you?

quotesbro’s picture

Status: Closed (works as designed) » Active

You just need to make it a View of Content instead of Commerce Products. Look at the default Cart block for an example.

How is it possible? The default Cart views (including Cart block) have type 'Commerce Order'. If I create a new view of Content, it doesn't have Commerce Order in contextual filters.

brockfanning, could you share your module's code?

rszrama’s picture

Status: Active » Closed (won't fix)

Honestly, I'm not sure what I was talking about, but since this issue was opened, there's a new place for Commerce Q&A: http://www.drupalcommerce.org/questions - or search drupalcommerce.org or Drupal Stack Exchange, as there's been quite a lot of discussion about front end configuration already.

raphael apard’s picture

You can add a relation to cart view (Produit) Commerce Product : Elément !entity_tape référençant des produits depuis field_product and then add field Content: Title.

ace11’s picture

#6 Does not work, because there is no Product (product display) relation in that view.
Any tips/help?

**EDIT**
I got this. You need to add two relationships.
1. Add relationship: Commerce Line item: Product
2. Add relationship: Commerce product: Node referencing products from field_product
3. Add field: Field: Title and set Relationship to "Node referencing products from field_product"

This shows product node title in views.

edaa’s picture

Issue summary: View changes

Install Inline Entity Form module > leave "Auto generate the product title" checked.

Then create a module to override the save() method of CommerceProductInlineEntityFormController class of Inline Entity Form module. In this way, the product type title is same as the node title.

/**
 * @file
 * your_product.inline_entity_form.inc
 */
class YourProductInlineEntityFormController extends CommerceProductInlineEntityFormController {

  /**
   * Overrides CommerceProductInlineEntityFormController::save().
   *
   * Autogenerates the product title if specified, and then saves the product.
   */
  public function save($entity, $context) {
    // Remove the temporary message added in entityFormSubmit() so that
    // Commerce AutoSKU can do its thing.
    if (!empty($entity->_remove_sku)) {
      $entity->sku = NULL;
      unset($entity->_remove_sku);
    }

    // Generate the product title. Take the parent entity title as the base.
    if ($this->settings['autogenerate_title']) {
      $entity->title = entity_label($context['parent_entity_type'], $context['parent_entity']);

      // Just comment following lines.
      // $attributes = $this->attributes($entity->type);
      // if (!empty($attributes)) {
      //   $wrapper = entity_metadata_wrapper('commerce_product', $entity);
      //   $attribute_values = array();
      //   foreach ($attributes as $field_name => $attribute) {
      //     $attribute_label = $wrapper->{$field_name}->label();
      //     if (!empty($attribute_label)) {
      //       $attribute_values[] = $attribute_label;
      //     }
      //   }

      //   if (!empty($attribute_values)) {
      //     $entity->title .= ' (' . implode(', ', $attribute_values) . ')';
      //   }
      // }
    }

    entity_save('commerce_product', $entity);
  }
}

/**
 * @file
 * your_module.module
 * Auto generate product variation title as same as product display title.
 */

/**
 * Implements hook_entity_info_alter().
 */
function your_module_entity_info_alter(&$entity_info) {
  if (isset($entity_info['commerce_product'])) {
    $entity_info['commerce_product']['inline entity form'] = array(
      'controller' => 'YourProductInlineEntityFormController',
    );
  }
}

It's petty cool if the Inline Entity Form module can work with Token module.

grougy’s picture

Thanks #7
I can confirm that the edit in #7 is working very well and allow to display any field from product display node in the cart view. (Quite simpler than #8 solution)

hottaco’s picture

#7 kind of works for me. But it's showing all content attached to that product.

I just want the node's title that's referenced in the path that hyperlinks the PRODUCT field on checkout.

I have a single product called "Voting on a Dog"
I created a new content type and referenced the product "Voting for a Dog".
I created 12 pieces of content that have the dogs pics, bio etc.

When I go to checkout it shows all the content I created vs just the one I'm checking out with when I add all the relationships as described in #7
I dumped all the variables from this hook to see if the title was already there since the nid is listed.. but can't find it.

function custom_commerce_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state) {
      dsm($form,'Form');
      dsm($form_state,'Form State');
  }

Any guidance would be appreciated.