You are viewing a Product Display Page. Therefore your context is the nid of the Product Display you are looking at. You now need to load the title and body field and pass that as a string to your view's contextual filter.
You can do this in various ways:
- Use
hook_views_pre_view
in a custom module
Allows altering a view at the very beginning of views processing,
before anything is done.
Adding output to the view can be accomplished by placing text on
$view->attachment_before and $view->attachment_after.
Parameters
$view: The view object about to be processed.
$display_id: The machine name of the active display.
$args: An array of arguments passed into the view.
You implement this hook in a custom module
check the $view argument for your view's name and display id
load the Product Display using menu_get_object which will return the $node.
Inspect $node to get the title and body, which you then concatenate and you then
set this as the argument on $args which is one of the parameters passed by reference to hook_views_pre_view
.
- Use Views Field
View
There are a lot of cases in views where you want to embed a list
inside each row. One example could be, you have a list of groups, and
for each groups you want to list the first and last name of all of
their members.
This can be achieved with this module, as views_field_view allows you
to embed one view into another view and pass arguments along.
For this method you create a parent view block of Product Display (nodes) and for the contextual filter take the node id from the url. This is the view that will display your related products. After you have constructed it test it so that it shows the exact same product as the product page you are embedding it on.
So now you have a block that shows the same Product Display as the main page shows. Now you need to link it to the search api view.
First change the fields. Make sure that you have title field and body field added to your parent view, then set them to be hidden. Add a global text field and using the tokens from the above two fields add them with a space between them as in : [title] [body] so that the title and body is now one field. Again set this field to be hidden.
Because you installed Views Field View you can now add another field Global:View field. This field allows you to select a view to embed. You now select your search api view. It also allows you to pass parameters to the view, so you select the token for the global text field that is hidden.
Lastly set caching to some time value for this view so that it performs quickly.
ADDED
For option 1 (custom module) the code will go roughly like this (I currently don't have Drupal installed so I can only provide pointers. You will have to inspect the $node object via dpm() to get to the body field, which may be on the Product Display node or on the referenced Product type)
function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
if ($view->name == "VIEWMACHINENAME" && $display_id == "VIEWDISPLAYID") {
$node = menu_get_object(); // defaults are fine
dpm($node); // comment out when code works
if (isset($node->content...)) { // inspect output from dpm to get field
$argument = strip_tags($node->content...); // same field from if statement
$args = array($argument);
}
}
}