mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Product] Removed originalPrice field from ProductVariant
This commit is contained in:
parent
8496dbca3e
commit
2e175b7bdb
9 changed files with 35 additions and 93 deletions
34
app/migrations/Version20161118090221.php
Normal file
34
app/migrations/Version20161118090221.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Sylius\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20161118090221 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_product_variant DROP original_price');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_product_variant ADD original_price INT DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
{{ form_row(form.code) }}
|
||||
<div class="two fields">
|
||||
{{ form_row(form.price) }}
|
||||
{{ form_row(form.originalPrice) }}
|
||||
</div>
|
||||
<div class="two fields">
|
||||
{{ form_row(form.pricingCalculator) }}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,6 @@ class ProductVariantType extends BaseProductVariantType
|
|||
->add('price', 'sylius_money', [
|
||||
'label' => 'sylius.form.variant.price',
|
||||
])
|
||||
->add('originalPrice', 'sylius_money', [
|
||||
'required' => false,
|
||||
'label' => 'sylius.form.variant.original_price',
|
||||
])
|
||||
->add('tracked', 'checkbox', [
|
||||
'label' => 'sylius.form.variant.tracked',
|
||||
])
|
||||
|
|
|
|||
|
|
@ -11,12 +11,7 @@
|
|||
|
||||
-->
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<mapped-superclass name="Sylius\Component\Core\Model\ProductVariant" table="sylius_product_variant">
|
||||
<field name="onHold" column="on_hold" type="integer" />
|
||||
<field name="onHand" column="on_hand" type="integer" />
|
||||
|
|
@ -24,9 +19,6 @@
|
|||
<field name="price" column="price" type="integer">
|
||||
<gedmo:versioned />
|
||||
</field>
|
||||
<field name="originalPrice" column="original_price" type="integer" nullable="true">
|
||||
<gedmo:versioned />
|
||||
</field>
|
||||
<field name="pricingCalculator" column="pricing_calculator" type="string">
|
||||
<gedmo:versioned/>
|
||||
</field>
|
||||
|
|
@ -52,5 +44,4 @@
|
|||
|
||||
<gedmo:loggable />
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
|
|||
|
|
@ -24,13 +24,6 @@
|
|||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="originalPrice">
|
||||
<constraint name="Range">
|
||||
<option name="min">0.00</option>
|
||||
<option name="minMessage">sylius.product_variant.original_price.min</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="onHand">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.product_variant.onHand.not_blank</option>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ sylius:
|
|||
height: Height
|
||||
on_hand: Current stock
|
||||
price: Price
|
||||
original_price: Original price
|
||||
sku: SKU
|
||||
weight: Weight
|
||||
width: Width
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ class ProductVariant extends BaseVariant implements ProductVariantInterface
|
|||
*/
|
||||
protected $price;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $originalPrice;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -121,26 +116,6 @@ class ProductVariant extends BaseVariant implements ProductVariantInterface
|
|||
$this->price = $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOriginalPrice()
|
||||
{
|
||||
return $this->originalPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOriginalPrice($originalPrice)
|
||||
{
|
||||
if (null !== $originalPrice && !is_int($originalPrice)) {
|
||||
throw new \InvalidArgumentException('Original price must be an integer.');
|
||||
}
|
||||
|
||||
$this->originalPrice = $originalPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -351,14 +326,6 @@ class ProductVariant extends BaseVariant implements ProductVariantInterface
|
|||
return $this->depth * $this->height * $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isPriceReduced()
|
||||
{
|
||||
return $this->originalPrice > $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -68,23 +68,6 @@ interface ProductVariantInterface extends
|
|||
*/
|
||||
public function setDepth($depth);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOriginalPrice();
|
||||
|
||||
/**
|
||||
* @param int|null $originalPrice
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setOriginalPrice($originalPrice);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPriceReduced();
|
||||
|
||||
/**
|
||||
* @param TaxCategoryInterface $category
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -51,23 +51,12 @@ final class ProductVariantSpec extends ObjectBehavior
|
|||
$this->getPrice()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_does_not_have_original_price_by_default()
|
||||
{
|
||||
$this->getOriginalPrice()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_price_should_be_mutable()
|
||||
{
|
||||
$this->setPrice(499);
|
||||
$this->getPrice()->shouldReturn(499);
|
||||
}
|
||||
|
||||
function its_original_price_should_be_mutable()
|
||||
{
|
||||
$this->setOriginalPrice(399);
|
||||
$this->getOriginalPrice()->shouldReturn(399);
|
||||
}
|
||||
|
||||
function its_price_should_accept_only_integer()
|
||||
{
|
||||
$this->setPrice(410);
|
||||
|
|
@ -80,15 +69,6 @@ final class ProductVariantSpec extends ObjectBehavior
|
|||
$this->shouldThrow(\InvalidArgumentException::class)->duringSetPrice(new \stdClass());
|
||||
}
|
||||
|
||||
function its_original_price_should_accept_only_integer()
|
||||
{
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->duringSetOriginalPrice(3.1 * 100);
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->duringSetOriginalPrice('310');
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->duringSetOriginalPrice(round(3.1 * 100));
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->duringSetOriginalPrice([310]);
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->duringSetOriginalPrice(new \stdClass());
|
||||
}
|
||||
|
||||
function it_implements_a_shippable_interface()
|
||||
{
|
||||
$this->shouldImplement(ShippableInterface::class);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue