InSales API - Товары
Материал из Insales Wiki
Версия от 09:24, 18 июля 2010; Vb (обсуждение | вклад)
Содержание
Получение списка товаров
Возможные параметры запроса:
- category_id - идентификатор категории на складе
- collection_id - идентификатор категории на сайте
Запрос: GET /admin/products.xml?category_id=478
Ответ:
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <products type="array"> <product> <category-id type="integer">478</category-id> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">41658</id> <is-hidden type="boolean">false</is-hidden> <updated-at type="timestamp">2010-07-14 13:40:01 +0400</updated-at> <title>Van Gogh Ruled Peach Notebook</title> <description><p><span style="font-family: 'Times New Roman'; font-size: 16px;"> </span></p></description> <short-description>Алая записная книжка "Ван Гог" в линейку</short-description> <permalink>Van-Gogh-Ruled-Rose-Notebook</permalink> <tag-title nil="true"/> <meta-keywords nil="true"/> <meta-description nil="true"/> <option-names type="array"> <option-name> <id type="integer">1171</id> <position type="integer">1</position> <title>Модификация</title> </option-name> </option-names> <images type="array"> <image> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">24690</id> <position type="integer">1</position> <url>http://static.insales.ru/images/products/24690/thumb/vangogh-red.jpg</url> <title nil="true"/> </image> </images> <variants type="array"> <variant> <cost-price type="decimal">487.0</cost-price> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">48136</id> <old-price type="decimal" nil="true"/> <price type="decimal">740.0</price> <product-id type="integer">41658</product-id> <quantity type="integer" nil="true"/> <sku>QP021MVEN-r</sku> <updated-at type="timestamp">2010-07-16 13:20:04 +0400</updated-at> <title>Базовая</title> <option-values type="array"> <option-value> <id type="integer">5649</id> <option-name-id type="integer">1171</option-name-id> <position type="integer">1</position> <title>Базовая</title> </option-value> </option-values> </variant> </variants> </product> <product> <category-id type="integer">478</category-id> <created-at type="timestamp">2009-04-10 00:00:05 +0400</created-at> <id type="integer">15757</id> <is-hidden type="boolean">false</is-hidden> <updated-at type="timestamp">2009-12-08 14:58:34 +0300</updated-at> <title>Van Gogh Sketchbook Peach</title> <description nil="true" /> <short-description>Персиковая записная книжка "Ван Гог" для рисунков</short-description> <permalink>Van-Gogh-Sketchbook-Peach</permalink> <tag-title nil="true"/> <meta-keywords nil="true"/> <meta-description nil="true"/> <option-names type="array"> <option-name> <id type="integer">1171</id> <position type="integer">1</position> <title>Модификация</title> </option-name> </option-names> <images type="array"> <image> <created-at type="timestamp">2009-04-10 00:00:05 +0400</created-at> <id type="integer">13886</id> <position type="integer">1</position> <url>http://static.insales.ru/images/products/13886/thumb/vangogh-orange.jpg</url> <title nil="true"/> </image> </images> <variants type="array"> <variant> <cost-price type="decimal">487.0</cost-price> <created-at type="timestamp">2009-04-10 00:00:05 +0400</created-at> <id type="integer">16638</id> <old-price type="decimal" nil="true"/> <price type="decimal">740.0</price> <product-id type="integer">15757</product-id> <quantity type="integer">0</quantity> <sku>QP023MVEN-o</sku> <updated-at type="timestamp">2010-07-16 13:20:05 +0400</updated-at> <title>Базовая</title> <option-values type="array"> <option-value> <id type="integer">5649</id> <option-name-id type="integer">1171</option-name-id> <position type="integer">1</position> <title>Базовая</title> </option-value> </option-values> </variant> </variants> </product> </products>
Получение информации о товаре
Запрос: GET /admin/products/#{id}.xml
Ответ:
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <product> <category-id type="integer">478</category-id> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">41658</id> <is-hidden type="boolean">false</is-hidden> <updated-at type="timestamp">2010-07-14 13:40:01 +0400</updated-at> <title>Van Gogh Ruled Peach Notebook</title> <description><p><span style="font-family: 'Times New Roman'; font-size: 16px;"> </span></p></description> <short-description>Алая записная книжка "Ван Гог" в линейку</short-description> <permalink>Van-Gogh-Ruled-Rose-Notebook</permalink> <tag-title nil="true"/> <meta-keywords nil="true"/> <meta-description nil="true"/> <option-names type="array"> <option-name> <id type="integer">1171</id> <position type="integer">1</position> <title>Модификация</title> </option-name> </option-names> <images type="array"> <image> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">24690</id> <position type="integer">1</position> <url>http://static.insales.ru/images/products/24690/thumb/vangogh-red.jpg</url> <title nil="true"/> </image> </images> <variants type="array"> <variant> <cost-price type="decimal">487.0</cost-price> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">48136</id> <old-price type="decimal" nil="true"/> <price type="decimal">740.0</price> <product-id type="integer">41658</product-id> <quantity type="integer" nil="true"/> <sku>QP021MVEN-r</sku> <updated-at type="timestamp">2010-07-16 13:20:04 +0400</updated-at> <title>Базовая</title> <option-values type="array"> <option-value> <id type="integer">5649</id> <option-name-id type="integer">1171</option-name-id> <position type="integer">1</position> <title>Базовая</title> </option-value> </option-values> </variant> </variants> </product>
Добавление товара
Добавление товара с умолчательными свойствами
Запрос: POST /admin/products.xml
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <product> <category-id type="integer">478</category-id> <title>Van Gogh Ruled Peach Notebook</title> <description><p><span style="font-family: 'Times New Roman'; font-size: 16px;"> </span></p></description> <short-description>Алая записная книжка "Ван Гог" в линейку</short-description> <variants type="array"> <variant> <sku>QP021MVEN-r</sku> <quantity type="integer" nil="true"/> <price type="decimal">740.0</price> <cost-price type="decimal">487.0</cost-price> <old-price type="decimal" nil="true"/> </variant> </variants> </product>
Ответ:
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <product> <category-id type="integer">478</category-id> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">41658</id> <is-hidden type="boolean">false</is-hidden> <updated-at type="timestamp">2010-07-14 13:40:01 +0400</updated-at> <title>Van Gogh Ruled Peach Notebook</title> <description><p><span style="font-family: 'Times New Roman'; font-size: 16px;"> </span></p></description> <short-description>Алая записная книжка "Ван Гог" в линейку</short-description> <permalink>Van-Gogh-Ruled-Rose-Notebook</permalink> <tag-title nil="true"/> <meta-keywords nil="true"/> <meta-description nil="true"/> <option-names type="array"> <option-name> <id type="integer">1171</id> <position type="integer">1</position> <title>Модификация</title> </option-name> </option-names> <images type="array" /> <variants type="array"> <variant> <cost-price type="decimal">487.0</cost-price> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">48136</id> <old-price type="decimal" nil="true"/> <price type="decimal">740.0</price> <product-id type="integer">41658</product-id> <quantity type="integer" nil="true"/> <sku>QP021MVEN-r</sku> <updated-at type="timestamp">2010-07-16 13:20:04 +0400</updated-at> <title>Базовая</title> <option-values type="array"> <option-value> <id type="integer">5649</id> <option-name-id type="integer">1171</option-name-id> <position type="integer">1</position> <title>Базовая</title> </option-value> </option-values> </variant> </variants> </product>
Добавление товара с нестандартными свойствами
Запрос: POST /admin/products.xml
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <product> <category-id type="integer">478</category-id> <is-hidden type="boolean">false</is-hidden> <title>Модная майка</title> <options type="array"> <option-name> <title>Размер</title> <value> </option-name> </option-names> <images type="array"> <image> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">24690</id> <position type="integer">1</position> <url>http://static.insales.ru/images/products/24690/thumb/vangogh-red.jpg</url> <title nil="true"/> </image> </images> <variants type="array"> <variant> <cost-price type="decimal">487.0</cost-price> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">48136</id> <old-price type="decimal" nil="true"/> <price type="decimal">740.0</price> <product-id type="integer">41658</product-id> <quantity type="integer" nil="true"/> <sku>QP021MVEN-r</sku> <updated-at type="timestamp">2010-07-16 13:20:04 +0400</updated-at> <title>Базовая</title> <option-values type="array"> <option-value> <id type="integer">5649</id> <option-name-id type="integer">1171</option-name-id> <title>Базовая</title> </option-value> </option-values> </variant> </variants> </product>
Ответ:
HTTP/1.1 200 OK <?xml version="1.0" encoding="UTF-8"?> <product> <category-id type="integer">478</category-id> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">41658</id> <is-hidden type="boolean">false</is-hidden> <updated-at type="timestamp">2010-07-14 13:40:01 +0400</updated-at> <title>Van Gogh Ruled Peach Notebook</title> <description><p><span style="font-family: 'Times New Roman'; font-size: 16px;"> </span></p></description> <short-description>Алая записная книжка "Ван Гог" в линейку</short-description> <permalink>Van-Gogh-Ruled-Rose-Notebook</permalink> <tag-title nil="true"/> <meta-keywords nil="true"/> <meta-description nil="true"/> <option-names type="array"> <option-name> <id type="integer">1171</id> <position type="integer">1</position> <title>Модификация</title> </option-name> </option-names> <images type="array"> <image> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">24690</id> <position type="integer">1</position> <url>http://static.insales.ru/images/products/24690/thumb/vangogh-red.jpg</url> <title nil="true"/> </image> </images> <variants type="array"> <variant> <cost-price type="decimal">487.0</cost-price> <created-at type="timestamp">2009-06-04 14:22:34 +0400</created-at> <id type="integer">48136</id> <old-price type="decimal" nil="true"/> <price type="decimal">740.0</price> <product-id type="integer">41658</product-id> <quantity type="integer" nil="true"/> <sku>QP021MVEN-r</sku> <updated-at type="timestamp">2010-07-16 13:20:04 +0400</updated-at> <title>Базовая</title> <option-values type="array"> <option-value> <id type="integer">5649</id> <option-name-id type="integer">1171</option-name-id> <position type="integer">1</position> <title>Базовая</title> </option-value> </option-values> </variant> </variants> </product>