[Product] Adding product/variant without price

This commit is contained in:
Adam Kasperczak 2020-09-16 13:50:24 +02:00
parent 13ffd07da3
commit 8eedea1193
9 changed files with 69 additions and 16 deletions

View file

@ -7,12 +7,11 @@ namespace Sylius\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20200916093101 extends AbstractMigration
{
public function getDescription(): string
{
return 'make a price on channel pricing nullable';
return 'Make a price on channel pricing nullable';
}
public function up(Schema $schema): void

View file

@ -0,0 +1,21 @@
@managing_product_variants
Feature: Adding a product variant with only original price
In order to prepare product variant in all channel
As an Administrator
I want to be able to create product variant without price in disabled channel
Background:
Given the store operates on a single channel in "United States"
And the store has a "Wyborowa Vodka" configurable product
And this product is disabled in "United States" channel
And I am logged in as an administrator
@ui
Scenario: Adding a new product variant without price
When I want to create a new variant of this product
And I specify its code as "VODKA_WYBOROWA_DELUX"
And I set its original price to "$100.00" for "United States" channel
And I add it
Then I should be notified that it has been successfully created
And the "VODKA_WYBOROWA_DELUX" variant of the "Wyborowa Vodka" product should appear in the store
And the variant with code "VODKA_WYBOROWA_DELUX" should be originally priced at $100.00 for channel "United States"

View file

@ -10,7 +10,7 @@ Feature: Removing a product variant's price from obsolete channel
And the store has a "PHP Mug" configurable product
And this product has "Medium PHP Mug" variant priced at "$20" in "Web-US" channel
And "Medium PHP Mug" variant priced at "£25" in "Web-GB" channel
And "Medium PHP Mug" variant is original priced at "£50.00" in "Web-GB" channel
And "Medium PHP Mug" variant is originally priced at "£50.00" in "Web-GB" channel
And this product is disabled in "Web-GB" channel
And I am logged in as an administrator
@ -20,7 +20,7 @@ Feature: Removing a product variant's price from obsolete channel
And I remove its price for "Web-GB" channel
And I save my changes
Then I should not have configured price for "Web-GB" channel
But I should have original price equal "£50.00" in "Web-GB" channel
But I should have original price equal to "£50.00" in "Web-GB" channel
@ui
Scenario: Removing a product variant's price from disabled channel
@ -29,4 +29,4 @@ Feature: Removing a product variant's price from obsolete channel
And I remove its price for "Web-GB" channel
And I save my changes
Then I should not have configured price for "Web-GB" channel
But I should have original price equal "£50.00" in "Web-GB" channel
But I should have original price equal to "£50.00" in "Web-GB" channel

View file

@ -0,0 +1,20 @@
@managing_products
Feature: Adding a product with only original price
In order to prepare product in all channel
As an Administrator
I want to be able to create product without price in disabled channel
Background:
Given the store operates on a single channel in "United States"
And I am logged in as an administrator
@ui
Scenario: Adding a new simple product without price
When I want to create a new simple product
And I specify its code as "BOARD_DICE_BREWING"
And I name it "Dice Brewing" in "English (United States)"
And I set its slug to "games/Dice-brewing" in "English (United States)"
And I set its original price to "$100.00" for "United States" channel
And I add it
Then I should be notified that it has been successfully created
And I should have original price equal to "$100.00" in "United States" channel

View file

@ -9,7 +9,7 @@ Feature: Removing a product's price from the channel where it is not available i
And the store operates on another channel named "Web-GB" in "GBP" currency
And the store has a product "Dice Brewing" priced at "$10.00" in "Web-US" channel
And this product is also priced at "£5.00" in "Web-GB" channel
And this product is original priced at "£70.00" in "Web-GB" channel
And this product is originally priced at "£70.00" in "Web-GB" channel
And this product is disabled in "Web-GB" channel
And I am logged in as an administrator
@ -20,7 +20,7 @@ Feature: Removing a product's price from the channel where it is not available i
And I remove its price for "Web-GB" channel
And I save my changes
Then I should not have configured price for "Web-GB" channel
But I should have original price equal "£70.00" in "Web-GB" channel
But I should have original price equal to "£70.00" in "Web-GB" channel
@ui
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
And I remove its price for "Web-GB" channel
And I save my changes
Then I should not have configured price for "Web-GB" channel
But I should have original price equal "£70.00" in "Web-GB" channel
But I should have original price equal to "£70.00" in "Web-GB" channel

View file

@ -150,9 +150,9 @@ final class ProductContext implements Context
}
/**
* @Given /^(this product) is original priced at ("[^"]+") in ("[^"]+" channel)$/
* @Given /^(this product) is originally priced at ("[^"]+") in ("[^"]+" channel)$/
*/
public function thisProductHasOriginalPriceInChannel(
public function thisProductHasOriginallyPriceInChannel(
ProductInterface $product,
int $originalPrice,
ChannelInterface $channel
@ -347,7 +347,7 @@ final class ProductContext implements Context
}
/**
* @Given /^("[^"]+" variant) is original priced at ("[^"]+") in ("[^"]+" channel)$/
* @Given /^("[^"]+" variant) is originally priced at ("[^"]+") in ("[^"]+" channel)$/
*/
public function variantIsOriginalPricedAtInChannel(
ProductVariantInterface $productVariant,

View file

@ -232,6 +232,19 @@ final class ManagingProductVariantsContext implements Context
Assert::same($this->updatePage->getPriceForChannel($channelName), $price);
}
/**
* @Then /^the (variant with code "[^"]+") should be originally priced at (?:€|£|\$)([^"]+) for channel "([^"]+)"$/
*/
public function theVariantWithCodeShouldBeOriginalPricedAtForChannel(
ProductVariantInterface $productVariant,
string $price,
string $channelName
): void {
$this->updatePage->open(['id' => $productVariant->getId(), 'productId' => $productVariant->getProduct()->getId()]);
Assert::same($this->updatePage->getOriginalPriceForChannel($channelName), $price);
}
/**
* @Then /^the (variant with code "[^"]+") should be named "([^"]+)" in ("([^"]+)" locale)$/
*/
@ -564,7 +577,7 @@ final class ManagingProductVariantsContext implements Context
}
/**
* @Then I should have original price equal :price in :channelName channel
* @Then I should have original price equal to :price in :channelName channel
*/
public function iShouldHaveOriginalPriceEqualInChannel(string $price, string $channelName): void
{

View file

@ -1055,7 +1055,7 @@ final class ManagingProductsContext implements Context
}
/**
* @Then I should have original price equal :price in :channelName channel
* @Then I should have original price equal to :price in :channelName channel
*/
public function iShouldHaveOriginalPriceEqualInChannel(string $price, string $channelName): void
{

View file

@ -25,9 +25,9 @@
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="price" column="price" type="integer" nullable="true"/>
<field name="originalPrice" column="original_price" type="integer" nullable="true"/>
<field name="channelCode" column="channel_code" type="string"/>
<field name="price" column="price" type="integer" nullable="true" />
<field name="originalPrice" column="original_price" type="integer" nullable="true" />
<field name="channelCode" column="channel_code" type="string" />
<many-to-one field="productVariant" target-entity="Sylius\Component\Product\Model\ProductVariantInterface" inversed-by="channelPricings">
<join-column name="product_variant_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />