PHP code example of tavy315 / sylius-sales-prices-plugin
1. Go to this page and download the library: Download tavy315/sylius-sales-prices-plugin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tavy315 / sylius-sales-prices-plugin example snippets
// src/Entity/Product/ProductVariant.php
namespace App\Entity\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
use Tavy315\SyliusSalesPricesPlugin\Entity\ProductVariantInterface;
use Tavy315\SyliusSalesPricesPlugin\Entity\SalesPriceInterface;
use Tavy315\SyliusSalesPricesPlugin\Traits\SalesPriceableInterface;
use Tavy315\SyliusSalesPricesPlugin\Traits\SalesPriceableTrait;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product_variant")
*/
class ProductVariant extends BaseProductVariant implements SalesPriceableInterface, ProductVariantInterface
{
use SalesPriceableTrait;
/**
* @ORM\OneToMany(targetEntity="Tavy315\SyliusSalesPricesPlugin\Entity\SalesPrice", mappedBy="productVariant", orphanRemoval=true, cascade={"all"})
* @ORM\OrderBy({"priceGroup"="ASC","qty"="ASC"})
* @var SalesPriceInterface[]|ArrayCollection
*/
protected $salesPrices;
public function __construct()
{
parent::__construct();
$this->initSalesPriceableTrait();
}
}
// src/Model/Product/ProductVariant.php
namespace App\Entity\Product;
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
use Tavy315\SyliusSalesPricesPlugin\Entity\ProductVariantInterface;
use Tavy315\SyliusSalesPricesPlugin\Traits\SalesPriceableInterface;
use Tavy315\SyliusSalesPricesPlugin\Traits\SalesPriceableTrait;
class ProductVariant extends BaseProductVariant implements SalesPriceableInterface, ProductVariantInterface
{
use SalesPriceableTrait;
public function __construct()
{
parent::__construct();
$this->initSalesPriceableTrait();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.