在 symfony2 中使用 sonata-bundle,如何更加便捷地管理資料資訊?

來源:互聯網
上載者:User

我目前有3張表goodscategory and brand,在sonata後台中,我希望可以把類別名稱和品牌名稱全部顯示在貨品列表,有詳細的資訊:

從可以看出,iphone6plus的類別是mobile,這裡我在yml檔案中定義了many-to-one的關係,這裡顯示是正確的,但是brand.name很明顯錯了,iphone6plus的品牌應該是apple,這裡我有疑問,我我在 goods.yml 檔案中定義了兩次many-to-one關係,第二次定義的是goodsbrand表,並沒有正確顯示。

我想更便捷地管理貨品資訊,在同一頁面,瀏覽商品類別和品牌,在編輯頁面同理,我應該如何?呢?下面是My 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: {  }

您的建議,對我來說是莫大的協助。

回複內容:

我目前有3張表goodscategory and brand,在sonata後台中,我希望可以把類別名稱和品牌名稱全部顯示在貨品列表,有詳細的資訊:

從可以看出,iphone6plus的類別是mobile,這裡我在yml檔案中定義了many-to-one的關係,這裡顯示是正確的,但是brand.name很明顯錯了,iphone6plus的品牌應該是apple,這裡我有疑問,我我在 goods.yml 檔案中定義了兩次many-to-one關係,第二次定義的是goodsbrand表,並沒有正確顯示。

我想更便捷地管理貨品資訊,在同一頁面,瀏覽商品類別和品牌,在編輯頁面同理,我應該如何?呢?下面是My 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: {  }

您的建議,對我來說是莫大的協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.