Closed gplsek closed 10 years ago
Created couple sample functions in the fitmoo_product module sites/all/modules/custom/fitmoo_product/fitmoo_product.module
you can see what the product and product_item obeject looks like by trying something like for event product: http://fitmoo.plsekwerks.com/fitmoo/product_node/2 then its product_item: http://fitmoo.plsekwerks.com/fitmoo/product/3 you can see the product here: http://fitmoo.plsekwerks.com/node/2
For more complicated products: Product that is a collection of items you can see http://fitmoo.plsekwerks.com/fitmoo/product_node/3 you can now see that it has multiple product_item references
the product is here: http://fitmoo.plsekwerks.com/node/3 if you change the Size in the drop down it loads different product_item there you can tell for example by selecting S vs XL the price changes as well.
you can see the product_item object here: http://fitmoo.plsekwerks.com/fitmoo/product/4 http://fitmoo.plsekwerks.com/fitmoo/product/5 and so on
there are functions in there that will help you create the products via the api.
We will need to set up the API to accept the json soehting like this:
product
POST http://fitmoostore.loc/tapi/user/logout X-CSRF-Token: g23gMtjDtBzptg4YNXFmnYL8u8Ada425a44141 -- response -- <?xml version="1.0" encoding="utf-8"?>
POST http://fitmoostore.loc/tapi/user/login Content-Type: application/x-www-form-urlencoded username=test1&password=test1 -- response -- Set-Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=fMSznhcIJcpEslyhDxDuoxmwegqbBaerecjyIUbhhT4; expires=Thu, 13-Mar-2014 19:38:06 GMT; path=/; domain=.fitmoostore.loc; HttpOnly <?xml version="1.0" encoding="utf-8"?>
GET http://fitmoostore.loc/services/session/token Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=fMSznhcIJcpEslyhDxDuoxmwegqbBaerecjyIUbhhT4 -- response --
GET http://fitmoostore.loc/tapi/user/13 Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=fMSznhcIJcpEslyhDxDuoxmwegqbBaerecjyIUbhhT4 X-CSRF-Token: oUI5DA7jYSUSCWFvRID85Gp0k0Jk9BHFlxCC0fpH_HI -- response -- <?xml version="1.0" encoding="utf-8"?>
POST http://fitmoostore.loc/tapi/cart X-CSRF-Token: oUI5DA7jYSUSCWFvRID85Gp0k0Jk9BHFlxCC0fpH_HI Cookie: SESSb22f1e1c07a26da425a441410bf4eb41=fMSznhcIJcpEslyhDxDuoxmwegqbBaerecjyIUbhhT4 Content-Type: application/x-www-form-urlencoded -- response -- <?xml version="1.0" encoding="utf-8"?>
All done and works :)
2014-02-18 7:38 GMT+03:00 George Plsek notifications@github.com:
Created couple sample functions in the fitmoo_product module sites/all/modules/custom/fitmoo_product/fitmoo_product.module
you can see what the product and product_item obeject looks like by trying something like for event product: http://fitmoo.plsekwerks.com/fitmoo/product_node/2 then its product_item: http://fitmoo.plsekwerks.com/fitmoo/product/3 you can see the product here: http://fitmoo.plsekwerks.com/node/2
For more complicated products: Product that is a collection of items you can see http://fitmoo.plsekwerks.com/fitmoo/product_node/3 you can now see that it has multiple product_item references
the product is here: http://fitmoo.plsekwerks.com/node/3 if you change the Size in the drop down it loads different product_item there you can tell for example by selecting S vs XL the price changes as well.
you can see the product_item object here: http://fitmoo.plsekwerks.com/fitmoo/product/4 http://fitmoo.plsekwerks.com/fitmoo/product/5 and so on
there are functions in there that will help you create the products via the api.
We will need to set up the API to accept the json soehting like this:
product
- product description
- some field
- product items
- product item
- title
- price
- quantity/stock
- variation 1 (can be size)
- variation 2 ....
Reply to this email directly or view it on GitHubhttps://github.com/gplsek/fitmoostore/issues/2#issuecomment-35352014 .
Now I upload, configurate and making API-calls manual.
2014-02-20 16:35 GMT+03:00 Max Klimchuk sabre@tut.by:
All done and works :)
2014-02-18 7:38 GMT+03:00 George Plsek notifications@github.com:
Created couple sample functions in the fitmoo_product module
sites/all/modules/custom/fitmoo_product/fitmoo_product.module
you can see what the product and product_item obeject looks like by trying something like for event product: http://fitmoo.plsekwerks.com/fitmoo/product_node/2 then its product_item: http://fitmoo.plsekwerks.com/fitmoo/product/3 you can see the product here: http://fitmoo.plsekwerks.com/node/2
For more complicated products: Product that is a collection of items you can see http://fitmoo.plsekwerks.com/fitmoo/product_node/3 you can now see that it has multiple product_item references
the product is here: http://fitmoo.plsekwerks.com/node/3 if you change the Size in the drop down it loads different product_item there you can tell for example by selecting S vs XL the price changes as well.
you can see the product_item object here: http://fitmoo.plsekwerks.com/fitmoo/product/4 http://fitmoo.plsekwerks.com/fitmoo/product/5 and so on
there are functions in there that will help you create the products via the api.
We will need to set up the API to accept the json soehting like this:
product
- product description
- some field
- product items
- product item
- title
- price
- quantity/stock
- variation 1 (can be size)
- variation 2 ....
Reply to this email directly or view it on GitHubhttps://github.com/gplsek/fitmoostore/issues/2#issuecomment-35352014 .
Create product via API:
Receive json object from API call fitmoo->drupal
Product = Product Display (regular drupal node) Product Item (commerce product entity)
Product Display:
SudoCode
Create Node Object $node->type = 'tops' (shirts, jackets, and etc) $node->uid = logged in user UID
then add other fields
then add product items.
create product object via commerce: $product_type = 'shirt'; $product = commerce_product_new($product_type); $product->status = status; $product->uid = 'uid'; $productt->sku = 'sku'; $product->title = 'title'; $product->created = time(); $product->size = ...
then product save via commerce hook
get the ID, create the other 4 variations
then save ids on:
$node->product_items['und'] = IDs array.
then node_save($node)
let me know if this makes sense.
I will add some sample links.