How can you manage data information more easily using Sonata-bundle in Symfony2?

Source: Internet
Author: User

I currently have 3 tables goods , and category brand , in the background of sonata, I want to be able to display the category name and brand name in the list of items, with detailed information:

As you can see, the Iphone6plus category is mobile, where I define the many-to-one relationship in the Yml file, which is shown to be correct, But Brand.name is obviously wrong, Iphone6plus brand should be apple, here I have doubts, I i in goods.yml file defined two times Many-to-one relationship, the second definition is goods with the brand table, and does not display correctly.

I want to be more convenient to manage the goods information, on the same page, browse the product category and brand, on the editing page similarly, how should I implement it? Here is my block of code:

Brand.orm.yml

Application\Sonata\MallBundle\Entity\Brand:    type: entity    table: brand    ...oneToMany:    goods:        targetEntity: Goods        mappedBy: brandlifecycleCallbacks: {  }

Goods.orm.yml

Application\Sonata\MallBundle\Entity\Goods:type: entitytable: goodsrepositoryClass: Application\Sonata\MallBundle\Repository\GoodsRepository...manyToOne:    category:        targetEntity: Category        inverseBy: goods        joinColumn:            name: category_id            referencedColumnName: idmanyToOne:    brand:        targetEntity: Brand        inverseBy: goods        joinColumn:            name: brand_id            referencedColumnName: idlifecycleCallbacks: {  }

Category.orm.yml

Application\Sonata\MallBundle\Entity\Category:type: entitytable: categoryrepositoryClass: Application\Sonata\MallBundle\Repository\CategoryRepository...oneToMany:    goods:        targetEntity: Goods        mappedBy: categorylifecycleCallbacks: {  }

Your suggestion is a great help to me.

Reply content:

I currently have 3 tables goods , and category brand , in the background of sonata, I want to be able to display the category name and brand name in the list of items, with detailed information:

As you can see, the Iphone6plus category is mobile, where I define the many-to-one relationship in the Yml file, which is shown to be correct, But Brand.name is obviously wrong, Iphone6plus brand should be apple, here I have doubts, I i in goods.yml file defined two times Many-to-one relationship, the second definition is goods with the brand table, and does not display correctly.

I want to be more convenient to manage the goods information, on the same page, browse the product category and brand, on the editing page similarly, how should I implement it? Here is my block of code:

Brand.orm.yml

Application\Sonata\MallBundle\Entity\Brand:    type: entity    table: brand    ...oneToMany:    goods:        targetEntity: Goods        mappedBy: brandlifecycleCallbacks: {  }

Goods.orm.yml

Application\Sonata\MallBundle\Entity\Goods:type: entitytable: goodsrepositoryClass: Application\Sonata\MallBundle\Repository\GoodsRepository...manyToOne:    category:        targetEntity: Category        inverseBy: goods        joinColumn:            name: category_id            referencedColumnName: idmanyToOne:    brand:        targetEntity: Brand        inverseBy: goods        joinColumn:            name: brand_id            referencedColumnName: idlifecycleCallbacks: {  }

Category.orm.yml

Application\Sonata\MallBundle\Entity\Category:type: entitytable: categoryrepositoryClass: Application\Sonata\MallBundle\Repository\CategoryRepository...oneToMany:    goods:        targetEntity: Goods        mappedBy: categorylifecycleCallbacks: {  }

Your suggestion is a great help to me.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.