Create a new Product Type
CoreShop allows you to create a new custom Product Type. The most single interface implementation that can be added to
the cart
is the CoreShop\Component\Order\Model\PurchasableInterface
. You therefore have to at least implement this interface if
you want to add a new Product Type and allow it to be added the the cart.
If you need Product Price Rules, Product Specific Price Rules and Quantity Price Rules, you have to go for
the CoreShop\Component\Core\Model\ProductInterface
.
In that case, it is easier to just copy the CoreShopProduct
Class Definition and add it as a new Class.
Registering your Product Type
In Order for CoreShop to know that there is a new Purchasable
, you have to register your class. The easiest way to do
this is, to add this config:
core_shop_resource:
pimcore:
app.my_product:
classes:
model: Pimcore\Model\DataObject\MyProduct
interface: CoreShop\Component\Core\Model\ProductInterface
Or if it's just a Purchasable
:
core_shop_resource:
pimcore:
app.my_product:
classes:
model: Pimcore\Model\DataObject\MyProduct
interface: CoreShop\Component\Order\Model\PurchasableInterface
CoreShop will then create separate Services for you, the mains one are the Factory and the
Repository (app.repository.my_product
, app.factory.my_product
).
You don't need to use them in your Project, but they are quite important internally for CoreShop.