Skip to main content

Widgets

Widgets are dynamic UI components based on schemas, encompassing elements like sliders and banners that are deployable within the storefront. These elements can also store information regarding product collections and can be used for displaying products on the storefront. Widgets are formally defined within Omnitron and can be retrieved by querying them using their unique widget slug identifier.

Model

Widget

fieldtypedescription
nameCharFieldThe name of the widget.
slugSlugFieldA unique slug for identifying the widget.
templateSlugFieldThe template used for rendering the widget.
widget_typeWidgetTypeThe widget type that holds the widget's schema.
created_dateDateTimeFieldThe date when the widget was created.
modified_dateDateTimeFieldThe date when the widget was last modified.
attributesJSONFieldAttributes of the widget.
attributes_kwargsJSONFieldInformation about the widget's attributes.
content_typeContentTypeThe content type of the widget.
localized_attributesJSONFieldLocalized attributes specific to the widget.
localized_attributes_kwargsJSONFieldInformation about localized attributes.

ProductCollectionWidget

fieldtypedescription
nameCharFieldThe name of the widget.
slugSlugFieldA unique slug for identifying the widget.
templateSlugFieldThe template used for rendering the widget.
product_collectionProductCollectionThe product collection linked to the widget.
product_limitPositiveIntegerFieldThe maximum number of products to display in the widget.
widget_typeWidgetTypeThe widget type that holds the widget's schema.
created_dateDateTimeFieldThe date when the widget was created.
modified_dateDateTimeFieldThe date when the widget was last modified.
attributesJSONFieldAttributes of the widget.
attributes_kwargsJSONFieldInformation about the widget's attributes.
content_typeContentTypeThe content type of the widget.
localized_attributesJSONFieldLocalized attributes specific to the widget.
localized_attributes_kwargsJSONFieldInformation about localized attributes.

Endpoints

GET Retrieve a Widget Info

This method is used to get widget information that have been defined in Omnitron.

Path: https://{storefront_url}/widgets/<widget-slug>/

Example Response

Here's an example response of a product collection widget:

{
"name": "Campaign",
"slug": "x-campaign",
"attributes": {
"abc": "xyz"
},
"template": "widgets/campaign.html",
"products": [
{
"pk": 10,
"sku": "12612662136",
...
},
{
"pk": 11,
"sku": "12612662137",
...
},
....
]
}

Here's an example response of a simple widget:

{
"attributes": {
"sliders": [
{
"value": {
"name": "Kampanya",
"slug": "kampanya"
},
"kwargs": null
},
{
"value": {
"name": "\u0130ndirim",
"slug": "indirim"
},
"kwargs": null
}
],
"slider_items": [
{
"value": {
"url": "#",
"slider_slug": "kampanya",
"alt": "resim",
"image": "assets/img/slider.jpg",
"title": "baslik"
},
"kwargs": null
},
{
"value": {
"url": "#",
"slider_slug": "indirim",
"alt": "resim",
"image": "assets/img/slider2.jpg",
"title": "baslik"
},
"kwargs": null
},
{
"value": {
"url": "#",
"slider_slug": "kampanya",
"alt": "resim",
"image": "assets/img/slider2.jpg",
"title": "baslik"
},
"kwargs": null
},
{
"value": {
"url": "#",
"slider_slug": "indirim",
"alt": "resim",
"image": "assets/img/slider.jpg",
"title": "baslik"
},
"kwargs": null
}
]
},
"name": "Slider",
"template": "index/slider.html",
"slug": "slider"
}