Hello everyone, I briefly explain my problem:
I have custom modules related to each other, I need to add a relationship to one module when in another module I create a relationship (by creating a relationship I add others). Apparently the relationships are created (I can see it from the DB), but only one is set with deleted=0 field, the others have deleted=1 and I don’t understand why.
Trying to understand the problem step by step, I made a test by eliminating all foreach loops and creating an array of only 2 ids of the modules that must be part of the relationship, adding this array, again only one element is added (even if both appear in the DB, but one is set to deleted=1).
The procedure is this:
logic_hooks.php:
$hook_array[‘after_save’] = Array();
$hook_array[‘after_save’][] = Array(1, ‘afterSave’, ‘custom/modules/ModuleA/relation.php’, ‘relation’, ‘afterSave’);
relation.php:
$bean->load_relationship(’<moduleA_moduleB>’);
$pz=array(‘id_1’,‘id_2’);
$bean-><moduleA_moduleB>->add($pz);
If I load an id individually, it is added normally, but if I try to insert them via a loop or a group (array or bean), only one is added, the other, as mentioned, although added, its deleted field is set to 1.
Can someone please tell me the reason for this behavior? I am going crazy. Thanks