3

I'm trying to integrate Sylius Product Bundle into my existing Symfony project. It already has doctrine configured.

This is the error I am getting:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]  
  The child node "driver" at path "sylius_attribute" must be configured. 

Any idea what's causing this? I followed the instruction right off the bat without doing any other installations of sylius.

http://docs.sylius.org/en/latest/bundles/SyliusProductBundle/installation.html

I had to change the doctrine-bundle version in my composer.json file to allow the

composer require "sylius/product-bundle"

to run successfully without errors. I changed the version from 1.2.* to

"doctrine/doctrine-bundle": "1.3.*"

Also after composer installed these guys, i added the following to my config.yml file

sylius_product:
    driver: doctrine/orm
    classes:
        product:
            model: Sylius\Bundle\CoreBundle\Model\Product
            controller: Sylius\Bundle\CoreBundle\Controller\ProductController
            repository: Sylius\Bundle\CoreBundle\Repository\ProductRepository

stof_doctrine_extensions:
    default_locale: es_us
    translation_fallback: true
    orm:
        default:
            tree: true

Initially I was getting the following error:

[Exception]                                                                                         
  Missing parameter sylius.translation.default.mapping. Default translation mapping must be defined! 

After a little searching around I added the piece below to the config.yml file

sylius_translation:
    default_mapping:
        translatable:
            field: translations
            currentLocale: currentLocale
            fallbackLocale: fallbackLocale
        translation:
            field: translatable
            locale: locale

Already existing earlier in my config.yml file was:

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8       
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true

I didn't change anything in these settings.

What am i doing wrong here or missing? ANy help will be greatly appreciated.

Thanks!


EDIT


I tried adding all the below items:

sylius_attribute:
    driver: doctrine/orm
sylius_variation:
    driver: doctrine/orm
sylius_archetype:
    driver: doctrine/orm

Now I get the following error:

[InvalidArgumentException]                                      
  The class sylius.model.product_archetype.class does not exist. 

I added the corresponding file to the AppKernel with still no luck!

new Sylius\Bundle\AttributeBundle\SyliusArchetypeBundle(),

and then changed it to:

new Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),

Setting up Sylius has been quiet stressful so far :(

softie
  • 237
  • 1
  • 2
  • 17

2 Answers2

3

I've updated the docs for the ProductBundle:

In composer.json you'll need to add these lines:

"require": {
    ...
    "sylius/locale-bundle": "0.13.*",
    "sylius/product-bundle": "0.13.*"
    ...
}

In app/AppKernel.php:

        new FOS\RestBundle\FOSRestBundle(),
        new JMS\SerializerBundle\JMSSerializerBundle($this),
        new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
        new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),

        new Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),
        new Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
        new Sylius\Bundle\ProductBundle\SyliusProductBundle(),
        new Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
        new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
        new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
        new Sylius\Bundle\VariationBundle\SyliusVariationBundle(),

        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),

In config.yml:

parameters:
    sylius.locale: "%locale%"

sylius_archetype:
    classes:
        product:
            subject: Sylius\Component\Product\Model\Product
            attribute: Sylius\Component\Product\Model\Attribute
            option: Sylius\Component\Product\Model\Option
            archetype:
                model: Sylius\Component\Product\Model\Archetype
                repository: Sylius\Bundle\ResourceBundle\Doctrine\ORM\TranslatableEntityRepository
                translatable:
                    targetEntity: Sylius\Component\Product\Model\ArchetypeTranslation
            archetype_translation:
                model: Sylius\Component\Product\Model\ArchetypeTranslation

sylius_attribute:
    driver: doctrine/orm

sylius_product:
    driver: doctrine/orm

sylius_locale:
    driver: doctrine/orm

sylius_translation:
    default_mapping:
        translatable:
            field: translations
            currentLocale: currentLocale
            fallbackLocale: fallbackLocale
        translation:
            field: translatable
            locale: locale

sylius_variation:
    driver: doctrine/orm

stof_doctrine_extensions:
    orm:
        default:
            sluggable: true
            timestampable: true

Now you should be able to run schema update successfully

$ php app/console doctrine:schema:update --dump-sql

If satisfied, execute:

$ php app/console doctrine:schema:update --force

Update: This configuration will break when upgrading to 0.14 (current released version is 0.13).

Adam Elsodaney
  • 7,722
  • 6
  • 39
  • 65
1

It wasn't mention on the tutorial you followed but I think it will help you :

https://github.com/Sylius/Sylius-Docs/blob/master/bundles/SyliusAttributeBundle/installation.rst#container-configuration

henrily
  • 236
  • 1
  • 5
  • 1
    thanks @henrily. I appreciate the help. I still ran into a few problems. Please take a look at the edit in my question. – softie Feb 26 '15 at 17:22
  • I developed the ArchetypeBundle and initially modified the ProductBundle to automatically configure product archetypes in the container, but this was later removed and the docs not updated. I'll update the docs so this doesn't become an issue. :) Cheers! – Adam Elsodaney Feb 28 '15 at 21:37