Creating a block in "Customers who bought this item also bought"
Good evening!
I have the following situation - I am creating a block in the store: "Customers who bought this item also bought," which should display (recommend) a specific product corresponding to the currently viewed product. The relationship data is established using the Entity reference module. The Views PHP module is also installed to specify the appropriate filters for displaying product recommendations in the custom block.
In the Global:PHP filter criteria, I wrote the following code in the filter code field to display the recommended product in the block:
if (arg(0) && arg(0) == 'node') {
$related_ids = array();
$node = node_load(arg(1));
$related = field_get_items('node', $node, 'field_pd_related_products');
if ($related && is_array($related) && sizeof($related) > 0) {
for ($i=0; $i
$related_ids[] = $related[$i]['target_id'];
}
}
}
return (isset($related_ids) && in_array($row->nid, $related_ids) ? FALSE : TRUE );
As a result, the block does not appear next to the product display where the relationship is established using the Entity reference module. What is the problem? Is the code correct?