Sample API
Sample API
This file documents the Magento Core API for Magento Community Edition 1.6.1.
Resource: core_store
Method: list
$client->call($sessionId, 'core_store.list');
Implemented In
Mage_Core_Model_Store_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Core/Model/Store/Api.php
Doc Comment
/** * Retrieve stores list * * @return array */
Method: info
$client->call($sessionId, 'core_store.info', $storeId);
Implemented In
Mage_Core_Model_Store_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Core/Model/Store/Api.php
Doc Comment
/** * Retrieve store data * * @param string|int $storeId * @return array */
try { $store = Mage::app()->getStore($storeId); } catch (Mage_Core_Model_Store_Exception $e) { $this->_fault('store_not_exists'); } if (!$store->getId()) { $this->_fault('store_not_exists'); } // Basic store data $result = array(); $result['store_id'] = $store->getId(); $result['code'] = $store->getCode(); $result['website_id'] = $store->getWebsiteId(); $result['group_id'] = $store->getGroupId(); $result['name'] = $store->getName(); $result['sort_order'] = $store->getSortOrder(); $result['is_active'] = $store->getIsActive(); return $result; }
Resource: directory_country
Method: list
$client->call($sessionId, 'directory_country.list');
Implemented In
Mage_Directory_Model_Country_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Directory/Model/Country/Api.php
Doc Comment
/** * Retrieve countries list * * @return array */
Resource: directory_region
Method: list
$client->call($sessionId, 'directory_region.list', $country);
Implemented In
Mage_Directory_Model_Region_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Directory/Model/Region/Api.php
Doc Comment
/** * Retrieve regions list * * @param string $country * @return array */
Resource: customer
Method: list
$client->call($sessionId, 'customer.list', $filters);
Implemented In
Mage_Customer_Model_Customer_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Customer/Api.php
Doc Comment
/** * Retrieve cutomers data * * @param array $filters * @return array */
$field = $this->_mapAttributes[$field]; } $collection->addFieldToFilter($field, $value); } } catch (Mage_Core_Exception $e) { $this->_fault('filters_invalid', $e->getMessage()); } } $result = array(); foreach ($collection as $customer) { $data = $customer->toArray(); $row = array();
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { $row[$attributeAlias] = (isset($data[$attributeCode]) ? $data[$attributeCode] : null); } foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) { if (isset($data[$attributeCode])) { $row[$attributeCode] = $data[$attributeCode]; } } $result[] = $row; } return $result; }
Method: create
$client->call($sessionId, 'customer.create', $customerData);
Implemented In
Mage_Customer_Model_Customer_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Customer/Api.php
Doc Comment
/** * Create new customer * * @param array $customerData * @return int */
Method: info
$client->call($sessionId, 'customer.info', $customerId, $attributes);
Implemented In
Mage_Customer_Model_Customer_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Customer/Api.php
Doc Comment
/** * Retrieve customer data * * @param int $customerId * @param array $attributes * @return array */
Method: update
$client->call($sessionId, 'customer.update', $customerId, $customerData);
Implemented In
Mage_Customer_Model_Customer_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Customer/Api.php
Doc Comment
/** * Update customer data * * @param int $customerId * @param array $customerData * @return boolean */
$customer = Mage::getModel('customer/customer')->load($customerId); if (!$customer->getId()) { $this->_fault('not_exists'); } foreach ($this->getAllowedAttributes($customer) as $attributeCode=>$attribute) { if (isset($customerData[$attributeCode])) { $customer->setData($attributeCode, $customerData[$attributeCode]); } } $customer->save(); return true; }
Method: delete
$client->call($sessionId, 'customer.delete', $customerId);
Implemented In
Mage_Customer_Model_Customer_Api::delete /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Customer/Api.php
Doc Comment
/** * Delete customer * * @param int $customerId * @return boolean */
Resource: customer_group
Method: list
$client->call($sessionId, 'customer_group.list');
Implemented In
Mage_Customer_Model_Group_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Group/Api.php
Doc Comment
Resource: customer_address
Method: list
$client->call($sessionId, 'customer_address.list', $customerId);
Implemented In
Mage_Customer_Model_Address_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Address/Api.php
Doc Comment
/** * Retrive customer addresses list * * @param int $customerId * @return array */
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null; } foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { if (isset($data[$attributeCode])) { $row[$attributeCode] = $data[$attributeCode]; }
} $row['is_default_billing'] = $customer->getDefaultBilling() == $address->getId(); $row['is_default_shipping'] = $customer->getDefaultShipping() == $address->getId(); $result[] = $row; } return $result; }
Method: create
$client->call($sessionId, 'customer_address.create', $customerId, $addressData);
Implemented In
Mage_Customer_Model_Address_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Address/Api.php
Doc Comment
/** * Create new address for customer * * @param int $customerId * @param array $addressData * @return int */
Method: info
$client->call($sessionId, 'customer_address.info', $addressId);
Implemented In
Mage_Customer_Model_Address_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Address/Api.php
Doc Comment
/** * Retrieve address data * * @param int $addressId * @return array */
if ($customer = $address->getCustomer()) { $result['is_default_billing'] = $customer->getDefaultBilling() == $address->getId(); $result['is_default_shipping'] = $customer->getDefaultShipping() == $address->getId(); } return $result; }
Method: update
$client->call($sessionId, 'customer_address.update', $addressId, $addressData);
Implemented In
Mage_Customer_Model_Address_Api::update
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Address/Api.php
Doc Comment
/** * Update address data * * @param int $addressId * @param array $addressData * @return boolean */
Method: delete
$client->call($sessionId, 'customer_address.delete', $addressId);
Implemented In
Mage_Customer_Model_Address_Api::delete /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Customer/Model/Address/Api.php
Doc Comment
/** * Delete address * * @param int $addressId
* @return boolean */
Resource: catalog_category
Method: currentStore
$client->call($sessionId, 'catalog_category.currentStore', $store);
Implemented In
Mage_Catalog_Model_Category_Api::currentStore /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Api/Resource.php
Doc Comment
/** * Set current store for catalog. * * @param string|int $store * @return int */
Method: tree
$client->call($sessionId, 'catalog_category.tree', $parentId, $store);
Implemented In
Mage_Catalog_Model_Category_Api::tree
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Retrieve category tree * * @param int $parent * @param string|int $store * @return array */
Method: level
$client->call($sessionId, 'catalog_category.level', $website, $store, $categoryId);
Implemented In
Mage_Catalog_Model_Category_Api::level /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Retrieve level of categories for category/store view/website * * @param string|int|null $website * @param string|int|null $store * @param int|null $categoryId * @return array */
// load root categories of website if (null !== $website) { try { $website = Mage::app()->getWebsite($website); if (null === $store) { if (null === $categoryId) { foreach ($website->getStores() as $store) { /* @var $store Mage_Core_Model_Store */ $ids[] = $store->getRootCategoryId(); } } else { $ids = $categoryId; } } elseif (in_array($store, $website->getStoreIds())) { $storeId = Mage::app()->getStore($store)->getId(); $ids = (null === $categoryId)? $store->getRootCategoryId() : $categoryId; } else { $this->_fault('store_not_exists'); } } catch (Mage_Core_Exception $e) { $this->_fault('website_not_exists', $e->getMessage()); } } elseif (null !== $store) { // load children of root category of store if (null === $categoryId) { try { $store = Mage::app()->getStore($store); $storeId = $store->getId(); $ids = $store->getRootCategoryId(); } catch (Mage_Core_Model_Store_Exception $e) { $this->_fault('store_not_exists'); } } // load children of specified category id else { $storeId = $this->_getStoreId($store); $ids = (int)$categoryId; } } // load all root categories else { $ids = (null === $categoryId)? Mage_Catalog_Model_Category::TREE_ROOT_ID : $categoryId; } $collection = Mage::getModel('catalog/category')->getCollection() ->setStoreId($storeId) ->addAttributeToSelect('name') ->addAttributeToSelect('is_active'); if (is_array($ids)) { $collection->addFieldToFilter('entity_id', array('in' => $ids)); } else { $collection->addFieldToFilter('parent_id', $ids); } // Only basic category data $result = array(); foreach ($collection as $category) { /* @var $category Mage_Catalog_Model_Category */
$result[] = array( 'category_id' => $category->getId(), 'parent_id' 'name' 'is_active' 'position' 'level' ); } return $result; } => $category->getParentId(), => $category->getName(), => $category->getIsActive(), => $category->getPosition(), => $category->getLevel()
Method: info
$client->call($sessionId, 'catalog_category.info', $categoryId, $store, $attributes);
Implemented In
Mage_Catalog_Model_Category_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Retrieve category data * * @param int $categoryId * @param string|int $store * @param array $attributes * @return array */
foreach ($category->getAttributes() as $attribute) { if ($this->_isAllowedAttribute($attribute, $attributes)) { $result[$attribute->getAttributeCode()] = $category->getData($attribute->getAttributeCode()); } } $result['parent_id'] $result['children'] = $category->getParentId(); = $category->getChildren(); = $category->getAllChildren();
Method: create
$client->call($sessionId, 'catalog_category.create', $parentId, $categoryData, $store);
Implemented In
Mage_Catalog_Model_Category_Api::create
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Create new category * * @param int $parentId * @param array $categoryData * @param int|null|string $store * @return int */
} } } $category->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } catch (Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return $category->getId(); }
Method: update
$client->call($sessionId, 'catalog_category.update', $categoryId, $categoryData, $store);
Implemented In
Mage_Catalog_Model_Category_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Update category data * * @param int $categoryId * @param array $categoryData * @param string|int $store * @return boolean */
Method: move
$client->call($sessionId, 'catalog_category.move', $categoryId, $parentId, $afterId);
Implemented In
Mage_Catalog_Model_Category_Api::move /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Move category in tree * * @param int $categoryId * @param int $parentId * @param int $afterId * @return boolean */
Method: delete
$client->call($sessionId, 'catalog_category.delete', $categoryId);
Implemented In
Mage_Catalog_Model_Category_Api::delete /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
Method: assignedProducts
$client->call($sessionId, 'catalog_category.assignedProducts', $categoryId, $store);
Implemented In
Mage_Catalog_Model_Category_Api::assignedProducts /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Retrieve list of assigned products to category * * @param int $categoryId * @param string|int $store * @return array */
Method: assignProduct
$client->call($sessionId, 'catalog_category.assignProduct', $categoryId, $productId, $position, $identifierType);
Implemented In
Mage_Catalog_Model_Category_Api::assignProduct /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Assign product to category * * @param int $categoryId * @param int $productId * @param int $position * @return boolean */
Method: updateProduct
$client->call($sessionId, 'catalog_category.updateProduct', $categoryId, $productId, $position, $identifierType);
Implemented In
Mage_Catalog_Model_Category_Api::updateProduct /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Update product assignment * * @param int $categoryId * @param int $productId * @param int $position * @return boolean */
$this->_fault('product_not_assigned'); } $positions[$productId] = $position; $category->setPostedProducts($positions); try { $category->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; }
Method: removeProduct
$client->call($sessionId, 'catalog_category.removeProduct', $categoryId, $productId, $identifierType);
Implemented In
Mage_Catalog_Model_Category_Api::removeProduct /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Api.php
Doc Comment
/** * Remove product assignment from category * * @param int $categoryId * @param int $productId * @return boolean */
Resource: catalog_category_attribute
Method: currentStore
$client->call($sessionId, 'catalog_category_attribute.currentStore', $store);
Implemented In
Mage_Catalog_Model_Category_Attribute_Api::currentStore
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Api/Resource.php
Doc Comment
/** * Set current store for catalog. * * @param string|int $store * @return int */
Method: list
$client->call($sessionId, 'catalog_category_attribute.list');
Implemented In
Mage_Catalog_Model_Category_Attribute_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Attribute/Api.php
Doc Comment
/** * Retrieve category attributes * * @return array */
=> $scope
Method: options
$client->call($sessionId, 'catalog_category_attribute.options', $attributeId, $store);
Implemented In
Mage_Catalog_Model_Category_Attribute_Api::options /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Category/Attribute/Api.php
Doc Comment
/** * Retrieve category attribute options * * @param int|string $attributeId * @param string|int $store * @return array */
Resource: catalog_product
Method: currentStore
$client->call($sessionId, 'catalog_product.currentStore', $store);
Implemented In
Mage_Catalog_Model_Product_Api::currentStore /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Api/Resource.php
Doc Comment
/** * Set current store for catalog. * * @param string|int $store * @return int */
Method: list
$client->call($sessionId, 'catalog_product.list', $filters, $store);
Implemented In
Mage_Catalog_Model_Product_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Retrieve list of products with basic info (id, sku, type, set, name) * * @param array $filters * @param string|int $store * @return array */
} $result = array(); foreach ($collection as $product) { $result[] = $product->getData(); $result[] = array( // Basic product data 'product_id' => $product->getId(), 'sku' => $product->getSku(), 'name' => $product->getName(), 'set' => $product->getAttributeSetId(), 'type' => $product->getTypeId(), 'category_ids' => $product->getCategoryIds() ); } return $result; }
//
Method: info
$client->call($sessionId, 'catalog_product.info', $productId, $store, $attributes, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Retrieve product info * * @param int|string $productId * @param string|int $store * @param array $attributes * @return array */
$result = array( // Basic product data 'product_id' => $product->getId(), 'sku' => $product->getSku(), 'set' 'type' => $product->getAttributeSetId(), => $product->getTypeId(),
'categories' => $product->getCategoryIds(), 'websites' => $product->getWebsiteIds() ); foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { if ($this->_isAllowedAttribute($attribute, $attributes)) { $result[$attribute->getAttributeCode()] = $product->getData( $attribute->getAttributeCode()); } } return $result; }
Method: create
$client->call($sessionId, 'catalog_product.create', $type, $set, $sku, $productData, $store);
Implemented In
Mage_Catalog_Model_Product_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Create new product. * * @param string $type * @param int $set * @param string $sku * @param array $productData * @param string $store * @return int */
Method: update
$client->call($sessionId, 'catalog_product.update', $productId, $productData, $store, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Update product data * * @param int|string $productId * @param array $productData * @param string|int $store * @return boolean */
Method: delete
$client->call($sessionId, 'catalog_product.delete', $productId, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Api::delete /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/**
Method: getSpecialPrice
$client->call($sessionId, 'catalog_product.getSpecialPrice', $productId, $store);
Implemented In
Mage_Catalog_Model_Product_Api::getSpecialPrice /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Retrieve product special price * * @param int|string $productId * @param string|int $store * @return array */
Method: setSpecialPrice
$client->call($sessionId, 'catalog_product.setSpecialPrice', $productId, $specialPrice, $fromDate, $toDate, $store);
Implemented In
Mage_Catalog_Model_Product_Api::setSpecialPrice /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Update product special price * * @param int|string $productId * @param float $specialPrice * @param string $fromDate * @param string $toDate * @param string|int $store * @return boolean */
Method: listOfAdditionalAttributes
$client->call($sessionId, 'catalog_product.listOfAdditionalAttributes', $productType, $attributeSetId);
Implemented In
Mage_Catalog_Model_Product_Api::getAdditionalAttributes /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Api.php
Doc Comment
/** * Get list of additional attributes which are not in default create/update list * * @param $productType * @param $attributeSetId * @return array */
); } } return $result; }
Resource: catalog_product_attribute
Method: currentStore
$client->call($sessionId, 'catalog_product_attribute.currentStore', $store);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::currentStore /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Api/Resource.php
Doc Comment
/** * Set current store for catalog. * * @param string|int $store * @return int */
Method: list
$client->call($sessionId, 'catalog_product_attribute.list', $setId);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Retrieve attributes from specified attribute set * * @param int $setId * @return array */
->getSortedAttributes($setId); $result = array(); foreach ($attributes as $attribute) { /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) { if (!$attribute->getId() || $attribute->isScopeGlobal()) { $scope = 'global'; } elseif ($attribute->isScopeWebsite()) { $scope = 'website'; } else { $scope = 'store'; } $result[] = array( 'attribute_id' => $attribute->getId(), 'code' => $attribute->getAttributeCode(), 'type' => $attribute->getFrontendInput(), 'required' => $attribute->getIsRequired(), 'scope' => $scope ); } } return $result; }
Method: options
$client->call($sessionId, 'catalog_product_attribute.options', $attributeId, $store);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::options /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Retrieve attribute options * * @param int $attributeId * @param string|int $store * @return array */
if (is_array($optionValue)) { $options[] = $optionValue; } else { $options[] = array( 'value' => $optionId, 'label' => $optionValue ); } } } return $options; }
Method: types
$client->call($sessionId, 'catalog_product_attribute.types');
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::types /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Retrieve list of possible attribute types * * @return array */
Method: create
$client->call($sessionId, 'catalog_product_attribute.create', $data);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Create new product attribute * * @param array $data input data * @return integer */
//validate attribute_code if (!preg_match('/^[a-z][a-z_0-9]{0,254}$/', $data['attribute_code'])) { $this->_fault('invalid_code'); } //validate frontend_input $allowedTypes = array(); foreach ($this->types() as $type) { $allowedTypes[] = $type['value']; } if (!in_array($data['frontend_input'], $allowedTypes)) { $this->_fault('invalid_frontend_input'); } $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']); $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']); if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) { $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']); } $this->_prepareDataForSave($data); $model->addData($data); $model->setEntityTypeId($this->_entityTypeId); $model->setIsUserDefined(1); try { $model->save(); // clear translation cache because attribute labels are stored in translation Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); } catch (Exception $e) { $this->_fault('unable_to_save', $e->getMessage()); } return (int) $model->getId(); }
Method: update
$client->call($sessionId, 'catalog_product_attribute.update', $attribute, $data);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Update product attribute * * @param string|integer $attribute attribute code or ID * @param array $data * @return boolean */
$data['attribute_code'] = $model->getAttributeCode(); $data['is_user_defined'] = $model->getIsUserDefined(); $data['frontend_input'] = $model->getFrontendInput(); $this->_prepareDataForSave($data); $model->addData($data); try { $model->save(); // clear translation cache because attribute labels are stored in translation Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); return true; } catch (Exception $e) { $this->_fault('unable_to_save', $e->getMessage()); } }
Method: remove
$client->call($sessionId, 'catalog_product_attribute.remove', $attribute);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Remove attribute * * @param integer|string $attribute attribute ID or code * @return boolean */
Method: info
$client->call($sessionId, 'catalog_product_attribute.info', $attribute);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Get full information about attribute with list of options
$result['additional_fields'] = array( 'is_wysiwyg_enabled' => $model->getIsWysiwygEnabled(), 'is_html_allowed_on_front' => $model->getIsHtmlAllowedOnFront(), ); break; case 'date': case 'boolean': $result['additional_fields'] = array( 'used_for_sort_by' => $model->getUsedForSortBy() ); break; case 'multiselect': $result['additional_fields'] = array( 'is_filterable' => $model->getIsFilterable(), 'is_filterable_in_search' => $model->getIsFilterableInSearch(), 'position' => $model->getPosition() ); break; case 'select': case 'price': $result['additional_fields'] = array( 'is_filterable' => $model->getIsFilterable(), 'is_filterable_in_search' => $model->getIsFilterableInSearch(), 'position' => $model->getPosition(), 'used_for_sort_by' => $model->getUsedForSortBy() ); break; default: $result['additional_fields'] = array(); break; } // set options $options = $this->options($model->getId()); // remove empty first element if ($model->getFrontendInput() != 'boolean') { array_shift($options); } if (count($options) > 0) { $result['options'] = $options; } return $result; }
Method: addOption
$client->call($sessionId, 'catalog_product_attribute.addOption', $attribute, $data);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::addOption /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Add option to select or multiselect attribute * * @param integer|string $attribute attribute ID or code * @param array $data * @return bool
*/
Method: removeOption
$client->call($sessionId, 'catalog_product_attribute.removeOption', $attribute, $optionId);
Implemented In
Mage_Catalog_Model_Product_Attribute_Api::removeOption /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
Doc Comment
/** * Remove option from select or multiselect attribute * * @param * @param integer|string $attribute attribute ID or code integer $optionId option to remove ID
* @return bool */
Resource: catalog_product_attribute_set
Method: create
$client->call($sessionId, 'catalog_product_attribute_set.create', $attributeSetName, $skeletonSetId);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Create new attribute set based on another set * * @param string $attributeSetName * @param string $skeletonSetId * @return integer */
{ // check if set with requested $skeletonSetId exists if (!Mage::getModel('eav/entity_attribute_set')->load($skeletonSetId)->getId()){ $this->_fault('invalid_skeleton_set_id'); } // get catalog product entity type id $entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId(); /** @var $attributeSet Mage_Eav_Model_Entity_Attribute_Set */ $attributeSet = Mage::getModel('eav/entity_attribute_set') ->setEntityTypeId($entityTypeId) ->setAttributeSetName($attributeSetName); try { // check if name is valid $attributeSet->validate(); // copy parameters to new set from skeleton set $attributeSet->save(); $attributeSet->initFromSkeleton($skeletonSetId)->save(); } catch (Mage_Eav_Exception $e) { $this->_fault('invalid_data', $e->getMessage()); } catch (Exception $e) { $this->_fault('create_attribute_set_error', $e->getMessage()); } return (int)$attributeSet->getId(); }
Method: remove
$client->call($sessionId, 'catalog_product_attribute_set.remove', $attributeSetId, $forceProductsRemove);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Remove attribute set * * @param string $attributeSetId * @param bool $forceProductsRemove * @return bool */
Method: list
$client->call($sessionId, 'catalog_product_attribute_set.list');
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Retrieve attribute set list * * @return array */
Method: attributeAdd
$client->call($sessionId, 'catalog_product_attribute_set.attributeAdd', $attributeId, $attributeSetId, $attributeGroupId, $sortOrder);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::attributeAdd /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Add attribute to attribute set * * @param string $attributeId * @param string $attributeSetId * @param string|null $attributeGroupId * @param string $sortOrder * @return bool */
public function attributeAdd($attributeId, $attributeSetId, $attributeGroupId = null, $sortOrder = '0') { // check if attribute with requested id exists /** @var $attribute Mage_Eav_Model_Entity_Attribute */ $attribute = Mage::getModel('eav/entity_attribute')->load($attributeId); if (!$attribute->getId()) { $this->_fault('invalid_attribute_id'); } // check if attribute set with requested id exists /** @var $attributeSet Mage_Eav_Model_Entity_Attribute_Set */ $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId); if (!$attributeSet->getId()) { $this->_fault('invalid_attribute_set_id'); } if (!empty($attributeGroupId)) { // check if attribute group with requested id exists if (!Mage::getModel('eav/entity_attribute_group')->load($attributeGroupId)->getId()) { $this->_fault('invalid_attribute_group_id'); } } else { // define default attribute group id for current attribute set $attributeGroupId = $attributeSet->getDefaultGroupId(); } $attribute->setAttributeSetId($attributeSet->getId())->loadEntityAttributeIdBySet(); if ($attribute->getEntityAttributeId()) { $this->_fault('attribute_is_already_in_set'); } try { $attribute->setEntityTypeId($attributeSet->getEntityTypeId()) ->setAttributeSetId($attributeSetId) ->setAttributeGroupId($attributeGroupId) ->setSortOrder($sortOrder) ->save(); } catch (Exception $e) { $this->_fault('add_attribute_error', $e->getMessage()); } return true; }
Method: attributeRemove
$client->call($sessionId, 'catalog_product_attribute_set.attributeRemove', $attributeId, $attributeSetId);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::attributeRemove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Remove attribute from attribute set * * @param string $attributeId * @param string $attributeSetId * @return bool */
$attribute = Mage::getModel('eav/entity_attribute')->load($attributeId); if (!$attribute->getId()) { $this->_fault('invalid_attribute_id'); } // check if attribute set with requested id exists /** @var $attributeSet Mage_Eav_Model_Entity_Attribute_Set */ $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId); if (!$attributeSet->getId()) { $this->_fault('invalid_attribute_set_id'); } // check if attribute is in set $attribute->setAttributeSetId($attributeSet->getId())->loadEntityAttributeIdBySet(); if (!$attribute->getEntityAttributeId()) { $this->_fault('attribute_is_not_in_set'); } try { // delete record from eav_entity_attribute // using entity_attribute_id loaded by loadEntityAttributeIdBySet() $attribute->deleteEntity(); } catch (Exception $e) { $this->_fault('remove_attribute_error', $e->getMessage()); } return true; }
Method: groupAdd
$client->call($sessionId, 'catalog_product_attribute_set.groupAdd', $attributeSetId, $groupName);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::groupAdd /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Create group within existing attribute set * * @param * @param */ string|int $attributeSetId string $groupName
* @return int
Method: groupRename
$client->call($sessionId, 'catalog_product_attribute_set.groupRename', $groupId, $groupName);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::groupRename /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Rename existing group * * @param string|int $groupId * @param string $groupName * @return boolean */
Method: groupRemove
$client->call($sessionId, 'catalog_product_attribute_set.groupRemove', $attributeGroupId);
Implemented In
Mage_Catalog_Model_Product_Attribute_Set_Api::groupRemove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Set/ Api.php
Doc Comment
/** * Remove group from existing attribute set * * @param string|int $attributeGroupId * @return bool */
$this->_fault('invalid_attribute_group_id'); } if ($group->hasConfigurableAttributes()) { $this->_fault('group_has_configurable_attributes'); } if ($group->hasSystemAttributes()) { $this->_fault('group_has_system_attributes'); } try { $group->delete(); } catch (Exception $e) { $this->_fault('group_remove_error', $e->getMessage()); } return true; }
Resource: catalog_product_type
Method: list
$client->call($sessionId, 'catalog_product_type.list');
Implemented In
Mage_Catalog_Model_Product_Type_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Type/Api.php
Doc Comment
/** * Retrieve product type list * * @return array */
Resource: catalog_product_attribute_media
Method: currentStore
$client->call($sessionId, 'catalog_product_attribute_media.currentStore', $store);
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::currentStore /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Api/Resource.php
Doc Comment
/** * Set current store for catalog. *
Method: list
$client->call($sessionId, 'catalog_product_attribute_media.list', $productId, $store, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/ Api.php
Doc Comment
/** * Retrieve images for product * * @param int|string $productId * @param string|int $store * @return array */
Method: info
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/ Api.php
Doc Comment
/** * Retrieve image data * * @param int|string $productId * @param string $file * @param string|int $store * @return array */
Method: types
$client->call($sessionId, 'catalog_product_attribute_media.types', $setId);
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::types /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/ Api.php
Doc Comment
/** * Retrieve image types (image, small_image, thumbnail, etc...) * * @param int $setId * @return array */
} elseif ($attribute->isScopeWebsite()) { $scope = 'website'; } else { $scope = 'store'; } $result[] = array( 'code' 'scope' ); } } return $result; } => $attribute->getAttributeCode(), => $scope
Method: create
$client->call($sessionId, 'catalog_product_attribute_media.create', $productId, $data, $store, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/ Api.php
Doc Comment
/** * Create new image for product and return image filename * * @param int|string $productId * @param array $data * @param string|int $store * @return string */
if (isset($data['file']['name']) && $data['file']['name']) { $fileName } else { $fileName } $fileName .= '.' . $this->_mimeTypes[$data['file']['mime']]; $ioAdapter = new Varien_Io_File(); try { // Create temporary directory for api $ioAdapter->checkAndCreateFolder($tmpDirectory); $ioAdapter->open(array('path'=>$tmpDirectory)); // Write image file $ioAdapter->write($fileName, $fileContent, 0666); unset($fileContent); // Adding image to gallery $file = $gallery->getBackend()->addImage( $product, $tmpDirectory . DS . $fileName, null, true ); // Remove temporary directory $ioAdapter->rmdir($tmpDirectory, true); $gallery->getBackend()->updateImage($product, $file, $data); if (isset($data['types'])) { $gallery->getBackend()->setMediaAttribute($product, $data['types'], $file); } $product->save(); } catch (Mage_Core_Exception $e) { $this->_fault('not_created', $e->getMessage()); } catch (Exception $e) { $this->_fault('not_created', Mage::helper('catalog')->__('Cannot create image.')); } return $gallery->getBackend()->getRenamedImage($file); } = $data['file']['name']; = 'image';
Method: update
$client->call($sessionId, 'catalog_product_attribute_media.update', $productId, $file, $data, $store, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/ Api.php
Doc Comment
/** * Update image data * * @param int|string $productId * @param string $file * @param array $data * @param string|int $store
* @return boolean */
Method: remove
$client->call($sessionId, 'catalog_product_attribute_media.remove', $productId, $file, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Attribute_Media_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/ Api.php
Doc Comment
/** * Remove image from product * * @param int|string $productId * @param string $file * @return boolean */
Resource: catalog_product_attribute_tier_price
Method: info
$client->call($sessionId, 'catalog_product_attribute_tier_price.info', $productId, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Attribute_Tierprice_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/ Tierprice/Api.php
{ $product = $this->_initProduct($productId, $identifierType); $tierPrices = $product->getData(self::ATTRIBUTE_CODE); if (!is_array($tierPrices)) { return array(); } $result = array(); foreach ($tierPrices as $tierPrice) { $row = array(); $row['customer_group_id'] = (empty($tierPrice['all_groups']) ? $tierPrice['cust_group'] : 'all' ); $row['website'] = ($tierPrice['website_id'] ? Mage::app()->getWebsite($tierPrice['website_id'])->getCode() : 'all' ); $row['qty'] $row['price'] $result[] = $row; } return $result; } = $tierPrice['price_qty']; = $tierPrice['price'];
Method: update
$client->call($sessionId, 'catalog_product_attribute_tier_price.update', $productId, $tierPrices, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Attribute_Tierprice_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Attribute/ Tierprice/Api.php
Doc Comment
/** * Update tier prices of product * * @param int|string $productId * @param array $tierPrices * @return boolean */
$strErrors = array(); foreach($errors as $code=>$error) { $strErrors[] = ($error === true)? Mage::helper('catalog')->__('Value for "%s" is invalid.', $code) : Mage::helper('catalog')->__('Value for "%s" is invalid: %s', $code, $error); } $this->_fault('data_invalid', implode("\n", $strErrors)); } $product->save(); } catch (Mage_Core_Exception $e) { $this->_fault('not_updated', $e->getMessage()); } return true; }
Resource: catalog_product_link
Method: list
$client->call($sessionId, 'catalog_product_link.list', $type, $productId, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Link_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Link/Api.php
Doc Comment
/** * Retrieve product link associations * * @param string $type * @param int|sku $productId * @param string $identifierType * @return array */
Method: assign
$client->call($sessionId, 'catalog_product_link.assign', $type, $productId, $linkedProductId, $data, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Link_Api::assign /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Link/Api.php
Doc Comment
/** * Add product link association * * @param string $type * @param int|string $productId * @param int|string $linkedProductId * @param array $data * @param string $identifierType * @return boolean */
$indexerStock = Mage::getModel('cataloginventory/stock_status'); $indexerStock->updateStatus($productId); $indexerPrice = Mage::getResourceModel('catalog/product_indexer_price'); $indexerPrice->reindexProductIds($productId); } catch (Exception $e) { $this->_fault('data_invalid', Mage::helper('catalog')->__('Link product does not exist.')); } return true; }
Method: update
$client->call($sessionId, 'catalog_product_link.update', $type, $productId, $linkedProductId, $data, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Link_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Link/Api.php
Doc Comment
/** * Update product link association info * * @param string $type * @param int|string $productId * @param int|string $linkedProductId * @param array $data * @param string $identifierType * @return boolean */
} else { $link->getResource()->saveProductLinks($product, $links, $typeId); } $_linkInstance = Mage::getSingleton('catalog/product_link'); $_linkInstance->saveProductRelations($product); $indexerStock = Mage::getModel('cataloginventory/stock_status'); $indexerStock->updateStatus($productId); $indexerPrice = Mage::getResourceModel('catalog/product_indexer_price'); $indexerPrice->reindexProductIds($productId); } catch (Exception $e) { $this->_fault('data_invalid', Mage::helper('catalog')->__('Link product does not exist.')); } return true; }
Method: remove
$client->call($sessionId, 'catalog_product_link.remove', $type, $productId, $linkedProductId, $identifierType);
Implemented In
Mage_Catalog_Model_Product_Link_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Link/Api.php
Doc Comment
/** * Remove product link association * * @param string $type * @param int|string $productId * @param int|string $linkedProductId * @param string $identifierType * @return boolean */
Method: types
$client->call($sessionId, 'catalog_product_link.types');
Implemented In
Mage_Catalog_Model_Product_Link_Api::types /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Link/Api.php
Doc Comment
/** * Retrieve link types * * @return array */
Method: attributes
$client->call($sessionId, 'catalog_product_link.attributes', $type);
Implemented In
Mage_Catalog_Model_Product_Link_Api::attributes /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Link/Api.php
Doc Comment
/** * Retrieve attribute list for specified type * * @param string $type * @return array */
Resource: catalog_product_custom_option
Method: add
$client->call($sessionId, 'catalog_product_custom_option.add', $productId, $data, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Api::add /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Doc Comment
/** * Add custom option to product * * @param string $productId * @param array $data * @param int|string|null $store * @return bool $isAdded */
Method: update
$client->call($sessionId, 'catalog_product_custom_option.update', $optionId, $data, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Doc Comment
/** * Update product custom option data * * @param string $optionId * @param array $data * @param int|string|null $store * @return bool */
$option = Mage::getModel('catalog/product_option')->load($optionId); if (!$option->getId()) { $this->_fault('option_not_exists'); } $product = $this->_getProduct($option->getProductId(), $store, null); $option = $product->getOptionById($optionId); if (isset($data['type']) and !$this->_isTypeAllowed($data['type'])) { $this->_fault('invalid_type'); } if (isset($data['additional_fields'])) { $this->_prepareAdditionalFields( $data, $option->getGroupByType() ); } foreach ($option->getValues() as $valueId => $value) { if(isset($data['values'][$valueId])) { $data['values'][$valueId] = array_merge($value->getData(), $data['values'][$valueId]); } } $data = array_merge($option->getData(), $data); $this->_saveProductCustomOption($product, $data); return true; }
Method: types
$client->call($sessionId, 'catalog_product_custom_option.types');
Implemented In
Mage_Catalog_Model_Product_Option_Api::types /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Doc Comment
/** * Read list of possible custom option types from module config * * @return array */
Method: info
Implemented In
Mage_Catalog_Model_Product_Option_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Doc Comment
/** * Get full information about custom option in product * * @param int|string $optionId * @param int|string|null $store * @return array */
Method: list
$client->call($sessionId, 'catalog_product_custom_option.list', $productId, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Doc Comment
/** * Retrieve list of product custom options * * @param string $productId * @param int|string|null $store * @return array */
Method: remove
$client->call($sessionId, 'catalog_product_custom_option.remove', $optionId);
Implemented In
Mage_Catalog_Model_Product_Option_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Doc Comment
/** * Remove product custom option * * @param string $optionId * @return boolean */
$option = Mage::getModel('catalog/product_option')->load($optionId); if (!$option->getId()) { $this->_fault('option_not_exists'); } try { $option->getValueInstance()->deleteValue($optionId); $option->deletePrices($optionId); $option->deleteTitles($optionId); $option->delete(); } catch (Exception $e){ $this->fault('delete_option_error'); } return true; }
Resource: catalog_product_custom_option_value
Method: list
$client->call($sessionId, 'catalog_product_custom_option_value.list', $optionId, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Value_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Value/ Api.php
Doc Comment
/** * Retrieve values from specified option * * @param string $optionId * @param int|string|null $store * @return array */
Method: info
$client->call($sessionId, 'catalog_product_custom_option_value.info', $valueId, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Value_Api::info
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Value/ Api.php
Doc Comment
/** * Retrieve specified option value info * * @param string $valueId * @param int|string|null $store * @return array */
Method: add
$client->call($sessionId, 'catalog_product_custom_option_value.add', $optionId, $data, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Value_Api::add /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Value/ Api.php
Doc Comment
/** * Add new values to select option * * @param string $optionId * @param array $data * @param int|string|null $store * @return bool */
{ /** @var $option Mage_Catalog_Model_Product_Option */ $option = $this->_prepareOption($optionId, $store); /** @var $optionValueModel Mage_Catalog_Model_Product_Option_Value */ $optionValueModel = Mage::getModel('catalog/product_option_value'); $optionValueModel->setOption($option); foreach ($data as &$optionValue) { foreach ($optionValue as &$value) { $value = Mage::helper('catalog')->stripTags($value); } } $optionValueModel->setValues($data); try { $optionValueModel->saveValues(); } catch (Exception $e) { $this->_fault('add_option_value_error', $e->getMessage()); } return true; }
Method: update
$client->call($sessionId, 'catalog_product_custom_option_value.update', $valueId, $data, $store);
Implemented In
Mage_Catalog_Model_Product_Option_Value_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Value/ Api.php
Doc Comment
/** * Update value to select option * * @param string $valueId * @param array $data * @param int|string|null $store * @return bool */
$data['store_id'] = $this->_getStoreId($store); $productOptionValue->addValue($data); $productOptionValue->setData($data); try { $productOptionValue->save()->saveValues(); } catch (Exception $e) { $this->_fault('update_option_value_error', $e->getMessage()); } return true; }
Method: remove
$client->call($sessionId, 'catalog_product_custom_option_value.remove', $valueId);
Implemented In
Mage_Catalog_Model_Product_Option_Value_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Catalog/Model/Product/Option/Value/ Api.php
Doc Comment
/** * Delete value from select option * * @param int $valueId * @return boolean */
Resource: sales_order
Method: list
$client->call($sessionId, 'sales_order.list', $filters);
Implemented In
Mage_Sales_Model_Order_Api::items
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Api.php
Doc Comment
/** * Retrieve list of orders by filters * * @param array $filters * @return array */
$result = array(); foreach ($collection as $order) { $result[] = $this->_getAttributes($order, 'order'); } return $result; }
Method: info
$client->call($sessionId, 'sales_order.info', $orderIncrementId);
Implemented In
Mage_Sales_Model_Order_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Api.php
Doc Comment
/** * Retrieve full order information * * @param string $orderIncrementId * @return array */
Method: addComment
$client->call($sessionId, 'sales_order.addComment', $orderIncrementId, $status, $comment, $notify);
Implemented In
Mage_Sales_Model_Order_Api::addComment /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Api.php
Doc Comment
/** * Add comment to order * * @param string $orderIncrementId * @param string $status * @param string $comment * @param boolean $notify * @return boolean */
try { if ($notify && $comment) { $oldStore = Mage::getDesign()->getStore(); $oldArea = Mage::getDesign()->getArea(); Mage::getDesign()->setStore($order->getStoreId()); Mage::getDesign()->setArea('frontend'); } $order->save(); $order->sendOrderUpdateEmail($notify, $comment); if ($notify && $comment) { Mage::getDesign()->setStore($oldStore); Mage::getDesign()->setArea($oldArea); } } catch (Mage_Core_Exception $e) { $this->_fault('status_not_changed', $e->getMessage()); } return true; }
Method: hold
$client->call($sessionId, 'sales_order.hold', $orderIncrementId);
Implemented In
Mage_Sales_Model_Order_Api::hold /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Api.php
Doc Comment
/** * Hold order
Method: unhold
$client->call($sessionId, 'sales_order.unhold', $orderIncrementId);
Implemented In
Mage_Sales_Model_Order_Api::unhold /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Api.php
Doc Comment
/** * Unhold order * * @param string $orderIncrementId * @return boolean */
Method: cancel
$client->call($sessionId, 'sales_order.cancel', $orderIncrementId);
Implemented In
Mage_Sales_Model_Order_Api::cancel /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Api.php
Doc Comment
/** * Cancel order *
Resource: sales_order_shipment
Method: list
$client->call($sessionId, 'sales_order_shipment.list', $filters);
Implemented In
Mage_Sales_Model_Order_Shipment_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Retrive shipments by filters * * @param array $filters * @return array */
} } $result = array(); foreach ($collection as $shipment) { $result[] = $this->_getAttributes($shipment, 'shipment'); } return $result; }
Method: info
$client->call($sessionId, 'sales_order_shipment.info', $shipmentIncrementId);
Implemented In
Mage_Sales_Model_Order_Shipment_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Retrieve shipment information * * @param string $shipmentIncrementId * @return array */
Method: create
Implemented In
Mage_Sales_Model_Order_Shipment_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Create new shipment for order * * @param string $orderIncrementId * @param array $itemsQty * @param string $comment * @param booleam $email * @param boolean $includeComment * @return string */
Method: addComment
$client->call($sessionId, 'sales_order_shipment.addComment', $shipmentIncrementId, $comment, $email, $includeInEmail);
Implemented In
Mage_Sales_Model_Order_Shipment_Api::addComment /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Add comment to shipment * * @param string $shipmentIncrementId * @param string $comment * @param boolean $email * @param boolean $includeInEmail * @return boolean */
try { $shipment->addComment($comment, $email); $shipment->sendUpdateEmail($email, ($includeInEmail ? $comment : '')); $shipment->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; }
Method: addTrack
$client->call($sessionId, 'sales_order_shipment.addTrack', $shipmentIncrementId, $carrier, $title, $trackNumber);
Implemented In
Mage_Sales_Model_Order_Shipment_Api::addTrack /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Add tracking number to order * * @param string $shipmentIncrementId * @param string $carrier * @param string $title * @param string $trackNumber * @return int */
Method: removeTrack
$client->call($sessionId, 'sales_order_shipment.removeTrack', $shipmentIncrementId, $trackId);
Implemented In
Mage_Sales_Model_Order_Shipment_Api::removeTrack /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Remove tracking number * * @param string $shipmentIncrementId * @param int $trackId * @return boolean */
if(!$track = $shipment->getTrackById($trackId)) { $this->_fault('track_not_exists'); } try { $track->delete(); } catch (Mage_Core_Exception $e) { $this->_fault('track_not_deleted', $e->getMessage()); } return true; }
Method: getCarriers
$client->call($sessionId, 'sales_order_shipment.getCarriers', $orderIncrementId);
Implemented In
Mage_Sales_Model_Order_Shipment_Api::getCarriers /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
Doc Comment
/** * Retrieve allowed shipping carriers for specified order * * @param string $orderIncrementId * @return array */
Resource: sales_order_invoice
Method: list
$client->call($sessionId, 'sales_order_invoice.list', $filters);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Retrive invoices by filters * * @param array $filters * @return array */
Method: info
$client->call($sessionId, 'sales_order_invoice.info', $invoiceIncrementId);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Retrieve invoice information * * @param string $invoiceIncrementId * @return array */
if (!$invoice->getId()) { $this->_fault('not_exists'); } $result = $this->_getAttributes($invoice, 'invoice'); $result['order_increment_id'] = $invoice->getOrderIncrementId(); $result['items'] = array(); foreach ($invoice->getAllItems() as $item) { $result['items'][] = $this->_getAttributes($item, 'invoice_item'); } $result['comments'] = array(); foreach ($invoice->getCommentsCollection() as $comment) { $result['comments'][] = $this->_getAttributes($comment, 'invoice_comment'); } return $result; }
Method: create
$client->call($sessionId, 'sales_order_invoice.create', $orderIncrementId, $itemsQty, $comment, $email, $includeComment);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Create new invoice for order * * @param string $orderIncrementId * @param array $itemsQty * @param string $comment * @param booleam $email * @param boolean $includeComment * @return string */
$invoice = $order->prepareInvoice($itemsQty); $invoice->register(); if ($comment !== null) { $invoice->addComment($comment, $email); } if ($email) { $invoice->setEmailSent(true); } $invoice->getOrder()->setIsInProcess(true); try { $transactionSave = Mage::getModel('core/resource_transaction') ->addObject($invoice) ->addObject($invoice->getOrder()) ->save(); $invoice->sendEmail($email, ($includeComment ? $comment : '')); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return $invoice->getIncrementId(); }
Method: addComment
$client->call($sessionId, 'sales_order_invoice.addComment', $invoiceIncrementId, $comment, $email, $includeComment);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::addComment /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Add comment to invoice * * @param string $invoiceIncrementId * @param string $comment * @param boolean $email * @param boolean $includeComment * @return boolean */
try {
$invoice->addComment($comment, $email); $invoice->sendUpdateEmail($email, ($includeComment ? $comment : '')); $invoice->save(); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return true; }
Method: capture
$client->call($sessionId, 'sales_order_invoice.capture', $invoiceIncrementId);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::capture /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Capture invoice * * @param string $invoiceIncrementId * @return boolean */
Method: void
$client->call($sessionId, 'sales_order_invoice.void', $invoiceIncrementId);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::void /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Void invoice * * @param unknown_type $invoiceIncrementId * @return unknown */
Method: cancel
$client->call($sessionId, 'sales_order_invoice.cancel', $invoiceIncrementId);
Implemented In
Mage_Sales_Model_Order_Invoice_Api::cancel /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Invoice/Api.php
Doc Comment
/** * Cancel invoice * * @param string $invoiceIncrementId * @return boolean */
/* @var $invoice Mage_Sales_Model_Order_Invoice */ if (!$invoice->getId()) { $this->_fault('not_exists'); } if (!$invoice->canCancel()) { $this->_fault('status_not_changed', Mage::helper('sales')->__('Invoice cannot be canceled.')); } try { $invoice->cancel(); $invoice->getOrder()->setIsInProcess(true); $transactionSave = Mage::getModel('core/resource_transaction') ->addObject($invoice) ->addObject($invoice->getOrder()) ->save(); } catch (Mage_Core_Exception $e) { $this->_fault('status_not_changed', $e->getMessage()); } catch (Exception $e) { $this->_fault('status_not_changed', Mage::helper('sales')->__('Invoice canceling problem.')); } return true; }
Resource: sales_order_creditmemo
Method: list
$client->call($sessionId, 'sales_order_creditmemo.list', $filter);
Implemented In
Mage_Sales_Model_Order_Creditmemo_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php
Doc Comment
/** * Retrieve credit memos by filters * * @param array|null $filter * @return array */
Method: info
$client->call($sessionId, 'sales_order_creditmemo.info', $creditmemoIncrementId);
Implemented In
Mage_Sales_Model_Order_Creditmemo_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php
Doc Comment
/** * Retrieve credit memo information * * @param string $creditmemoIncrementId * @return array */
Method: create
$client->call($sessionId, 'sales_order_creditmemo.create', $orderIncrementId, $data, $comment, $notifyCustomer, $includeComment, $refundToStoreCreditAmount);
Implemented In
Mage_Sales_Model_Order_Creditmemo_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php
Doc Comment
/** * Create new credit memo for order * * @param string $orderIncrementId * @param array $data array('qtys' => array('sku1' => qty1, ... , 'skuN' => qtyN), * 'shipping_amount' => value, 'adjustment_positive' => value, 'adjustment_negative' => value) * @param string|null $comment * @param bool $notifyCustomer * @param bool $includeComment * @param string $refundToStoreCreditAmount * @return string $creditmemoIncrementId */
{ /** @var $order Mage_Sales_Model_Order */ $order = Mage::getModel('sales/order')->load($orderIncrementId, 'increment_id'); if (!$order->getId()) { $this->_fault('order_not_exists'); } if (!$order->canCreditmemo()) { $this->_fault('cannot_create_creditmemo'); } $data = $this->_prepareCreateData($data); /** @var $service Mage_Sales_Model_Service_Order */ $service = Mage::getModel('sales/service_order', $order); /** @var $creditmemo Mage_Sales_Model_Order_Creditmemo */ $creditmemo = $service->prepareCreditmemo($data); // refund to Store Credit if ($refundToStoreCreditAmount) { // check if refund to Store Credit is available if ($order->getCustomerIsGuest()) { $this->_fault('cannot_refund_to_storecredit'); } $refundToStoreCreditAmount = max( 0, min($creditmemo->getBaseCustomerBalanceReturnMax(), $refundToStoreCreditAmount) ); if ($refundToStoreCreditAmount) { $refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice($refundToStoreCreditAmount); $creditmemo->setBaseCustomerBalanceTotalRefunded($refundToStoreCreditAmount); $refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice( $refundToStoreCreditAmount*$order->getStoreToOrderRate() ); // this field can be used by customer balance observer $creditmemo->setBsCustomerBalTotalRefunded($refundToStoreCreditAmount); // setting flag to make actual refund to customer balance after credit memo save $creditmemo->setCustomerBalanceRefundFlag(true); } } $creditmemo->setPaymentRefundDisallowed(true)->register(); // add comment to creditmemo if (!empty($comment)) { $creditmemo->addComment($comment, $notifyCustomer); } try { Mage::getModel('core/resource_transaction') ->addObject($creditmemo) ->addObject($order) ->save(); // send email notification $creditmemo->sendEmail($notifyCustomer, ($includeComment ? $comment : '')); } catch (Mage_Core_Exception $e) { $this->_fault('data_invalid', $e->getMessage()); } return $creditmemo->getIncrementId(); }
Method: addComment
$client->call($sessionId, 'sales_order_creditmemo.addComment', $creditmemoIncrementId, $comment, $notifyCustomer, $includeComment);
Implemented In
Mage_Sales_Model_Order_Creditmemo_Api::addComment /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php
Doc Comment
/** * Add comment to credit memo * * @param string $creditmemoIncrementId * @param string $comment * @param boolean $notifyCustomer * @param boolean $includeComment * @return boolean */
Method: cancel
$client->call($sessionId, 'sales_order_creditmemo.cancel', $creditmemoIncrementId);
Implemented In
Mage_Sales_Model_Order_Creditmemo_Api::cancel /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php
Doc Comment
/** * Cancel credit memo * * @param string $creditmemoIncrementId * @return boolean */
Resource: cataloginventory_stock_item
Method: list
$client->call($sessionId, 'cataloginventory_stock_item.list', $productIds);
Implemented In
Mage_CatalogInventory_Model_Stock_Item_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api.php
Method: update
$client->call($sessionId, 'cataloginventory_stock_item.update', $productId, $data);
Implemented In
Mage_CatalogInventory_Model_Stock_Item_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/CatalogInventory/Model/Stock/Item/Api.php
public function update($productId, $data) { $product = Mage::getModel('catalog/product'); if ($newId = $product->getIdBySku($productId)) { $productId = $newId; } $product->setStoreId($this->_getStoreId()) ->load($productId); if (!$product->getId()) { $this->_fault('not_exists'); } if (!$stockData = $product->getStockData()) { $stockData = array(); } if (isset($data['qty'])) { $stockData['qty'] = $data['qty']; } if (isset($data['is_in_stock'])) { $stockData['is_in_stock'] = $data['is_in_stock']; } if (isset($data['manage_stock'])) { $stockData['manage_stock'] = $data['manage_stock']; } if (isset($data['use_config_manage_stock'])) { $stockData['use_config_manage_stock'] = $data['use_config_manage_stock']; } $product->setStockData($stockData); try { $product->save(); } catch (Mage_Core_Exception $e) { $this->_fault('not_updated', $e->getMessage()); } return true; }
Resource: cart
Method: create
$client->call($sessionId, 'cart.create', $store);
Implemented In
Mage_Checkout_Model_Cart_Api::create /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Api.php
Doc Comment
/** * Create new quote for shopping cart * * @param int|string $store
* @return int */
Method: order
$client->call($sessionId, 'cart.order', $quoteId, $store, $agreements);
Implemented In
Mage_Checkout_Model_Cart_Api::createOrder /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Api.php
Doc Comment
/** * Create an order from the shopping cart (quote) * * @param * @param $quoteId $store
try { $quote->collectTotals(); /** @var $service Mage_Sales_Model_Service_Quote */ $service = Mage::getModel('sales/service_quote', $quote); $service->submitAll(); if ($isNewCustomer) { try { $customerResource->involveNewCustomer($quote); } catch (Exception $e) { Mage::logException($e); } } $order = $service->getOrder(); if ($order) { Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order' => $order, 'quote' => $quote)); try { $order->sendNewOrderEmail(); } catch (Exception $e) { Mage::logException($e); } } Mage::dispatchEvent( 'checkout_submit_all_after', array('order' => $order, 'quote' => $quote) ); } catch (Mage_Core_Exception $e) { $this->_fault('create_order_fault', $e->getMessage()); } return $order->getIncrementId(); }
Method: info
$client->call($sessionId, 'cart.info', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Api.php
Doc Comment
/** * Retrieve full information about quote * * @param * @param $quoteId $store
* @return array */
Mage::getSingleton('giftmessage/message')->load($quote->getGiftMessageId())->getMessage() ); } $result = $this->_getAttributes($quote, 'quote'); $result['shipping_address'] = $this->_getAttributes($quote->getShippingAddress(), 'quote_address'); $result['billing_address'] = $this->_getAttributes($quote->getBillingAddress(), 'quote_address'); $result['items'] = array(); foreach ($quote->getAllItems() as $item) { if ($item->getGiftMessageId() > 0) { $item->setGiftMessage( Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage() ); } $result['items'][] = $this->_getAttributes($item, 'quote_item'); } $result['payment'] = $this->_getAttributes($quote->getPayment(), 'quote_payment'); return $result; }
Method: totals
$client->call($sessionId, 'cart.totals', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Api::totals /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Api.php
Doc Comment
/** * @param $quoteId * @param $store * @return void */
Method: license
$client->call($sessionId, 'cart.license', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Api::licenseAgreement
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Api.php
Doc Comment
/** * @param $quoteId
Resource: cart_product
Method: add
$client->call($sessionId, 'cart_product.add', $quoteId, $productsData, $store);
Implemented In
Mage_Checkout_Model_Cart_Product_Api::add /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Product/Api.php
Doc Comment
/** * @param * @param $quoteId $productsData
if (isset($productItem['product_id'])) { $productByItem = $this->_getProduct($productItem['product_id'], $store, "id"); } else if (isset($productItem['sku'])) { $productByItem = $this->_getProduct($productItem['sku'], $store, "sku"); } else { $errors[] = Mage::helper('checkout')->__("One item of products do not have identifier or sku"); continue; } $productRequest = $this->_getProductRequest($productItem); try { $result = $quote->addProduct($productByItem, $productRequest); if (is_string($result)) { Mage::throwException($result); } } catch (Mage_Core_Exception $e) { $errors[] = $e->getMessage(); } } if (!empty($errors)) { $this->_fault("add_product_fault", implode(PHP_EOL, $errors)); } try { $quote->collectTotals()->save(); } catch(Exception $e) { $this->_fault("add_product_quote_save_fault", $e->getMessage()); } return true; }
Method: update
$client->call($sessionId, 'cart_product.update', $quoteId, $productsData, $store);
Implemented In
Mage_Checkout_Model_Cart_Product_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Product/Api.php
Doc Comment
/** * @param * @param $quoteId $productsData
$errors = array(); foreach ($productsData as $productItem) { if (isset($productItem['product_id'])) { $productByItem = $this->_getProduct($productItem['product_id'], $store, "id"); } else if (isset($productItem['sku'])) { $productByItem = $this->_getProduct($productItem['sku'], $store, "sku"); } else { $errors[] = Mage::helper('checkout')->__("One item of products do not have identifier or sku"); continue; } /** @var $quoteItem Mage_Sales_Model_Quote_Item */ $quoteItem = $this->_getQuoteItemByProduct($quote, $productByItem, $this->_getProductRequest ($productItem)); if (is_null($quoteItem->getId())) { $errors[] = Mage::helper('checkout')->__("One item of products is not belong any of quote item"); continue; } if ($productItem['qty'] > 0) { $quoteItem->setQty($productItem['qty']); } } if (!empty($errors)) { $this->_fault("update_product_fault", implode(PHP_EOL, $errors)); } try { $quote->save(); } catch(Exception $e) { $this->_fault("update_product_quote_save_fault", $e->getMessage()); } return true; }
Method: remove
$client->call($sessionId, 'cart_product.remove', $quoteId, $productsData, $store);
Implemented In
Mage_Checkout_Model_Cart_Product_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Product/Api.php
Doc Comment
/** * @param * @param * @param $quoteId $productsData $store
* @return bool */
$productsData = $this->_prepareProductsData($productsData); if (empty($productsData)) { $this->_fault('invalid_product_data'); } $errors = array(); foreach ($productsData as $productItem) { if (isset($productItem['product_id'])) { $productByItem = $this->_getProduct($productItem['product_id'], $store, "id"); } else if (isset($productItem['sku'])) { $productByItem = $this->_getProduct($productItem['sku'], $store, "sku"); } else { $errors[] = Mage::helper('checkout')->__("One item of products do not have identifier or sku"); continue; } try { /** @var $quoteItem Mage_Sales_Model_Quote_Item */ $quoteItem = $this->_getQuoteItemByProduct($quote, $productByItem, $this->_getProductRequest ($productItem)); if (is_null($quoteItem->getId())) { $errors[] = Mage::helper('checkout')->__("One item of products is not belong any of quote item"); continue; } $quote->removeItem($quoteItem->getId()); } catch (Mage_Core_Exception $e) { $errors[] = $e->getMessage(); } } if (!empty($errors)) { $this->_fault("remove_product_fault", implode(PHP_EOL, $errors)); } try { $quote->save(); } catch(Exception $e) { $this->_fault("remove_product_quote_save_fault", $e->getMessage()); } return true; }
Method: list
$client->call($sessionId, 'cart_product.list', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Product_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Product/Api.php
Doc Comment
/** * @param * @param $quoteId $store
* @return array */
$quote = $this->_getQuote($quoteId, $store); if (empty($store)) { $store = $quote->getStoreId(); } if (!$quote->getItemsCount()) { return array(); } $productsResult = array(); foreach ($quote->getAllItems() as $item) { /** @var $item Mage_Sales_Model_Quote_Item */ $product = $item->getProduct(); $productsResult[] = array( // Basic product data 'product_id' => $product->getId(), 'sku' => $product->getSku(), 'set' => $product->getAttributeSetId(), 'type' => $product->getTypeId(), 'categories' => $product->getCategoryIds(), 'websites' ); } return $productsResult; } => $product->getWebsiteIds()
Method: moveToCustomerQuote
$client->call($sessionId, 'cart_product.moveToCustomerQuote', $quoteId, $productsData, $store);
Implemented In
Mage_Checkout_Model_Cart_Product_Api::moveToCustomerQuote /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Product/Api.php
Doc Comment
/** * @param * @param $quoteId $productsData
$this->_fault('customer_quote_not_exist'); } if ($customerQuote->getId() == $quote->getId()) { $this->_fault('quotes_are_similar'); } $productsData = $this->_prepareProductsData($productsData); if (empty($productsData)) { $this->_fault('invalid_product_data'); } $errors = array(); foreach($productsData as $key => $productItem){ if (isset($productItem['product_id'])) { $productByItem = $this->_getProduct($productItem['product_id'], $store, "id"); } else if (isset($productItem['sku'])) { $productByItem = $this->_getProduct($productItem['sku'], $store, "sku"); } else { $errors[] = Mage::helper('checkout')->__("One item of products do not have identifier or sku"); continue; } try { /** @var $quoteItem Mage_Sales_Model_Quote_Item */ $quoteItem = $this->_getQuoteItemByProduct($quote, $productByItem, $this->_getProductRequest ($productItem)); if($quoteItem->getId()){ $customerQuote->addItem($quoteItem); $quote->removeItem($quoteItem->getId()); unset($productsData[$key]); } else { $errors[] = Mage::helper('checkout')->__("One item of products is not belong any of quote item"); } } catch (Mage_Core_Exception $e) { $errors[] = $e->getMessage(); } } if (count($productsData) || !empty($errors)) { $this->_fault('unable_to_move_all_products', implode(PHP_EOL, $errors)); } try { $customerQuote ->collectTotals() ->save(); $quote ->collectTotals() ->save(); } catch (Exception $e) { $this->_fault("product_move_quote_save_fault", $e->getMessage()); } return true; }
Resource: cart_customer
Method: set
$client->call($sessionId, 'cart_customer.set', $quoteId, $customerData, $store);
Implemented In
Mage_Checkout_Model_Cart_Customer_Api::set /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Customer/Api.php
Doc Comment
/** * Set customer for shopping cart * * @param int $quoteId * @param array|object $customerData * @param int | string $store * @return int */
Method: addresses
$client->call($sessionId, 'cart_customer.addresses', $quoteId, $customerAddressData, $store);
Implemented In
Mage_Checkout_Model_Cart_Customer_Api::setAddresses /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Customer/Api.php
Doc Comment
/** * @param int $quoteId
// // // // // //
if (($validateRes = $address->validate())!==true) { $this->_fault('customer_address_invalid', implode(PHP_EOL, $validateRes)); } switch($addressMode) { case self::ADDRESS_BILLING: $address->setEmail($quote->getCustomer()->getEmail()); if (!$quote->isVirtual()) { $usingCase = isset($addressItem['use_for_shipping']) ? (int)$addressItem ['use_for_shipping'] : 0; switch($usingCase) { case 0: $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setSameAsBilling(0); break; case 1: $billingAddress = clone $address; $billingAddress->unsAddressId()->unsAddressType(); $shippingAddress = $quote->getShippingAddress(); $shippingMethod = $shippingAddress->getShippingMethod(); $shippingAddress->addData($billingAddress->getData()) ->setSameAsBilling(1) ->setShippingMethod($shippingMethod) ->setCollectShippingRates(true); break; } } $quote->setBillingAddress($address); break; case self::ADDRESS_SHIPPING: $address->setCollectShippingRates(true) ->setSameAsBilling(0); $quote->setShippingAddress($address); break; } } try { $quote ->collectTotals() ->save(); } catch (Exception $e) { $this->_fault('address_is_not_set', $e->getMessage()); } return true; }
Resource: cart_shipping
Method: method
$client->call($sessionId, 'cart_shipping.method', $quoteId, $shippingMethod, $store);
Implemented In
Mage_Checkout_Model_Cart_Shipping_Api::setShippingMethod
/Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Shipping/Api.php
Doc Comment
/** * Set an Shipping Method for Shopping Cart * * @param * @param $quoteId $shippingMethod
Method: list
$client->call($sessionId, 'cart_shipping.list', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Shipping_Api::getShippingMethodsList /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Shipping/Api.php
Doc Comment
/** * Get list of available shipping methods * * @param $quoteId * @param $store * @return array */
try { $quoteShippingAddress->collectShippingRates()->save(); $groupedRates = $quoteShippingAddress->getGroupedAllShippingRates(); $ratesResult = array(); foreach ($groupedRates as $carrierCode => $rates ) { $carrierName = $carrierCode; if (!is_null(Mage::getStoreConfig('carriers/'.$carrierCode.'/title'))) { $carrierName = Mage::getStoreConfig('carriers/'.$carrierCode.'/title'); } foreach ($rates as $rate) { $rateItem = $this->_getAttributes($rate, "quote_shipping_rate"); $rateItem['carrierName'] = $carrierName; $ratesResult[] = $rateItem; unset($rateItem); } } } catch (Mage_Core_Exception $e) { $this->_fault('shipping_methods_list_could_not_be_retrived', $e->getMessage()); } return $ratesResult; }
Resource: cart_payment
Method: method
$client->call($sessionId, 'cart_payment.method', $quoteId, $paymentData, $store);
Implemented In
Mage_Checkout_Model_Cart_Payment_Api::setPaymentMethod /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php
Doc Comment
/** * @param * @param $quoteId $paymentData
} else { // check if shipping address is set if (is_null($quote->getShippingAddress()->getId()) ) { $this->_fault('shipping_address_is_not_set'); } $quote->getShippingAddress()->setPaymentMethod(isset($paymentData['method']) ? $paymentData ['method'] : null); } if (!$quote->isVirtual() && $quote->getShippingAddress()) { $quote->getShippingAddress()->setCollectShippingRates(true); } $total = $quote->getBaseSubtotal(); $methods = Mage::helper('payment')->getStoreMethods($store, $quote); foreach ($methods as $key=>$method) { if ($method->getCode() == $paymentData['method']) { /** @var $method Mage_Payment_Model_Method_Abstract */ if (!($this->_canUsePaymentMethod($method, $quote) && ($total != 0 || $method->getCode() == 'free' || ($quote->hasRecurringItems() && $method->canManageRecurringProfiles())))) { $this->_fault("method_not_allowed"); } } } try { $payment = $quote->getPayment(); $payment->importData($paymentData);
$quote->setTotalsCollectedFlag(false) ->collectTotals() ->save(); } catch (Mage_Core_Exception $e) { $this->_fault('payment_method_is_not_set', $e->getMessage()); } return true; }
Method: list
$client->call($sessionId, 'cart_payment.list', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Payment_Api::getPaymentMethodsList /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php
Doc Comment
/** * @param $quoteId
$total = $quote->getBaseSubtotal(); $methodsResult = array(); $methods = Mage::helper('payment')->getStoreMethods($store, $quote); foreach ($methods as $key=>$method) { /** @var $method Mage_Payment_Model_Method_Abstract */ if ($this->_canUsePaymentMethod($method, $quote) && ($total != 0 || $method->getCode() == 'free' || ($quote->hasRecurringItems() && $method->canManageRecurringProfiles()))) { $methodsResult[] = array( "code" => $method->getCode(), "title" => $method->getTitle(), "ccTypes" => $this->_getPaymentMethodAvailableCcTypes($method) ); } } return $methodsResult; }
Resource: cart_coupon
Method: add
$client->call($sessionId, 'cart_coupon.add', $quoteId, $couponCode, $store);
Implemented In
Mage_Checkout_Model_Cart_Coupon_Api::add /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Coupon/Api.php
Doc Comment
/** * @param $quoteId
Method: remove
$client->call($sessionId, 'cart_coupon.remove', $quoteId, $store);
Implemented In
Mage_Checkout_Model_Cart_Coupon_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Checkout/Model/Cart/Coupon/Api.php
Doc Comment
/** * @param * @param $quoteId $storeId
* @return void */
public function remove($quoteId, $store = null) { $couponCode = ''; return $this->_applyCoupon($quoteId, $couponCode, $store); }
Resource: catalog_product_tag
Method: list
$client->call($sessionId, 'catalog_product_tag.list', $productId, $store);
Implemented In
Mage_Tag_Model_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Tag/Model/Api.php
Doc Comment
/** * Retrieve list of tags for specified product * * @param int $productId * @param string|int $store * @return array */
Method: info
$client->call($sessionId, 'catalog_product_tag.info', $tagId, $store);
Implemented In
Mage_Tag_Model_Api::info /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Tag/Model/Api.php
Doc Comment
/**
* Retrieve tag info as array('name'-> .., 'status' => .., * 'base_popularity' => .., 'products' => array($productId => $popularity, ...)) * * @param int $tagId * @param string|int $store * @return array */
Method: add
$client->call($sessionId, 'catalog_product_tag.add', $data);
Implemented In
Mage_Tag_Model_Api::add /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Tag/Model/Api.php
Doc Comment
/** * Add tag(s) to product. * Return array of added/updated tags as array($tagName => $tagId, ...) * * @param array $data * @return array */
} $storeId = $this->_getStoreId($data['store']); try { /** @var $tag Mage_Tag_Model_Tag */ $tag = Mage::getModel('tag/tag'); $tagNamesArr = Mage::helper('tag')->cleanTags(Mage::helper('tag')->extractTags($data['tag'])); foreach ($tagNamesArr as $tagName) { // unset previously added tag data $tag->unsetData(); $tag->loadByName($tagName); if (!$tag->getId()) { $tag->setName($tagName) ->setFirstCustomerId($customer->getId()) ->setFirstStoreId($storeId) ->setStatus($tag->getPendingStatus()) ->save(); } $tag->saveRelation($product->getId(), $customer->getId(), $storeId); $result[$tagName] = $tag->getId(); } } catch (Mage_Core_Exception $e) { $this->_fault('save_error', $e->getMessage()); } return $result; }
Method: update
$client->call($sessionId, 'catalog_product_tag.update', $tagId, $data, $store);
Implemented In
Mage_Tag_Model_Api::update /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Tag/Model/Api.php
Doc Comment
/** * Change existing tag information * * @param int $tagId * @param array $data * @param string|int $store * @return bool */
if (isset($data['name'])) { $tag->setName(trim($data['name'])); } if (isset($data['status'])) { // validate tag status if (!in_array($data['status'], array( $tag->getApprovedStatus(), $tag->getPendingStatus(), $tag->getDisabledStatus()))) { $this->_fault('invalid_data'); } $tag->setStatus($data['status']); } try { $tag->save(); } catch (Mage_Core_Exception $e) { $this->_fault('save_error', $e->getMessage()); } return true; }
Method: remove
$client->call($sessionId, 'catalog_product_tag.remove', $tagId);
Implemented In
Mage_Tag_Model_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Tag/Model/Api.php
Doc Comment
/** * Remove existing tag * * @param int $tagId * @return bool */
Resource: giftmessage
Method: setForQuote
$client->call($sessionId, 'giftmessage.setForQuote', $quoteId, $giftMessage, $store);
Implemented In
Mage_GiftMessage_Model_Api::setForQuote /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/GiftMessage/Model/Api.php
Doc Comment
/** * Set GiftMessage for a Quote. * * @param String $quoteId * @param AssociativeArray $giftMessage * @param String $store * @return AssociativeArray */
Method: setForQuoteItem
$client->call($sessionId, 'giftmessage.setForQuoteItem', $quoteItemId, $giftMessage, $store);
Implemented In
Mage_GiftMessage_Model_Api::setForQuoteItem /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/GiftMessage/Model/Api.php
Doc Comment
/** * Set GiftMessage for a QuoteItem by its Id. * * @param String $quoteItemId * @param AssociativeArray $giftMessage * @param String $store * @return AssociativeArray */
$giftMessage['type'] = 'quote_item'; $giftMessages = array($quoteItem->getId() => $giftMessage); $request = new Mage_Core_Controller_Request_Http(); $request->setParam("giftmessage", $giftMessages); return $this->_setGiftMessage($quoteItemId, $request, $quote); }
Method: setForQuoteProduct
$client->call($sessionId, 'giftmessage.setForQuoteProduct', $quoteId, $productsAndMessages, $store);
Implemented In
Mage_GiftMessage_Model_Api::setForQuoteProduct /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/GiftMessage/Model/Api.php
Doc Comment
/** * Set a GiftMessage to QuoteItem by product * * @param String $quoteId * @param Array $productsAndMessages * @param String $store * @return array */
continue; } $productObj = $this->_getProductRequest($product); $quoteItem = $this->_getQuoteItemByProduct($quote, $productByItem, $productObj); $results[] = $this->setForQuoteItem($quoteItem->getId(), $message, $store); } } return $results; }
Resource: catalog_product_downloadable_link
Method: add
$client->call($sessionId, 'catalog_product_downloadable_link.add', $productId, $resource, $resourceType, $store, $identifierType);
Implemented In
Mage_Downloadable_Model_Link_Api::add /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Downloadable/Model/Link/Api.php
Doc Comment
/** * Add downloadable content to product * * @param int|string $productId * @param array $resource * @param string $resourceType * @param string|int|null $store * @param string|null $identifierType ('sku'|'id') * @return boolean */
if (isset($resource['sample']['file'])) { $resource['sample']['file'] = $this->_uploadFile($resource['sample']['file'], 'link_samples'); } unset($resource['sample']['url']); } elseif ($resourceType == 'link' && $resource['sample']['type'] == 'url') { $resource['sample']['file'] = null; } $product = $this->_getProduct($productId, $store, $identifierType); try { $downloadable = array($resourceType => array($resource)); $product->setDownloadableData($downloadable); $product->save(); } catch (Exception $e) { $this->_fault('save_error', $e->getMessage()); } return true; }
Method: list
$client->call($sessionId, 'catalog_product_downloadable_link.list', $productId, $store, $identifierType);
Implemented In
Mage_Downloadable_Model_Link_Api::items /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Downloadable/Model/Link/Api.php
Doc Comment
/** * Retrieve downloadable product links * * @param int|string $productId * @param string|int $store * @param string $identifierType ('sku'|'id') * @return array */
if ($item->getLinkFile() && !is_file($file)) { Mage::helper('core/file_storage_database')->saveFileToFilesystem($file); } if ($item->getLinkFile() && is_file($file)) { $name = Mage::helper('downloadable/file')->getFileFromPathFile($item->getLinkFile()); $tmpLinkItem['file_save'] = array( array( 'file' => $item->getLinkFile(), 'name' => $name, 'size' => filesize($file), 'status' => 'old' )); } $sampleFile = Mage::helper('downloadable/file')->getFilePath( Mage_Downloadable_Model_Link::getBaseSamplePath(), $item->getSampleFile() ); if ($item->getSampleFile() && is_file($sampleFile)) { $tmpLinkItem['sample_file_save'] = array( array( 'file' => $item->getSampleFile(), 'name' => Mage::helper('downloadable/file')->getFileFromPathFile($item->getSampleFile ()), 'size' => filesize($sampleFile), 'status' => 'old' )); } if ($item->getNumberOfDownloads() == '0') { $tmpLinkItem['is_unlimited'] = 1; } if ($product->getStoreId() && $item->getStoreTitle()) { $tmpLinkItem['store_title'] = $item->getStoreTitle(); } if ($product->getStoreId() && Mage::helper('downloadable')->getIsPriceWebsiteScope()) { $tmpLinkItem['website_price'] = $item->getWebsitePrice(); } $linkArr[] = $tmpLinkItem; } unset($item); unset($tmpLinkItem); unset($links); $samples = $product->getTypeInstance(true)->getSamples($product)->getData(); return array('links' => $linkArr, 'samples' => $samples); }
Method: remove
$client->call($sessionId, 'catalog_product_downloadable_link.remove', $linkId, $resourceType);
Implemented In
Mage_Downloadable_Model_Link_Api::remove /Users/alanstorm/Sites2011/magento1point6point1.dev/app/code/core/Mage/Downloadable/Model/Link/Api.php
Doc Comment
/** * Remove downloadable product link * @param string $linkId * @param string $resourceType * @return bool
*/