ePages 6.14.0 - DE_EPAGES/RemoteSearch/API/RemoteSearchImpl.pm

Package DE_EPAGES::RemoteSearch::API::RemoteSearchImpl

High level API used by scripts from the RemoteSearch cartridge

Base
Exporter
@EXPORT_OK
GetOrCreateSearchIndex
GetUserAgent
DropAllSearchIndexes
IsRemoteSearchActive
RunIfRemoteSearchInitialized

Functions

DropAllSearchIndexes
GetOrCreateSearchIndex
GetUserAgent
IsRemoteSearchActive
RunIfRemoteSearchInitialized

DropAllSearchIndexes

Resets search info on shop and tries to delete the index from the remote search, if needed.

Syntax
DropAllSearchIndexes( $Shop );
Input
$Shop (object)
Shop
$DropRemote (boolean)
set to true, if you want to remove the remote index

GetOrCreateSearchIndex

Creates (if necessary) and returns SearchIndex object. Does not set the remote call to index the shop. Use DE_EPAGES::RemoteSearch::API::Object::IndexManager for that.

Syntax
my $SearchIndex = GetOrCreateSearchIndex( $Shop );
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
Shop object
Return
$SearchIndex (DE_EPAGES::RemoteSearch::API::Object::SearchIndex)
search index

GetUserAgent

Configure and return an LWP::UserAgent instance. Reads epages.conf sections to configure this object. Used configuration: [DE_EPAGES::RemoteSearch] HTTPTimeOut = 10; default timeout is 10 sec

Syntax
my $UserAgent = GetUserAgent();
Return
$UserAgent (LWP::UserAgent)
configured LWP::UserAgent

IsRemoteSearchActive

Check if remote search can be used for the shop

Syntax
my $IsUseable = IsRemoteSearchActive( $Shop );
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
Shop object
Return
$IsActive (Boolean)
Returns true if System and $Shop flagged have set RemoteSearchEnabled

RunIfRemoteSearchInitialized

Runs code if remote search is active and RemoteSearchIndex object has been created. Passes RemoteProductSearchIndex object into the sub. Non-fatal Errors get turned into Warnings.

Syntax
RunIfRemoteSearchInitialized( $Shop, $cSub );
Example
RunIfRemoteSearchActive($Shop, sub {
    my ($Search) = @_;
    $Search->updateItems([ $Product ]);
});
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
shop
$cSub (ref.code)
code ref