ePages 6.10 - DE_EPAGES/Product/API/Object/Product.pm

Package DE_EPAGES::Product::API::Object::Product

object interface for Product.

Base
DE_EPAGES::Content::API::Object::ContentObject

Functions

adaptLayout
addBundleToStock
addLineItemEcoParticipation
addToBundle
addToContainer
addToStock
appointmentPrepayment
appointmentPrice
availableQuantity
businessHours
canAddToBasket
className
correctQuantity
createURI
dbPackage
defaultObject
discount
filePath
getDirectEcoParticipation
getDirectListPrice
getDirectManufacturerPrice
getEcoParticipation
getListPrice
getManufacturerPrice
getPrepayment
getWithParent
hasPrice
invalidatePageCache
isAllowedChild
isDeliveryTimeLonger
lineItem
price
recalculateLineItem
renumberBundleProductMaps
renumberDownloadProductMaps
requiredChildClass
setEcoParticipation
setListPrice
setManufacturerPrice
setPrepayment
stockAlert
substractBundleFromStock
substractFromStock
taxMatrix
templatePath
timeFactor
updateBundleEcoParticipation

adaptLayout

Changes selected templates to 0 if product has no bundles or variation.

Syntax
$Product->adaptLayout($hInfo);
Input
$hInfo (ref.hash.hash)
template type info, used key is 'Templates'

addBundleToStock

Adds the given Quantity to the Stocklevel of each bundled product. See also addToStock($Quantity). If the product is no bundle then this function is called for this product.

Syntax
$Product->addBundleToStock($Quantity);
Input
$Quantity (float)
product quantity

addLineItemEcoParticipation

Adds a eco Particpation lineitem for the given tax class, if not exists yet.

Syntax
$LineItemEcoParticipation = $Container->addLineItemEcoParticipation($Container, $TaxClass);
Input
$Container (object)
lineitem container
$TaxClass (float)
tax class | object
$input $TaxRate | tax rate
Return
$LineItemParticipation (object)
line item eco participation

addToBundle

Adds this product to a product bundle.

Syntax
$Product->addToBundle( $BundleProduct, $hInfo );
Example
$Product->addToBundle( $BundleProduct, { BundledQuantity => 2 } );
Input
$BundleProduct (object)
bundle product
$hInfo (ref.hash)
keys
  • BundledQuantity - quantity (optional default=MinOrder)- float
  • .... (optional)- ...

addToContainer

Adds the product to the line item container (of a basket or order). If a line item of the same product already exists in the basket, then the function acts according to the shop preference Shop.AddToBasketStyle:

Syntax
$LineItem = $Product->addToContainer( $Container, $hInfo );
Example
Transaction( sub {
    my $Basket = GetBasket( $User, $Shop );
    my $LineItem = $Product->addToContainer( $Basket->container, {
        Quantity => 3
    } );
    $Basket->recalculate;
} );
Input
$Container (object)
line item container
$hInfo (ref.hash)
keys
  • Quantity - quantity (optional default=MinOrder)- float
  • CurrencyID - alpha currency code (optional default=Container.CurrencyID) - char(3)
  • TaxModel - gros or net price (optional default=Container.TaxModel) - int
  • .... (optional)- ...
Return
$LineItem (object)
line item

addToStock

Increments the StockLevel by the given Quantity.

Syntax
$Product->addToStock($Quantity);
Input
$Quantity (float)
product quantity

appointmentPrepayment

Returns product price includes discount and duration data.

Syntax
$Price = $Product->appointmentPrepayment($Appointment, $hInfo);
Input
$Appointment (object)
calendar appointment (optional if Quantity and Duration set)
$hInfo (ref.hash)
session info, possible keys
  • Quantity - quantity (optional default=MinOrder)- float
  • CurrencyID - alpha currency code (optional default=Shop.CurrencyID) - char(3)
  • TaxModel - gros or net price (optional default=Shop.TaxModel) - int
  • Duration - duration of appointment in seconds - int
  • User - user how use appointment (optional) - object
Return
$Price (float)
calculated price

appointmentPrice

Returns product price includes discount and duration data.

Syntax
$Price = $Product->appointmentPrice($Appointment, $hInfo);
Input
$Appointment (object)
calendar appointment (optional if Quantity and Duration set)
$hInfo (ref.hash)
session info, possible keys
  • Quantity - quantity (optional default=MinOrder)- float
  • CurrencyID - alpha currency code (optional default=Shop.CurrencyID) - char(3)
  • TaxModel - gros or net price (optional default=Shop.TaxModel) - int
  • Duration - duration of appointment in seconds - int
  • User - user how use appointment (optional) - object
