2017-04-25 1 views
1

Sylius ProductImage를 번역 할 수있게되어 화가났습니다. 나는 SEO 목적을 위해 ProductImage 이름과 슬러그가 필요하다. 이미 수행 한 어떤Sylius ProductImage 번역 가능하게하기

은 다음과 같습니다 그것에 sylius.model.product_image.class

  • 추가 TranslatableInterface 및 필요한 기능
  • 추가 ProductImageTranslation 엔티티
  • 추가 :

    • 무시 PARAM을 통해 ProductIamge ProductImage.orm.yml의 매핑 파일 & ProductImageTranslation.orm.yml
    • 확장 config.yml
    • ,451,515,

    ProductImage.orm.yml

    AppBundle\Entity\ProductImage: 
        type: entity 
        table: sylius_product_image 
    

    ProductImageTranslation.orm.yml

    AppBundle\Entity\ProductImageTranslation: 
        type: entity 
        table: app_product_image_translation 
        id: 
         id: 
          type: integer 
          generator: 
         strategy: AUTO 
        fields: 
         name: 
          type: string 
          nullable: true 
         slug: 
          type: string 
          nullable: true 
          unique: true 
    

    config.yml

    sylius_resource: 
        resources: 
         app.product_image: 
          classes: 
           model: AppBundle\Entity\ProductImage 
           form: AppBundle\Form\Type\ProductImageType 
          translation: 
           classes: 
            model: AppBundle\Entity\ProductImageTranslation 
            form: AppBundle\Form\Type\ProductImageTranslationType 
    

    결과는 다음 에러이다

    An exception occurred while executing 'SELECT t1.type AS type_2, t1.path AS path_3, t1.id AS id_4, t1.owner_id AS owner_id_5 FROM sylius_product_image t1 WHERE t0.owner_id = ?' with params [22]: 
    
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.owner_id' in 'where clause' 
    

    오류가 조인 변환 테이블이 없기 때문에 발생합니다.

    또한 sylius_core에 기본 ProductImage를 오버라이드 (override) 할 필요가
  • +0

    마이그레이션 및/또는 업데이트 된 스키마도 생성 및 적용 했습니까? 'php bin/console doctrine : migration : diff' 또는'php bin/console doctrine : schema : update' – nakashu

    +0

    예, 번역 결과 테이블을 볼 수 있습니다 :'app_product_image_translation' –

    답변

    0

    (http://docs.sylius.org/en/latest/customization/model.html)

    config.yml : 다음

    sylius_resource: 
        resources: 
         app.product_image: 
          classes: 
           model: AppBundle\Entity\ProductImage 
          translation: 
           classes: 
            model: AppBundle\Entity\ProductImageTranslation 
    
    sylius_core: 
        resources: 
         product_image: 
          classes: 
           model: AppBundle\Entity\ProductImage 
    

    그리고 번역 가이드를 따르 http://docs.sylius.org/en/latest/cookbook/custom-translatable-model.html

    모든 지침을 따라야하는 경우, 새로운 엔티티를 생성 할 수 있지만 다음과 같이 표시됩니다.

    The association AppBundle\Entity\ProductImageTranslation#translatable refers to the inverse side field AppBundle\Entity\ProductImage#translations which does not exist. 
    

    당신은

    은 아마 sylius 핵심 구성원이 우리에게 단서를 얻을 수 있다면 분명히 할 수있는 일이 아니다 'product_image'... 아래의 '번역'노드를 Sylius\Bundle\CoreBundle\DependencyInjection\Configuration 을 편집하고 추가 작업을 할 수 있습니다. ..

    +1

    답장을위한 Thx. 그 오류는 없어지지 않았습니다. 번역본을 관리자에게 표시되는 양식에 추가했습니다. 그러나 그것을 저장하는 동안 새로운 오류가 와서 .. -.- _CRITICAL - catch되지 않은 PHP 예외 심포니 \ 구성 요소 \ 디버그 \ 예외 \의 FatalThrowableError : "배열에() 멤버 함수로 setLocale에 전화"에서의/var/www가 /dev/vendor/sylius/sylius/src/Sylius/Bundle/ResourceBundle/Form/Type/ResourceTranslationsType.php line 63_ 문서를 다시 검사했지만 여전히 문제를 찾을 수 없습니다. –