Make $object->fetchObjectLinked() ignore entity

Hi,
I am going insane. I just sank half a day in this problem.

I want to make the LinkedObjectBlock of a custom element type I created able to link to elements in all entities. We use multicompany. And I am willing to make customizations to the core files!

My problem is:

  1. The function showLinkedObjectBlock() calls $object->fetchObjectLinked();

  2. When I tried to analyze how function fetchObjectLinked() works I realized that at the end of the function all linked elements are in the result array ignoring entity

1.BUT the $object of my element type that has the linked objects “looses” the elements with non-fitting entities

  1. I can not find out where the linked objects are removed or even where the entity integer is evaluated when collecting the linked objects.

I hope someone can understand this description.

PLEASE HELP me

Hi,
It’s been a while so I don’t know if my reply will be useful but I also struggled a long time with this LinkedObjectBlock and its functions.
For me the problem was the sourcetype attribute recorded in the database that was not correct, so when the fetchObjectLinked() function was called in the hooked showLinkedObjectBlock() function, the object name was a wrong one, so the first function could not return the object properly.
So the answer for me was to check the showLinkToObjectBlock() function that should be hooked in the actions_mymodule.class.php file and correct the module and object name, like this:

(`)

// showLinkToObjectBlock() function overloaded in actions_mymodule.class.php
$linkToMyObject["mymodule_myobject"] = array(
				'enabled' => isModEnabled('mymodule'),
				'perms' => 1,
				'label' => 'LinkToMyObject',
				'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "mymodule_myobject" as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($parameters['listofidcompanytoscan']) . ') AND t.entity IN (' . getEntity('mymodule_myobject') . ')',		
		);
// then return the $linkToMyObject into results
if (!$error) {
			$this->results = $linkToMyObject;
			$this->resprints = 'A text to show';
			return 0; // or return 1 to replace standard code
		} else {
			$this->errors[] = 'Error message';
			return -1;
		}

Hope it will be useful.