diff --git a/modules/log/tests/src/Kernel/CartIntegrationTest.php b/modules/log/tests/src/Kernel/CartIntegrationTest.php index 7e462331..37045cda 100755 --- a/modules/log/tests/src/Kernel/CartIntegrationTest.php +++ b/modules/log/tests/src/Kernel/CartIntegrationTest.php @@ -124,7 +124,7 @@ class CartIntegrationTest extends CommerceKernelTestBase { $log = reset($logs); $build = $this->logViewBuilder->view($log); $this->render($build); - $this->assertText("{$this->variation->label()} added to the cart."); + $this->assertText("{$this->variation->getOrderItemTitle()} added to the cart."); } /** @@ -167,7 +167,7 @@ class CartIntegrationTest extends CommerceKernelTestBase { $build = $this->logViewBuilder->view($log); $this->render($build); - $this->assertText("{$this->variation->label()} removed from the cart."); + $this->assertText("{$this->variation->getOrderItemTitle()} removed from the cart."); } /** diff --git a/modules/order/tests/src/Kernel/OrderRefreshTest.php b/modules/order/tests/src/Kernel/OrderRefreshTest.php index 376ea813..d434ebe2 100755 --- a/modules/order/tests/src/Kernel/OrderRefreshTest.php +++ b/modules/order/tests/src/Kernel/OrderRefreshTest.php @@ -204,7 +204,7 @@ class OrderRefreshTest extends CommerceKernelTestBase { $this->order->setRefreshState(Order::REFRESH_SKIP); $this->order->save(); - $this->assertEquals($order_item->label(), $this->variation2->getTitle()); + $this->assertEquals($order_item->label(), $this->variation2->getOrderItemTitle()); $this->assertEquals($order_item->getUnitPrice(), $this->variation2->getPrice()); $this->variation2->setTitle('Changed title'); @@ -214,7 +214,7 @@ class OrderRefreshTest extends CommerceKernelTestBase { /** @var \Drupal\commerce_order\Entity\OrderItemInterface $order_item */ $order_item = $this->reloadEntity($order_item); - $this->assertEquals($order_item->label(), $this->variation2->getTitle()); + $this->assertEquals($order_item->label(), $this->variation2->getOrderItemTitle()); $this->assertEquals($order_item->getUnitPrice(), $this->variation2->getPrice()); // Confirm that overridden unit prices stay untouched. @@ -227,7 +227,7 @@ class OrderRefreshTest extends CommerceKernelTestBase { /** @var \Drupal\commerce_order\Entity\OrderItemInterface $order_item */ $order_item = $this->reloadEntity($order_item); - $this->assertEquals($this->variation2->getTitle(), $order_item->label()); + $this->assertEquals($this->variation2->getOrderItemTitle(), $order_item->label()); $this->assertEquals($unit_price, $order_item->getUnitPrice()); } @@ -265,7 +265,7 @@ class OrderRefreshTest extends CommerceKernelTestBase { $this->assertNull($this->order->getRefreshState()); // Test REFRESH_ON_LOAD. - $old_title = $this->variation2->getTitle(); + $old_title = $this->variation2->getOrderItemTitle(); $this->variation2->setTitle('Changed title'); $this->variation2->save(); $this->order->setRefreshState(Order::REFRESH_ON_LOAD); @@ -279,7 +279,7 @@ class OrderRefreshTest extends CommerceKernelTestBase { $this->order = $this->reloadEntity($this->order); $another_order_item = $this->reloadEntity($another_order_item); $this->assertNotEquals($old_changed_time, $this->order->getChangedTime()); - $this->assertEquals('Changed title', $another_order_item->getTitle()); + $this->assertEquals('Changed title (' . $this->variation2->getSku() . ')', $another_order_item->getTitle()); $this->assertNull($this->order->getRefreshState()); } diff --git a/modules/product/src/Entity/ProductVariation.php b/modules/product/src/Entity/ProductVariation.php index 249caca7..2c548ec9 100755 --- a/modules/product/src/Entity/ProductVariation.php +++ b/modules/product/src/Entity/ProductVariation.php @@ -235,6 +235,7 @@ class ProductVariation extends CommerceContentEntityBase implements ProductVaria if (!$label) { $label = $this->generateTitle(); } + $label = $label . ' (' . $this->getSku() . ')'; return $label; } diff --git a/modules/product/tests/src/Kernel/Entity/ProductVariationTest.php b/modules/product/tests/src/Kernel/Entity/ProductVariationTest.php index b9015024..b128b288 100755 --- a/modules/product/tests/src/Kernel/Entity/ProductVariationTest.php +++ b/modules/product/tests/src/Kernel/Entity/ProductVariationTest.php @@ -85,15 +85,15 @@ class ProductVariationTest extends CommerceKernelTestBase { $product = $this->reloadEntity($product); $variation = $this->reloadEntity($variation); - $this->assertEquals('default', $variation->getOrderItemTypeId()); - $this->assertEquals('My Product Title', $variation->getOrderItemTitle()); - $this->assertEquals($product, $variation->getProduct()); $this->assertEquals($product->id(), $variation->getProductId()); $variation->setSku('1001'); $this->assertEquals('1001', $variation->getSku()); + $this->assertEquals('default', $variation->getOrderItemTypeId()); + $this->assertEquals('My Product Title (1001)', $variation->getOrderItemTitle()); + $variation->setTitle('My title'); $this->assertEquals('My title', $variation->getTitle());