I'm building a shop using some bundles provided by Sylius. I have installed the ResourceBundle, ProductBundle, OrderBundle and CartBundle so far.
I am having trouble when calling the 'sylius_cart_item_add' path on the product page:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Sylius\Bundle\CartBundle\Event\CartEvent::__construct() must be an instance of Sylius\Bundle\CartBundle\Model\CartInterface, instance of XXXX\OrderBundle\Entity\Order given, called in /XXXX/XXXX/XXXX/XXXX/vendor/sylius/cart-bundle/Sylius/Bundle/CartBundle/Provider/CartProvider.php on line 103 and defined in /XXXX/XXXX/XXXX/XXXX/vendor/sylius/cart-bundle/Sylius/Bundle/CartBundle/Event/CartEvent.php line 42
I have installed CartBundle following the documentation (I haven't created a CartItem entity, as is optional according to the guide). This is my config file for Sylius bundles (XXXX stands for my company name):
sylius_resource:
resources:
dinamic.product:
driver: doctrine/orm
classes:
model: XXXX\ProductBundle\Entity\Product
interface: Sylius\Bundle\ProductBundle\Model\ProductInterface
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
repository: Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository
sylius_product:
driver: doctrine/orm
classes:
product:
model: XXXX\ProductBundle\Entity\Product
controller: Sylius\Bundle\ProductBundle\Controller\ProductController
repository: XXXX\ProductBundle\Repository\ProductRepository
form: Sylius\Bundle\ProductBundle\Form\Type\ProductType
sylius_order:
driver: doctrine/orm
classes:
order:
model: XXXX\OrderBundle\Entity\Order
order_item:
model: XXXX\OrderBundle\Entity\OrderItem
sylius_money:
driver: doctrine/orm
sylius_cart:
resolver: XXXX.cart_item_resolver
classes: ~
stof_doctrine_extensions:
orm:
default:
sluggable: true
timestampable: true
I would gladly appreciate any help, thanks in advance.
EDIT: looking in Sylius' code, the problem seems to be in CartBundle/Provider/CartProvider/getCart() function (line 101):
$this->cart = $this->repository->createNew();
This returns a Order object instead of a CartInterface one, seems that the repository is not configured correctly, any suggestions?