Right now the variation label is just the attributes: "Blue, small".
For the line item label we construct the full version using the product title: "MyShirt - Blue, small".

This looks weird on the line item form cause the autocomplete only shows "Blue, small".

We need to:
1) Do #2631168: Add a getLabel() method to inline forms in IEF
2) move the getLineItemTitle() logic to label(), make the attribute generation part a public method
3) Use the new public method in the inline form's getLabel() method

IEF keeps looking the same, line item form gets fixed.

Comments

bojanz created an issue. See original summary.

harings_rob’s picture

I took a look at this and the patch in https://www.drupal.org/node/2631168 (applies fine, but could not completely test yet).

Currently I have created a Product, and Product variation.

To test, I created a few variations, but all of them always show up as Default.

modules/commerce/modules/product/src/Entity/ProductVariation.php

I see:

  public function label() {
    // A label callback was registered to override the default logic.
    $callback = $this->getEntityType()->getLabelCallback();
    if ($callback && is_callable($callback)) {
      return call_user_func($callback, $this);
    }

I assume this should be:

public function label() {
    // A label callback was registered to override the default logic.
    $callback = $this->getEntityType()->getLabel();
    if ($callback && is_callable($callback)) {
      return call_user_func($callback, $this);
    }

Also I see that getTitle() is often used here, but the productvariation does not have this field yet. Still to be implemented or by design?

The above notes and questions are blocking me from working on this ticket, as I cannot get the same behavior as in the TS (Myshirt - blue, small).

Looked at it a bit deeper, and seems that we could do something like this in the productvariation.php inside (public function label() {):

$label = $this->getSku();

instead of:

$label = t('Default')

harings_rob’s picture

Assigned: Unassigned » harings_rob
harings_rob’s picture

Status: Active » Needs review

  • bojanz committed 3b0a9ab on 8.x-2.x authored by harings_rob
    Issue #2631172 by harings_rob, bojanz: Change product variation label...

Status: Fixed » Closed (fixed)

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