The category
module
- class magento.models.category.Category(data, client)[source]View on GitHub
Bases:
Model
Wrapper for the
categories
endpoint- DOCUMENTATION: str = 'https://adobe-commerce.redoc.ly/2.3.7-admin/tag/categories'
Link to the Official Magento 2 API documentation for the endpoint wrapped by the Model
- __init__(data, client)[source]View on GitHub
Initialize a Category object using an API response from the
categories
endpoint- Parameters
data (dict) – raw API response
- property excluded_keys
API response keys that shouldn’t be set as object attributes by
set_attrs()
- Returns
list of API response keys that shouldn’t be set as attributes
- property subcategories: List[Category]
The child categories, returned as a list of
Category
objectsNote
Only the direct child categories are returned. For a list of all descendants, use
all_subcategories
- property subcategory_ids: List[int]
The
category_ids
of thesubcategories
- property subcategory_names: List[str]
The names of the category’s
subcategories
- property all_subcategories: Optional[List[Category]]
Recursively retrieves all descendants of the category
- property all_subcategory_ids: List[int]
The
category_ids
ofall_subcategories
- property products: List[Product]
The
Product
s in the categoryAlias for
get_products()
- property all_products: List[Product]
The
Product
s in the category and inall_subcategories
Alias for
get_products()
withsearch_subcategories=True
- property all_product_ids: Set[int]
The
product_ids
of the products in the category and inall_subcategories
- property all_skus: Set[str]
The skus of the products in the category and in
all_subcategories
- get_products(search_subcategories=False)[source]View on GitHub
Retrieves the category’s products
- Parameters
search_subcategories (bool) – if
True
, also retrieves products fromall_subcategories
- Return type
- get_orders(search_subcategories=False)[source]View on GitHub
Retrieve any
Order
that contains one of the category’sproducts
- Parameters
search_subcategories (bool) – if
True
, also searches for orders fromall_subcategories
- Return type
- get_order_items(search_subcategories=False)[source]View on GitHub
Retrieve any
OrderItem
that contains one of the category’sproducts
- Parameters
search_subcategories (bool) – if
True
, also searches for order items fromall_subcategories
- Return type
- get_invoices(search_subcategories=False)[source]View on GitHub
Retrieve any
Invoice
that contains one of the category’sproducts
- Parameters
search_subcategories (bool) – if
True
, also searches for invoices fromall_subcategories
- Return type