Store items

Retrieving store item objects

A store item can be retrieved from a store object. Use the get_items() function of the BlueConic store object.

Using store item objects

class StoreItem
add_value(prop_id, value)

Add a single value to a property, or create it if it doesn’t exist.

Parameters:
  • prop_id (str) – The property ID to add the value to.

  • value (PropertyValue) – The value to add to the property.

Raises:

ValueError – If attempting to set a fixed property.

Usage:
>>> item = StoreItem(store_id="item1", name="Sample")
>>> item.add_value("category", "Books")
>>> print(item.get_values("category"))
['Books']
add_values(prop_id, values)

Add multiple values to a property, or create it if it doesn’t exist.

Parameters:
  • prop_id (str) – The property ID to add the values to.

  • values (Sequence[PropertyValue]) – The values to add to the property.

Raises:

ValueError – If attempting to set a fixed property.

Usage:
>>> item = StoreItem(store_id="item1", name="Sample")
>>> item.add_values("category", ["Books", "Fiction"])
>>> print(item.get_values("category"))
['Books', 'Fiction']
get_value(prop_name)

Retrieve the first value of a property by its name.

Parameters:

prop_name (str) – The name of the property to retrieve.

Returns:

The value of the property, or None if not found.

Return type:

Optional[PropertyValue]

Usage:
>>> item = StoreItem(store_id="item1", name="Sample")
>>> item.add_value("text", "Just a sample text")
>>> print(item.get_value("text"))
Just a sample text
get_values(prop_name)

Retrieve all values of a property by its name.

Parameters:

prop_name (str) – The name of the property to retrieve.

Returns:

The values of the property as a sequence, or empty sequence if not found.

Return type:

Sequence[PropertyValue]

Usage:
>>> item = StoreItem(store_id="item1", name="Sample")
>>> item.add_value("text", "Just a sample text")
>>> print(item.get_values("text"))
['Just a sample text']
set_value(prop_id, value, set_if_empty=False)

Set a single value for a property, replacing any existing values.

set_values(prop_id, values, set_if_empty=False)

Set multiple values for a property, replacing any existing values.

to_dict()

Converts the StoreItem object to a dictionary suitable for JSON serialization.

property creation_date

Returns the store item creation date

property description

Returns the store item description

property hash

Returns the store item hash

property id

Returns the store item id

property image

Returns the store item image

property image_url

Returns the store item image url

property in_stock

Returns the store item in stock

property int_value

Returns the store item int_value

property last_modified_date

Returns the store item last modified date

property name

Returns the store item name

property properties

Returns the properties of this object alongside the fixed attributes.

property property_ids

Returns the property IDs of this object.

property publication_date

Returns the store item publication date

property statistics

Returns the store item statistics

property text

Returns the store item text

property url

Returns the store item url