The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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

Arguments: @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

Arguments: @tags

Adds tags to the current product. tags may be tag strings, or Mango::Tag objects:

    $product->add_tags(
        'computers',
        $tagobject
    );

attributes

Arguments: $filter, $options

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

Arguments: $filter

Deletes attributes from the current product matching the supplied filter..

    $product->delete_attributes({
        name => 'Color'
    });

delete_tag

Sames as "delete_tags".

delete_tags

Arguments: $filter

Deletes tags from the current product matching the supplied filter..

    $product->delete_tags({
        'computer'
    });

description

Arguments: $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

Arguments: $name

Gets/sets the name of the current product.

    print $product->name;

price

Arguments: $price

Gets/sets the price of the current product. The price is returned as a Mango::Currency object.

    print $product->price;

sku

Arguments: $sku

Gets/sets the sku/part number of the current product.

    print $product->sku;

tags

Arguments: $filter, $options

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/