Hello,
I am working on a package for my company eCommerce website which will be based on ConcreteCMS and CommunityStore.
I have to make this ConcreteCMS interacting with a Prestashop ERP (I know it is not an ideal stack), and I have to add per-warehouse stock on the website to display some ship delays.
I actually have an Entity ProductInventory
that looks like this:
<?php
namespace Concrete\Package\CommunityStoreSi3bRabbitmq\Entities;
// Workaround https://grafikart.fr/forum/29227
use Doctrine\Mapping\{Entity, Table, Id, GeneratedValue, Column, ManyToOne, JoinColumn};
use Concrete\Core\Support\Facade\DatabaseORM as dbORM;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product;
/**
* @Entity
* @Table(name="CommunityStoreSi3bProductInventory")
*/
class ProductInventory
{
/**
* @Id
* @GeneratedValue
* @Column
*/
private ?int $id = null;
/**
* @Column(type="text")
*/
private string $barcode;
/**
* @Column
*/
private ?int $quantity = null;
/**
* @ManyToOne(inversedBy = "productInventories")
* @JoinColumn(nullable = false)
*/
private ?Warehouse $warehouse = null;
/**
* @ManyToOne(targetEntity = "Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product", inversedBy = "productInventories")
* @JoinColumn(name = "barcode", referencedColumnName = "pBarcode", nullable = false)
*/
private Product $product;
The issue I have is with this $product property. Unluckily, Product::pBarcode is not marked as unique, therefore I cannot define it as a foreign key. I would like to know if I can add the UNIQUE property to this column ideally without having to fork CommunityStore. In my context, it is very relevant to define barcode as unique.