ePages 7.37.0 - DE_EPAGES/RemoteSearch/API/AttributeModifiedCheck.pm

Package DE_EPAGES::RemoteSearch::API::AttributeModifiedCheck

Helper for testing for attribute modifications.

Base
Exporter
@EXPORT_OK
RunIfModified

Functions

RunIfModified

RunIfModified

Check if at least one attribute is about to be changed. If yes, run the closure sub. This can be used in a BeforeUpdate Hook listener, to filter for relevant changes.

Syntax
RunIfModified( $Object, $aAttributes, $hNewValues, $LanguageID, $aTypes, $cSub );
Example
# hook listener (API_BeforeUpdateProductPrice)
sub OnBeforeUpdateProductPrice {
    my ($hInfo) = @_;
    RunIfModified(
      sub { GetInfoProductPrice($hInfo->{'ProductID}, $hInfo->{'CurrencyID'} ) },
      ['ListPrice'],
      $hInfo,
      undef,
      ['Money'],
      sub { BatchUpdateProduct(LoadObject($hInfo->{'ProductID'})) }
    );
}
Input
$ObjectOrCode (object or ref.code)
source object or sub for retrieving attribute information.
code should return a hashref.
$aAttributes (ref.array.string)
list of attribute names
$hNewValues (ref.hash.*)
new values
$LanguageID (int)
languageid, if undef non-localized get() will be used
$aTypes (string)
Type hint for testing equality of values correctly. For a list of
valid types see DE_EPAGES::Core::API::PerlTools::Compare
$cSub (ref.code)
sub to run