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.