php - Unknown related component on class with Doctrine inheritance, Symfony 1.4 -


i have symfony 1.4 project show products in category product view. products can viewed in different categories have many-to-many relationship between product , category.

i have different types of products have used doctrine inheritance define them of them share lot of same properties.

now problem having when trying add product category getting error:

unknown record property / related component "categoriesfeaturedin" on "multiproduct" 

categoriesfeaturedin property on product holds categories in defined in doctrine schema.

multiproduct inherits product should have property yes?

i post below schema , code i'm using adding product category. can , can provide more information neccessary.

--

schema: (not whole file)

category:   actas:     sluggable:       fields: [title]   columns:     id:       type:             integer       primary:          true       notnull:          true       autoincrement:    true     title:       type:             string(255)       notnull:          true     image:       type:             string(255)     store_id:       type:             integer       notnull:          true     sort_order:       type:             integer   relations:     store:       class:            store       local:            store_id       ondelete:         cascade       foreignalias:     categories     parents:       class:            category       refclass:         categorycategory       foreign:          parent_category_id       foreignalias:     subcategories  categoryfeaturedproduct:   columns:     category_id:       type:             integer       primary:          true     product_id:       type:             integer       primary:          true   relations:     category:       foreignalias:     featuredproducts       ondelete:         cascade     product:       foreignalias:     categoriesfeaturedin       ondelete:         cascade  product:   actas:     sluggable:       fields: [title]   columns:     id:       type:             integer       primary:          true       notnull:          true       autoincrement:    true     title:       type:             string(255)     description:       type:             string(255)     link:       type:             string(255)     image:       type:             string(255)     large_image:       type:             string(255)     featured_image:       type:             string(255)     sku:       type:             string(64)     mpid:       type:             string(64)     stock:       type:             integer     price:       type:             decimal     rrp:       type:             decimal     was_price:       type:             decimal     rating:       type:             decimal     sort_order:       type:             integer     promotion_id:       type:             integer     manufacturer_id:       type:             integer       notnull:          true   relations:     promotion:       class:            promotion       local:            promotion_id       ondelete:         set null       foreignalias:     products     manufacturer:       class:            manufacturer       local:            manufacturer_id       ondelete:         cascade       foreignalias:     products     categories:       class:            category       refclass:         productcategory       foreignalias:     products     categoriesfeaturedin:       class:            category       refclass:         categoryfeaturedproduct       foreignalias:     featuredproducts  multiproduct:   inheritance:     extends:            product     type:               column_aggregation     keyfield:           type     keyvalue:           2 

code:

$product = producttable::getinstance()->find($prod_id); $category = categorytable::getinstance()->find($cat_id); $product->addcategoryfeaturedin($category); 

product class:

public function addcategoryfeaturedin($category) {     $this->categoriesfeaturedin[] = $category; } 

i managed resolve issue although i'm not entirely sure on answer did 2 things , worked.

firstly reordered schema file reads so:

category:   actas:     sluggable:       fields: [title]   columns:     id:       type:             integer       primary:          true       notnull:          true       autoincrement:    true     title:       type:             string(255)       notnull:          true     image:       type:             string(255)     store_id:       type:             integer       notnull:          true     sort_order:       type:             integer   relations:     store:       class:            store       local:            store_id       ondelete:         cascade       foreignalias:     categories     parents:       class:            category       refclass:         categorycategory       foreign:          parent_category_id       foreignalias:     subcategories  product:   actas:     sluggable:       fields: [title]   columns:     id:       type:             integer       primary:          true       notnull:          true       autoincrement:    true     title:       type:             string(255)     description:       type:             string(255)     link:       type:             string(255)     image:       type:             string(255)     large_image:       type:             string(255)     featured_image:       type:             string(255)     sku:       type:             string(64)     mpid:       type:             string(64)     stock:       type:             integer     price:       type:             decimal     rrp:       type:             decimal     was_price:       type:             decimal     rating:       type:             decimal     sort_order:       type:             integer     promotion_id:       type:             integer     manufacturer_id:       type:             integer       notnull:          true   relations:     promotion:       class:            promotion       local:            promotion_id       ondelete:         set null       foreignalias:     products     manufacturer:       class:            manufacturer       local:            manufacturer_id       ondelete:         cascade       foreignalias:     products     categories:       class:            category       refclass:         productcategory       foreignalias:     products     categoriesfeaturedin:       class:            category       refclass:         categoryfeaturedproduct       foreignalias:     featuredproducts  multiproduct:   inheritance:     extends:            product     type:               column_aggregation     keyfield:           type     keyvalue:           2  categoryfeaturedproduct:   columns:     category_id:       type:             integer       primary:          true     product_id:       type:             integer       primary:          true   relations:     category:       foreignalias:     featuredproducts       ondelete:         cascade     product:       foreignalias:     categoriesfeaturedin       ondelete:         cascade 

i changed product method read so:

public function addcategory($category) {     $this->getcategories()->add($category); } 

i imagine reordering of schema file did trick , fixed problem suggest need define relationships in schema after have defined actual tables related.

the change of method didnt affect worth noting believe better way add many-to-many relationship.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -