Sylius Product Bundle configuration

橙三吉。 提交于 2020-01-13 18:16:44

问题


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 :(


回答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




回答2:


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).



来源:https://stackoverflow.com/questions/28731801/sylius-product-bundle-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!