Return
$Price (float)
calculated price

availableQuantity

Ckecks if the given quantity value is valid according to the products MinOrder and IntervalOrder settings. Then checks if the desired amount is actually on stock. If one order multiple line items of the same product, pass the quantity of the other line items as second parameter ($ExistingQuantity). Returns the closest quantity that can actually be ordered. Returns 0 if the product cannot be ordered.

Syntax
$AvailableQuantity = $Product->availableQuantity( $DesiredQuantity, $ExistingQuantity );
Input
$DesiredQuantity (float)
user wants quantity
$ExistingQuantity (float)
quantity of other lineitems (optional default=0)
Return
$AvailableQuantity (float)
product allow quantity (MinOrder and IntervalOrder )

businessHours

Returns product calendar (child BusinessHours), if not exists then the calendar will be created.

Syntax
$Calendar = $Product->businessHours;
Return
$Calendar (object)
calendar object

canAddToBasket

Tests if a product can be added to the basket with the given quantity.

Syntax
$CanAddToBasket = $Product->canAddToBasket($Quantity);
Input
$Product (object)
product
$Quantity (float)
quantity (optional: default Product.MinOrder)
Return
$CanAddToBasket (boolean)
true if the pruduct can be added to the basket

className

Returns the class name, used for DAL access.

Syntax
$ClassName = $Product->className;
Return
$ClassName (String)
class name

correctQuantity

Checks if a given quantity of the product can be ordered according to the products minimum order amount (MinOrder) and interval amount (IntervalOrder). Returns the next valid quantity value if the desired amount cannot be ordered. This function does not check the current stock level.

Syntax
$ValidQuantity = $Product->correctQuantity( $DesiredQuantity );
Example
print $Object->correctQuantity( 17.5 );
Input
$DesiredQuantity (float)
quantity desired by the user
Return
$ValidQuantity (float)
quantity allowed by the product attributes
MinOrder and IntervalOrder

createURI

Returns a suggestion for a short url.

Syntax
$URI = $Object->createURI($Name, $Parent, $LanguageID);
Return
$URI (string)
suggested URI

dbPackage

Returns the database package, used for DAL access.

Syntax
$DbPackage = $Product->dbPackage;
Return
$DbPackage (String)
database package name

defaultObject

Returns the default object (has to be overwritten for products with variation).

Syntax
$ContentObject = $Object->defaultObject();
Return
$ContentObject (object)
product or
default subproduct for product with variation

discount

Returns the product discount by the given requirements. The hook 'ProductDiscount' is triggered before the standard discount = 0.

Syntax
$Discount = $Product->discount( $hVars );
Example
$Discount = $Product->discount( {
    CurrencyID => 'USD',
    TaxModel => $Product->getSite()->get('TaxModel')
} );
Input
$hVars (ref.hash)
  • CurrencyID - alpha currency code (ISO 4217) - char(3)
  • TaxModel - gros or net price - int
  • Container - Container (optional)- LineItemContainer
  • LineItem - LineItemProduct (optional)- LineItemProduct
  • User - user (optional)- User
  • Customer - customer (optional)- Customer
  • .... (optional)- ...
Return
$Discount (money)
discount of product

filePath

Returns the relative file path of object from the System file path. If the product is an variation the filePath of the SuperProduct will returned.

Syntax
$Object->filePath;
Return
$Path (string)
relative file path

getDirectEcoParticipation

Returns the eco participation that is defined on directly on this product object. Returns undef if $Product is a sub product that does not have its own price and inherits its price from the super product.

