|
来源:http://trac.seagullproject.org/wiki/Modules/Ecomm/Api 产品产品灵气可以使用任何后台保存,目前支持CMS和最简单的product表。
// $config set for CMS product
$myProduct = ECM_Product::getByType('t-shirt')
->title = 'Foo Shirt'
->description = 'this is my tshirt'
->save();
编辑T恤产品实例:
// $config set for Simple product
$myProduct = ECM_Product::getByProductId($productId)
->title = 'Foo Shirt'
->description = 'this is my tshirt'
->save();
删除产品$myProduct = ECM_Product::getById(23) ->remove(); Product with variationscreating just new variations
// $config set for CMS product
$myProduct = ECM_Product::getByType('t-shirt')
->addVariation('colour', array('red', 'blue'))
->title = 'my tshirt'
->description = 'here is desc'
->save();
创建一个 t-shirt产品实例:
// $config set for CMS product
$myProduct = ECM_Product::getById($id)
->addVariation('size', array('L', 'XL'))
->save();
购买产品
// gets product from inventory with variation combinations
$myProduct = ECM_Product::getByInventoryId($inventoryId)
->retrieve();
产品目录产品目录可以使用任何后台保存,目前支持CMS数据或product表中的记录。 取得某个类别的产品
$aCatalog = SGL_Finder::factory('Product')
->addFilter('typeName', 't-shirt');
->retrieve();
// returns an array of objects of type ECM_Prodcut
从product表返回一个只读产品列表,获取一个特定类型的产品
$aCatalog = SGL_Finder::factory('Product')
->addFilter('typeName', 't-shirt');
->retrieve();
// returns an array of objects of type ECM_Prodcut
购物车购物车数据可以保存到任何后台,目前支持的只有cart表。 取得购物车的所有商品
$aProducts = SGL_Cart::getById($userId)
->retrieve();
从购物车删除商品
$ok = SGL_Cart::getById($userId)
->removeProduct($inventoryId)
->save();
向购物车添加商品
$ok = SGL_Cart::getById($userId)
->add($inventoryId, $productId)
->setQuantity(3)
->save();
编辑购物车中商品的数量:
$ok = SGL_Cart::getById($userId)
->getProduct($inventoryId)
->setQuantity(4)
->save();
数据访问取得某个商店的货物清单 $oInventory = $da->getInventoryByProductId($id); 添加商品到货物清单 $ok = $da->addInventoryByProductId($id); 更新货物清单 $ok = $da->updateInventoryById($id); adding variation names API $myProduct = ECM_Product::getByType('t-shirt')
->addVariation('size')
->save();
DA $da->addVariationByProductId($productId, $name, $value = array()); |