Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a3f52b

Browse files
committed
[Product] Adding product/variant without price
1 parent 13ffd07 commit 7a3f52b

9 files changed

Lines changed: 68 additions & 15 deletions

File tree

app/migrations/Version20200916093101.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
use Doctrine\DBAL\Schema\Schema;
88
use Doctrine\Migrations\AbstractMigration;
99

10-
1110
final class Version20200916093101 extends AbstractMigration
1211
{
1312
public function getDescription(): string
1413
{
15-
return 'make a price on channel pricing nullable';
14+
return 'Make a price on channel pricing nullable';
1615
}
1716

1817
public function up(Schema $schema): void
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@managing_product_variants
2+
Feature: Adding a product variant with only original price
3+
In order to prepare product variant in all channel
4+
As an Administrator
5+
I want to be able to create product variant without price in disabled channel
6+
7+
Background:
8+
Given the store operates on a single channel in "United States"
9+
And the store has a "Wyborowa Vodka" configurable product
10+
And this product is disabled in "United States" channel
11+
And I am logged in as an administrator
12+
13+
@ui
14+
Scenario: Adding a new product variant without price
15+
When I want to create a new variant of this product
16+
And I specify its code as "VODKA_WYBOROWA_DELUX"
17+
And I set its original price to "$100.00" for "United States" channel
18+
And I add it
19+
Then I should be notified that it has been successfully created
20+
And the "VODKA_WYBOROWA_DELUX" variant of the "Wyborowa Vodka" product should appear in the store
21+
And the variant with code "VODKA_WYBOROWA_DELUX" should be originally priced at $100.00 for channel "United States"

features/product/managing_product_variants/removing_product_variant_price_from_obsolete_channel.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feature: Removing a product variant's price from obsolete channel
2020
And I remove its price for "Web-GB" channel
2121
And I save my changes
2222
Then I should not have configured price for "Web-GB" channel
23-
But I should have original price equal "£50.00" in "Web-GB" channel
23+
But I should have original price equal to "£50.00" in "Web-GB" channel
2424

2525
@ui
2626
Scenario: Removing a product variant's price from disabled channel
@@ -29,4 +29,4 @@ Feature: Removing a product variant's price from obsolete channel
2929
And I remove its price for "Web-GB" channel
3030
And I save my changes
3131
Then I should not have configured price for "Web-GB" channel
32-
But I should have original price equal "£50.00" in "Web-GB" channel
32+
But I should have original price equal to "£50.00" in "Web-GB" channel
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@managing_products
2+
Feature: Adding a product with only original price
3+
In order to prepare product in all channel
4+
As an Administrator
5+
I want to be able to create product without price in disabled channel
6+
7+
Background:
8+
Given the store operates on a single channel in "United States"
9+
And I am logged in as an administrator
10+
11+
@ui
12+
Scenario: Adding a new simple product without price
13+
When I want to create a new simple product
14+
And I specify its code as "BOARD_DICE_BREWING"
15+
And I name it "Dice Brewing" in "English (United States)"
16+
And I set its slug to "games/Dice-brewing" in "English (United States)"
17+
And I set its original price to "$100.00" for "United States" channel
18+
And I add it
19+
Then I should be notified that it has been successfully created
20+
And I should have original price equal to "$100.00" in "United States" channel

features/product/managing_products/removing_product_price_from_obsolete_channel.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: Removing a product's price from the channel where it is not available i
99
And the store operates on another channel named "Web-GB" in "GBP" currency
1010
And the store has a product "Dice Brewing" priced at "$10.00" in "Web-US" channel
1111
And this product is also priced at "£5.00" in "Web-GB" channel
12-
And this product is original priced at "£70.00" in "Web-GB" channel
12+
And this product is originally priced at "£70.00" in "Web-GB" channel
1313
And this product is disabled in "Web-GB" channel
1414
And I am logged in as an administrator
1515

@@ -20,7 +20,7 @@ Feature: Removing a product's price from the channel where it is not available i
2020
And I remove its price for "Web-GB" channel
2121
And I save my changes
2222
Then I should not have configured price for "Web-GB" channel
23-
But I should have original price equal "£70.00" in "Web-GB" channel
23+
But I should have original price equal to "£70.00" in "Web-GB" channel
2424

2525
@ui
2626
Scenario: Removing a product's price from obsolete channel
@@ -29,4 +29,4 @@ Feature: Removing a product's price from the channel where it is not available i
2929
And I remove its price for "Web-GB" channel
3030
And I save my changes
3131
Then I should not have configured price for "Web-GB" channel
32-
But I should have original price equal "£70.00" in "Web-GB" channel
32+
But I should have original price equal to "£70.00" in "Web-GB" channel

src/Sylius/Behat/Context/Setup/ProductContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ public function storeHasAProductPricedAt($productName, int $price = 100, Channel
150150
}
151151

152152
/**
153-
* @Given /^(this product) is original priced at ("[^"]+") in ("[^"]+" channel)$/
153+
* @Given /^(this product) is originally priced at ("[^"]+") in ("[^"]+" channel)$/
154154
*/
155-
public function thisProductHasOriginalPriceInChannel(
155+
public function thisProductHasOriginallyPriceInChannel(
156156
ProductInterface $product,
157157
int $originalPrice,
158158
ChannelInterface $channel
@@ -347,7 +347,7 @@ public function variantPricedAtInChannel(
347347
}
348348

349349
/**
350-
* @Given /^("[^"]+" variant) is original priced at ("[^"]+") in ("[^"]+" channel)$/
350+
* @Given /^("[^"]+" variant) is originally priced at ("[^"]+") in ("[^"]+" channel)$/
351351
*/
352352
public function variantIsOriginalPricedAtInChannel(
353353
ProductVariantInterface $productVariant,

src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,19 @@ public function theVariantWithCodeShouldBePricedAtForChannel(ProductVariantInter
232232
Assert::same($this->updatePage->getPriceForChannel($channelName), $price);
233233
}
234234

235+
/**
236+
* @Then /^the (variant with code "[^"]+") should be originally priced at (?:€|£|\$)([^"]+) for channel "([^"]+)"$/
237+
*/
238+
public function theVariantWithCodeShouldBeOriginalPricedAtForChannel(
239+
ProductVariantInterface $productVariant,
240+
string $price,
241+
string $channelName
242+
): void {
243+
$this->updatePage->open(['id' => $productVariant->getId(), 'productId' => $productVariant->getProduct()->getId()]);
244+
245+
Assert::same($this->updatePage->getOriginalPriceForChannel($channelName), $price);
246+
}
247+
235248
/**
236249
* @Then /^the (variant with code "[^"]+") should be named "([^"]+)" in ("([^"]+)" locale)$/
237250
*/
@@ -564,7 +577,7 @@ public function iShouldNotHaveConfiguredPriceForChannel(string $channelName): vo
564577
}
565578

566579
/**
567-
* @Then I should have original price equal :price in :channelName channel
580+
* @Then I should have original price equal to :price in :channelName channel
568581
*/
569582
public function iShouldHaveOriginalPriceEqualInChannel(string $price, string $channelName): void
570583
{

src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ public function iShouldNotHaveConfiguredPriceForChannel(string $channelName): vo
10551055
}
10561056

10571057
/**
1058-
* @Then I should have original price equal :price in :channelName channel
1058+
* @Then I should have original price equal to :price in :channelName channel
10591059
*/
10601060
public function iShouldHaveOriginalPriceEqualInChannel(string $price, string $channelName): void
10611061
{

src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/ChannelPricing.orm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
<id name="id" column="id" type="integer">
2626
<generator strategy="AUTO" />
2727
</id>
28-
<field name="price" column="price" type="integer" nullable="true"/>
29-
<field name="originalPrice" column="original_price" type="integer" nullable="true"/>
30-
<field name="channelCode" column="channel_code" type="string"/>
28+
<field name="price" column="price" type="integer" nullable="true" />
29+
<field name="originalPrice" column="original_price" type="integer" nullable="true" />
30+
<field name="channelCode" column="channel_code" type="string" />
3131

3232
<many-to-one field="productVariant" target-entity="Sylius\Component\Product\Model\ProductVariantInterface" inversed-by="channelPricings">
3333
<join-column name="product_variant_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />

0 commit comments

Comments
 (0)