Syntax
$Value = $Product->getDirectEcoParticipation($CurrencyID, $TaxModel);
Example
$Value = $Product->getDirectEcoParticipation('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$ExtraPrecision (int)
extra precision
Return
$Value (float)
price

getDirectListPrice

Returns the list price that is defined on directly on this product object. Returns undef if $Product is a sub product that does not have its own price and inherits its price from the super product.

Syntax
$Value = $Product->getDirectListPrice($CurrencyID, $TaxModel);
Example
$Value = $Product->getDirectListPrice('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$ExtraPrecision (int)
extra precision
Return
$Value (float)
price

getDirectManufacturerPrice

Returns the manufacturer's suggested retail price (MSRP) that is defined directly on this product object. Returns undef if $Product is a sub product that does not have its own MSRP and inherits its MSRP from the super product.

Syntax
$Value = $Product->getDirectManufacturerPrice($CurrencyID, $TaxModel);
Example
$Value = $Product->getDirectManufacturerPrice('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$ExtraPrecision (int)
extra precision
Return
$Value (float)
price

getEcoParticipation

Returns the eco participation of this product. Returns the eco participation of the super product if $Product is a sub product that does not have its own price, i.e. the attribute HasSubOwnPrices is false. Returns undef if the product does not have a eco participation.

Syntax
$Value = $Product->getEcoParticipation($CurrencyID, $TaxModel);
Example
$Value = $Product->getEcoParticipation('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$ExtraPrecision (int)
extra precision
Return
$Value (float)
price

getListPrice

Returns the list price of this product. Returns the list price of the super product if $Product is a sub product that does not have its own price, i.e. the attribute HasSubOwnPrices is false. Returns undef if the product does not have a list price.

Syntax
$Value = $Product->getListPrice($CurrencyID, $TaxModel);
Example
$Value = $Product->getListPrice('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$ExtraPrecision (int)
extra precision
Return
$Value (float)
price

getManufacturerPrice

Returns the manufacturer's suggested retails price (MSRP) of this product. Returns the MSRP of the super product if $Product is a sub product that does not have its own price, i.e. the attribute HasSubOwnPrices is false. Returns undef if the product does not have an MSRP.

Syntax
$Value = $Product->getManufacturerPrice($CurrencyID, $TaxModel);
Example
$Value = $Product->getManufacturerPrice('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.TaxModel)
$ExtraPrecision (int)
extra precision
Return
$Value (float)
price

getPrepayment

Returns the prepayment of this product. Returns undef if the product does not have a prepayment.

Syntax
$Value = $Product->getPrepayment($CurrencyID, $TaxModel);
Example
$Value = $Product->getPrepayment('EUR', 1);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$ExtraPrecision (int)
extra precision
Return
$Prepayment (float)
price

getWithParent

Returns the values of product attributes. Similar to $Object->get(). If called on a sub product and the attribute value is not defined for the sub product, then returns the attribute value of its super product.

Syntax
$hValues = $Product->getWithParent($aNames, $LanguageID);
$hValues = $Product->getWithParent($aNames);
$Values = $Product->getWithParent($Name, $LanguageID);
$Value = $Product->getWithParent($Name);
Example
my $LangugaeID = GetPKeyLanguageByCode('en');
my $Description = $Product->getWithParent('Description', $LanguageID);
Input
$aNames (ref.array.string)
list of attribute names
$LanguageID (integer)
language id
$Name (string)
attribute name
Return
$hValues (ref.hash)
attribute name => value hash
$Values (scalar)
attribute value

hasPrice

Returns true if the product has a price. The result may depend on the customer or indirectly on the user. If no user or customer is given, returns whether there is a price for anonymous customers.

Syntax
$HasPrice = $Product->hasPrice;
$HasPrice = $Product->hasPrice( $hVars );
Example
if( $Product->hasPrice ) { ... }
if( $Product->hasPrice( { Customer => $Customer } ) ) { ... }
if( $Product->hasPrice( { User => $User } ) ) { ... }
Input
$hVars (ref.hash)
  • Customer - customer (optional)- Customer
  • User - user (optional)- User
Return
$HasPrice (boolean)
true if the product has a price

invalidatePageCache

Invalidates page cache of this product (mark at site).

Syntax
$Product->invalidatePageCache;

isAllowedChild

Returns if an Object could be the parent of a PossibleChild.

Syntax
$isAllowed = $Object->isAllowedChild($PossibleChild);
Return
$isAllowed (boolean)
is a allowed child type

isDeliveryTimeLonger

Tests if a product has a longer delivery time, because it is not currently on stock. The current basket is not involved.

Syntax
$IsLonger = $Product->isDeliveryTimeLonger();
Return
$IsLonger (boolean)
delivery time is longer

lineItem

Returns the required attributes to create a product line item object, which can be added to the line item container of a basket or order. Use addToContainer instead of calling this function directly.

Syntax
$hLineItem = $Product->lineItem( $Container, $hInfo );
Input
$Container (object)
line item container
$hInfo (ref.hash)
keys
  • Quantity - quantity (optional default=MinOrder)- float
  • CurrencyID - alpha currency code (optional default=Container.CurrencyID) - char(3)
  • TaxModel - gros or net price (optional default=Container.TaxModel) - int
  • IsChanged - quantity was changed by product (optional default=0) - int
  • .... (optional)- ...
Return
$hLineItem (ref.hash)
hash for lineitem insert, keys
  • SKU
  • Name
  • TaxClass
  • Quantity
  • BasePrice
  • Discount
  • LineItemPrice
  • Product
  • TaxRate
  • IsChanged
  • OrderUnit
  • WeightUnit
  • Weight
  • VariationString
  • EcoParticipation

price

Returns the product price by the given requirements. The hook 'ProductPrice' is triggered before the standard price list is used.

Syntax
$Price = $Product->price( $hVars );
Example
$Price = $Product->price( {
    CurrencyID => 'USD',
    TaxModel => $Product->getSite()->get('TaxModel')
} );
Input
$hVars (ref.hash)
  • CurrencyID - alpha currency code (ISO 4217) - char(3)
  • TaxModel - gross or net price - int
  • Container - line item container (optional)- LineItemContainer
  • LineItem - product line item (optional)- LineItemProduct
  • Customer - customer (optional)- Customer
  • User - user (optional)- User
  • IsBundled - is part of a bundle (optional)- Boolean
  • .... (optional)- ...
Return
$Price (money)
price of product

recalculateLineItem

Recalculate a product line item when something has changed on basket, for example if a different tax area was chosen.

Syntax
$Product->recalculateLineItem( $LineItem, $hValues);
Input
$LineItem (object)
line item
$hValues (ref.hash)
possible keys which was changed
  • Quantity - quantity (optional default=MinOrder)- float
  • CurrencyID - alpha currency code (optional default=Container.CurrencyID) - char(3)
  • TaxModel - gros or net price (optional default=Container.TaxModel) - int
  • .... (optional)- ...

renumberBundleProductMaps

Renumbers the bundled products assigned to a product.

Syntax
$Product->renumberBundleProductMaps;

renumberDownloadProductMaps

Renumbers the downloadfiles assigned to a product.

Syntax
$Product->renumberDownloadProductMaps;

requiredChildClass

Returns the name of the class a new child is required to be an instance of or undef if no class is allowed (no children).

Syntax
$RequiredChildClass = $ContentObject->requiredChildClass;
Return
$RequiredChildClass (String)
name of a class, i.e. "Object"

setEcoParticipation

Sets the eco participation of this product. If $Product is a sub product, then the price overrides the price of the super product. In this case, you should also set the attribute HasSubOwnPrices of the sub product to true.

Syntax
$Product->setEcoParticipation($CurrencyID, $TaxModel, $Value);
Example
$Product->setEcoParticipation('EUR', 1, 19.99);
$Product->set({ HasSubOwnPrices => 1 }) if defined $Product->get('SuperProduct');
$Product->setEcoParticipation('EUR', 1, undef);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$Value (float)
price. A value of undef deletes the price.

setListPrice

Sets the list price of this product. If $Product is a sub product, then the price overrides the price of the super product. In this case, you should also set the attribute HasSubOwnPrices of the sub product to true.

Syntax
$Product->setListPrice($CurrencyID, $TaxModel, $Value);
Example
$Product->setListPrice('EUR', 1, 19.99);
$Product->set({ HasSubOwnPrices => 1 }) if defined $Product->get('SuperProduct');
$Product->setListPrice('EUR', 1, undef);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$Value (float)
price. A value of undef deletes the price.

setManufacturerPrice

Sets the manufacturer's suggested retail price (MSRP) of this product. If $Product is a sub product, then the MSRP overrides the MSRP of the super product.

Syntax
$Product->setManufacturerPrice($CurrencyID, $TaxModel, $Value);
Example
$Product->setManufacturerPrice('EUR', 1, 19.99);
$Product->setManufacturerPrice('EUR', 1, undef);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
$Value (float)
price. A value of undef deletes the price.

setPrepayment

Sets the prepayment of this product.

Syntax
$Product->setPrepayment($CurrencyID, $TaxModel, $Value);
Example
$Product->setPrepayment('EUR', 1, 19.99);
$Product->setPrepayment('EUR', 1, undef);
Input
$CurrencyID (string)
currency code
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
(optional, default=Product.Shop.InputTaxModel)
Return
$Value (float)
price. A value of undef deletes the price.

stockAlert

Gets the availability status of the product. Used by the attribute 'StockLevelAlert'. Possible return values are: