NAME
Mango::Product - Module representing a product
SYNOPSIS
my $product = $provider->get_by_sku('ABC-123');
print $product->created;
my $attributes = $product->attributes;
while (my $attribute = $attributes->next) {
print $attribute->name, ': ', $attribute->value;
};
DESCRIPTION
Mango::Product represents a product to be sold.
METHODS
add_attribute
Same as "add_attributes".
add_attributes
Adds an attribute to the current product. atttributes
may be hashes containing name/value data, or Mango::Attribute objects;
$product->add_attributes(
{name => 'Color', value => 'red'},
$attributeobject
);
add_tag
Same as "add_tag".
add_tags
Adds tags to the current product. tags
may be tag strings, or Mango::Tag objects:
$product->add_tags(
'computers',
$tagobject
);
attributes
Returns a list of attributes for the current product in list context, or a Mango::Iterator in scalar context.
my @attributes = $product->attributes({
name => 'A%'
});
my $iterator = $product->attributes({
name => 'A%'
});
created
Returns the date and time in UTC the product was created as a DateTime object.
print $profile->created;
delete_attribute
Sames as "delete_attributes".
delete_attributes
Deletes attributes from the current product matching the supplied filter..
$product->delete_attributes({
name => 'Color'
});
delete_tag
Sames as "delete_tags".
delete_tags
Deletes tags from the current product matching the supplied filter..
$product->delete_tags({
'computer'
});
description
Gets/sets the description of the current product.
print $product->description;
destroy
Deletes the current profile.
id
Returns the id of the current product.
print $product->id;
name
Gets/sets the name of the current product.
print $product->name;
price
Gets/sets the price of the current product. The price is returned as a Mango::Currency object.
print $product->price;
sku
Gets/sets the sku/part number of the current product.
print $product->sku;
tags
Returns a list of tags for the current product in list context, or a Mango::Iterator in scalar context.
my @tags = $product->tags({
name => 'A%'
});
my $iterator = $product->tags({
name => 'A%'
});
update
Saves any changes made to the product back to the provider.
$product->password('Red');
$product->update;
Whenever "update" is called, "updated" is automatically set to the current time in UTC.
updated
Returns the date and time in UTC the product was last updated as a DateTime object.
print $product->updated;
SEE ALSO
Mango::Object, Mango::Provider::Profiles
AUTHOR
Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/