Skip to content

Commit

Permalink
BB-18526: Product price is not shown in shopping list widget (#26128)
Browse files Browse the repository at this point in the history
 - fixed twig template and layout data provider
 - updated unit test
 - added behat test
  • Loading branch information
Mykhailo Sulyma authored and webevt committed Dec 13, 2019
1 parent dcd8595 commit 3396ddc
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public function getMatchedPrices(array $shoppingLists = [])

$prices = [];
foreach ($shoppingLists as $shoppingList) {
$prices[] = $this->getMatchedPrice($shoppingList);
$prices[$shoppingList->getId()] = $this->getMatchedPrice($shoppingList);
}

return array_merge(...$prices);
return $prices;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
<div class="shopping-list-dropdown__product-list">
{% for lineItem in shoppingList.lineItems|default([]) %}
{% set product = lineItem.product %}
{% set productMatchedPrice = productsMatchedPrices[product.id][lineItem.productUnit.code] is not empty ? productsMatchedPrices[product.id][lineItem.unit.code] : null %}
{% set productMatchedPrice = productsMatchedPrices[shoppingList.id][product.id][lineItem.productUnit.code] is defined ? productsMatchedPrices[shoppingList.id][product.id][lineItem.unit.code] : null %}

<div class="shopping-list-dropdown__product-item">
<div class="shopping-list-dropdown__product-img">
Expand All @@ -180,7 +180,7 @@
{{ productMatchedPrice.value|oro_format_currency({'currency': productMatchedPrice.currency}) }}
</span>
{% else %}
<div data-name="price-not-found">{{ 'oro.pricing.frontend.product_prices.price_not_found'|trans }}</div>
<span data-name="price-not-found">{{ 'oro.pricing.frontend.product_prices.price_not_found'|trans }}</span>
{% endif %}
</div>
{% set routeOptions = {'id': product.id} %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
include:
- '@OroShoppingListBundle:ProductFixture.yml'

Oro\Bundle\PricingBundle\Entity\PriceList:
pricelist:
name: 'pricelist'
default: true
__calls:
- setCurrencies: [['USD']]
active: true

Oro\Bundle\PricingBundle\Entity\PriceListToWebsite:
priceListToWebsite1:
pricelist: '@pricelist'
website: '@website1'
sortOrder: 100

Oro\Bundle\PricingBundle\Entity\ProductPrice:
productPrice{1..3}:
pricelist: '@pricelist'
product: '@product<current()>'
productSku: '@product<current()>->getSku'
quantity: 1
unit: '@each'
value: '<current()>'
currency: 'USD'
productPrice4:
pricelist: '@pricelist'
product: '@simpleProduct1'
productSku: '@simpleProduct1->getSku'
quantity: 1
unit: '@each'
value: 4
currency: 'USD'

Oro\Bundle\PricingBundle\Entity\CombinedProductPrice:
combinedProductPrice{1..3}:
pricelist: '@combinedPriceList'
product: '@product<current()>'
productSku: '@product<current()>->getSku'
quantity: 1
unit: '@each'
value: '<current()>'
currency: 'USD'
combinedProductPrice4:
pricelist: '@combinedPriceList'
product: '@simpleProduct1'
productSku: '@simpleProduct1->getSku'
quantity: 1
unit: '@each'
value: 4
currency: 'USD'

Oro\Bundle\PricingBundle\Entity\CombinedPriceListToWebsite:
combinedPriceListToWebsite1:
pricelist: '@combinedPriceList'
website: '@website1'

Oro\Bundle\PricingBundle\Entity\PriceListToProduct:
priceListToProduct:
product: '@product1'
pricelist: '@pricelist'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@regression
@ticket-BB-10050
@fixture-OroShoppingListBundle:ProductFixture.yml
@fixture-OroShoppingListBundle:GuestShoppingListsFixture.yml
Feature: Guest Shopping Lists
In order to allow unregistered customers to select goods they want to purchase
As a Sales rep
Expand Down Expand Up @@ -130,7 +130,7 @@ Feature: Guest Shopping Lists
Then I should see "Product has been added to" flash message
And I should see "In shopping list"
And I hover on "Shopping List Widget"
And I should see "1 Item | $0.00" in the "Shopping List Widget" element
And I should see "1 ea | $3.00" in the "Shopping List Widget" element

Scenario: Check Update Shopping List
Given I should see "Update Shopping list"
Expand All @@ -143,6 +143,10 @@ Feature: Guest Shopping Lists
And I click "Search Button"
Then I should see "In shopping list"

Scenario: Check shopping list widget
When I hover on "Shopping List Widget"
Then I should see "10 ea | $3.00" in the "Shopping List Widget" element

Scenario: Add more products to shopping list from list page (search)
Given I type "CONTROL1" in "search"
And I click "Search Button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function testGetMatchedPrice($shoppingList)

public function testGetMatchedPrices()
{
$shoppingList = new ShoppingList();
$shoppingList = $this->getEntity(ShoppingList::class, ['id' => 42]);
$lineItems = [];

$this->shoppingListLineItemsDataProvider->expects($this->once())
Expand All @@ -144,7 +144,7 @@ public function testGetMatchedPrices()
->willReturn($expected);

$result = $this->provider->getMatchedPrices([$shoppingList]);
$this->assertEquals($expected, $result);
$this->assertEquals([42 => $expected], $result);
}

/**
Expand Down

0 comments on commit 3396ddc

Please sign in to comment.