PHP code example of bitbag / product-bundle-plugin
1. Go to this page and download the library: Download bitbag/product-bundle-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/ */
declare(strict_types=1);
namespace App\Entity\Product;
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface;
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareTrait;
use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Product as BaseProduct;
use Sylius\Component\Product\Model\ProductTranslationInterface;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_product')]
class Product extends BaseProduct implements ProductInterface
{
use ProductBundlesAwareTrait;
/**
* @var ProductBundleInterface
*/
#[ORM\OneToOne(
targetEntity: "BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface",
mappedBy: "product",
cascade: ["all"]
)]
protected $productBundle;
protected function createTranslation(): ProductTranslationInterface
{
return new ProductTranslation();
}
}
declare(strict_types=1);
namespace App\Entity\Order;
use BitBag\SyliusProductBundlePlugin\Entity\OrderItemInterface;
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemInterface;
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemsAwareTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_order_item')]
class OrderItem extends BaseOrderItem implements OrderItemInterface
{
use ProductBundleOrderItemsAwareTrait;
public function __construct()
{
parent::__construct();
$this->init();
}
/**
* @var ArrayCollection|ProductBundleOrderItemInterface[]
*/
#[ORM\OneToMany(
targetEntity: "BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemInterface",
mappedBy: "orderItem",
cascade: ["all"]
)]
protected $productBundleOrderItems;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.