Forums / Developer / how are eztrade_products related in the database?
harry mentas
Friday 10 September 2010 10:43:14 am
Hello,
I have a client that uses ezpublish. Looking at the tables in Mysql, what tables are used to store related products?
André R.
Sunday 12 September 2010 1:30:55 am
Take a look at ezcontentobject_link, relation_type comes from constants on eZContentObject class:
const RELATION_COMMON = 1; const RELATION_EMBED = 2; const RELATION_LINK = 4; const RELATION_ATTRIBUTE = 8;
If you want to add relations by code you can do it like this (where $object is instance of eZContentObject):
$object->addContentObjectRelation( $newObjectID, $objectVersion, 0, eZContentObject::RELATION_EMBED );
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription @: http://twitter.com/andrerom
Michal Slocinski
Wednesday 15 September 2010 1:52:58 pm
Hi André,
I have similar problem.
I created custom class and added attribute of "Object Relations" type.
Using method similar to the one you presented:
$object->addContentObjectRelation( $newObjectID, $objectVersion, $attributeId, eZContentObject::RELATION_EMBED );
where $attributeId is ID of my attribute in that class of "Object Relations" type.
I can see that relation is being created on "Relations" tab of that object (and "Reverse Related Relation" in destination object has been also created) however in "preview" and when I hit "edit" on that object, I don't see related object(s) being selected in list of checkboxes which represent this relation (note: I chosen to represent this relation as list of checkboxes when adding Object Relations attribute to my class).
Can you give me some hints here?
regards,
Michal
Wednesday 15 September 2010 2:33:54 pm
Hi Andre!
Just to let you know I have found solution.
Basically I used $attribute->fromString(..) method and provided parameter in format listed here: http://ezpedia.org/en/ez/simple_fromstring_and_tostring_interface_for_attributes
Calling $attribute->store() after reading values from string works perfectly now.