Version Notes
ERPinCloud Connector
Download this release
Release Info
Developer | Team ERPInCloud |
Extension | ERPinCloudConnector |
Version | 2.1.2 |
Comparing to | |
See all releases |
Version 2.1.2
- app/code/community/ERPinCloud/Connector/Helper/Data.php +7 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Categories.php +98 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Category/Api.php +67 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Api.php +77 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Attribute.php +109 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Attributegroup.php +171 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Attributeset.php +28 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Link.php +248 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Tierprice.php +36 -0
- app/code/community/ERPinCloud/Connector/Model/Catalog/Products.php +316 -0
- app/code/community/ERPinCloud/Connector/Model/Observer.php +25 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcore/Groups.php +122 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcore/Storeviews.php +122 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcore/Website.php +151 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Address.php +206 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Customer.php +137 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Group.php +99 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Subscriber.php +141 -0
- app/code/community/ERPinCloud/Connector/Model/Oerpstock/Item/Api.php +72 -0
- app/code/community/ERPinCloud/Connector/Model/Sales/Order/Api.php +187 -0
- app/code/community/ERPinCloud/Connector/controllers/Adminhtml/InitController.php +62 -0
- app/code/community/ERPinCloud/Connector/controllers/OpenerpsyncController.php +5 -0
- app/code/community/ERPinCloud/Connector/etc/api.xml +629 -0
- app/code/community/ERPinCloud/Connector/etc/config.xml +91 -0
- app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-install-0.0.1.php +53 -0
- app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-0.0.1-2.0.0.php +5 -0
- app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-2.0.0-2.1.0.php +5 -0
- app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-2.1.0-2.1.1.php +5 -0
- app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-2.1.1-2.1.2.php +5 -0
- app/etc/modules/ERPinCloud_Connector.xml +10 -0
- package.xml +18 -0
app/code/community/ERPinCloud/Connector/Helper/Data.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
//Linux4ever_MagentoXtender_Model_Api
|
5 |
+
}
|
6 |
+
|
7 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Categories.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Catalog_Categories extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
public function items($filters = null) {
|
6 |
+
try {
|
7 |
+
$collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image');
|
8 |
+
} catch (Mage_Core_Exception $e) {
|
9 |
+
$this->_fault('category_not_exists');
|
10 |
+
}
|
11 |
+
if (is_array($filters)) {
|
12 |
+
try {
|
13 |
+
foreach ($filters as $field => $value) {
|
14 |
+
$collection->addFieldToFilter($field, $value);
|
15 |
+
}
|
16 |
+
} catch (Mage_Core_Exception $e) {
|
17 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
18 |
+
// If we are adding filter on non-existent attribute
|
19 |
+
}
|
20 |
+
}
|
21 |
+
$result = array();
|
22 |
+
foreach ($collection as $category) {
|
23 |
+
//$result[] = $customer->toArray();
|
24 |
+
$result[] = array(
|
25 |
+
'category_id' => $category->getId(),
|
26 |
+
'image' => $category->getImage(),
|
27 |
+
);
|
28 |
+
}
|
29 |
+
return $result;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function info($categoryId = null) {
|
33 |
+
if (is_numeric($categoryId)) {
|
34 |
+
try {
|
35 |
+
$collection = Mage :: getModel('catalog/category/attribute')->load($categoryId)->getCollection()->addAttributeToSelect('image');
|
36 |
+
$result = array();
|
37 |
+
foreach ($collection as $category) {
|
38 |
+
//$result[] = $customer->toArray();
|
39 |
+
if ($category->getId() == $categoryId) {
|
40 |
+
$image = $category->getImage();
|
41 |
+
if ($image) {
|
42 |
+
$path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
|
43 |
+
$fullpath = $path . $image;
|
44 |
+
try {
|
45 |
+
$fp = fopen($fullpath, "rb");
|
46 |
+
$imagebin = fread($fp, filesize($fullpath));
|
47 |
+
$img_data = base64_encode($imagebin);
|
48 |
+
fclose($fp);
|
49 |
+
} catch (Exception $e) {
|
50 |
+
$this->_fault('not_media');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
$result[] = array(
|
54 |
+
'category_id' => $category->getId(),
|
55 |
+
'image' => $category->getImage(),
|
56 |
+
'image_data' => $img_data
|
57 |
+
);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
return $result;
|
62 |
+
} catch (Mage_Core_Exception $e) {
|
63 |
+
$this->_fault('group_not_exists');
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
public function create($filename, $imgdata) {
|
69 |
+
if ($filename) {
|
70 |
+
$path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
|
71 |
+
$fullpath = $path . $filename;
|
72 |
+
try {
|
73 |
+
$fp = fopen($fullpath, "w");
|
74 |
+
if ($fp == false) {
|
75 |
+
return "Error in file creation";
|
76 |
+
}
|
77 |
+
$img_data = base64_decode($imgdata);
|
78 |
+
$imagebin = fwrite($fp, $img_data);
|
79 |
+
fclose($fp);
|
80 |
+
return $imagebin;
|
81 |
+
} catch (Exception $e) {
|
82 |
+
$this->_fault('not_created');
|
83 |
+
}
|
84 |
+
return False;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
public function update($something = null) {
|
89 |
+
return "Not implemented yet";
|
90 |
+
}
|
91 |
+
|
92 |
+
public function remove($something = null) {
|
93 |
+
return "Not implemented yet";
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Category/Api.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Catalog_Category_Api extends Mage_Catalog_Model_Category_Api {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Return the list of products category ids
|
7 |
+
*
|
8 |
+
* @param array $filters
|
9 |
+
* @param string|int $store
|
10 |
+
* @return array
|
11 |
+
*/
|
12 |
+
public function search($filters = null, $store = null) {
|
13 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
14 |
+
->setStoreId($this->_getStoreId($store))
|
15 |
+
->addAttributeToSelect('name');
|
16 |
+
|
17 |
+
if (is_array($filters)) {
|
18 |
+
try {
|
19 |
+
foreach ($filters as $field => $value) {
|
20 |
+
if (isset($this->_filtersMap[$field])) {
|
21 |
+
$field = $this->_filtersMap[$field];
|
22 |
+
}
|
23 |
+
|
24 |
+
$collection->addFieldToFilter($field, $value);
|
25 |
+
}
|
26 |
+
} catch (Mage_Core_Exception $e) {
|
27 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
$result = array();
|
32 |
+
|
33 |
+
foreach ($collection as $product) {
|
34 |
+
$result[] = $product->getId();
|
35 |
+
}
|
36 |
+
|
37 |
+
return $result;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function move($categoryId, $parentId, $afterId = null) {
|
41 |
+
$category = $this->_initCategory($categoryId);
|
42 |
+
$parent_category = $this->_initCategory($parentId);
|
43 |
+
|
44 |
+
$parentChildren = $parent_category->getChildren();
|
45 |
+
$child = explode(',', $parentChildren);
|
46 |
+
// TODO Improve speed when using $afterId
|
47 |
+
if (!in_array($categoryId, $child) || $afterId != null) {
|
48 |
+
// if $afterId is null - move category to the down
|
49 |
+
if ($afterId === null && $parent_category->hasChildren()) {
|
50 |
+
|
51 |
+
$afterId = array_pop($child);
|
52 |
+
}
|
53 |
+
|
54 |
+
if (strpos($parent_category->getPath(), $category->getPath()) === 0) {
|
55 |
+
$this->_fault('not_moved', "Operation do not allow to move a parent category to any of children category");
|
56 |
+
}
|
57 |
+
|
58 |
+
try {
|
59 |
+
$category->move($parentId, $afterId);
|
60 |
+
} catch (Mage_Core_Exception $e) {
|
61 |
+
$this->_fault('not_moved', $e->getMessage());
|
62 |
+
}
|
63 |
+
}
|
64 |
+
return true;
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Api.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Catalog_Product_Api extends Mage_Catalog_Model_Product_Api {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Set additional data before product saved
|
7 |
+
*
|
8 |
+
* @param Mage_Catalog_Model_Product $product
|
9 |
+
* @param array $productData
|
10 |
+
* @return object
|
11 |
+
*/
|
12 |
+
protected function _prepareDataForSave($product, $productData) {
|
13 |
+
if (isset($productData['categories']) && is_array($productData['categories'])) {
|
14 |
+
$product->setCategoryIds($productData['categories']);
|
15 |
+
}
|
16 |
+
|
17 |
+
if (isset($productData['websites']) && is_array($productData['websites'])) {
|
18 |
+
foreach ($productData['websites'] as &$website) {
|
19 |
+
if (is_string($website)) {
|
20 |
+
try {
|
21 |
+
$website = Mage::app()->getWebsite($website)->getId();
|
22 |
+
} catch (Exception $e) {
|
23 |
+
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
$product->setWebsiteIds($productData['websites']);
|
28 |
+
}
|
29 |
+
|
30 |
+
if (Mage::app()->isSingleStoreMode()) {
|
31 |
+
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
|
32 |
+
}
|
33 |
+
|
34 |
+
if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
|
35 |
+
$product->setStockData($productData['stock_data']);
|
36 |
+
} else {
|
37 |
+
$product->setStockData(array('use_config_manage_stock' => 0));
|
38 |
+
}
|
39 |
+
|
40 |
+
if (isset($productData['tier_price']) && is_array($productData['tier_price'])) {
|
41 |
+
$tierPrices = Mage::getModel('catalog/product_attribute_tierprice_api')->prepareTierPrices($product, $productData['tier_price']);
|
42 |
+
$product->setData(Mage_Catalog_Model_Product_Attribute_Tierprice_Api::ATTRIBUTE_CODE, $tierPrices);
|
43 |
+
}
|
44 |
+
|
45 |
+
/*
|
46 |
+
* Check if configurable product data array passed
|
47 |
+
*/
|
48 |
+
if (isset($productData['configurable_products_data']) && is_array($productData['configurable_products_data'])) {
|
49 |
+
$product->setConfigurableProductsData($productData['configurable_products_data']);
|
50 |
+
}
|
51 |
+
|
52 |
+
if (isset($productData['configurable_attributes_data']) && is_array($productData['configurable_attributes_data'])) {
|
53 |
+
foreach ($productData['configurable_attributes_data'] as $key => $data) {
|
54 |
+
|
55 |
+
//Check to see if these values exist, otherwise try and populate from existing values
|
56 |
+
$data['label'] = (!empty($data['label'])) ? $data['label'] : $product->getResource()->getAttribute($data['attribute_code'])->getStoreLabel();
|
57 |
+
$data['frontend_label'] = (!empty($data['frontend_label'])) ? $data['frontend_label'] : $product->getResource()->getAttribute($data['attribute_code'])->getFrontendLabel();
|
58 |
+
$productData['configurable_attributes_data'][$key] = $data;
|
59 |
+
}
|
60 |
+
$product->setConfigurableAttributesData($productData['configurable_attributes_data']);
|
61 |
+
$product->setCanSaveConfigurableAttributes(true);
|
62 |
+
}
|
63 |
+
|
64 |
+
/*
|
65 |
+
* Check if bundle product data, options and bundle items arrays passed
|
66 |
+
*/
|
67 |
+
if (isset($productData['bundle_items_data']) && isset($productData['options_data']) && is_array($productData['bundle_items_data']) && is_array($productData['options_data'])) {
|
68 |
+
|
69 |
+
$product->setBundleOptionsData($productData['options_data']);
|
70 |
+
$product->setBundleSelectionsData($productData['bundle_items_data']);
|
71 |
+
$product->setCanSaveBundleSelections(true);
|
72 |
+
$product->setAffectBundleProductSelections(true);
|
73 |
+
Mage::register('product', $product); // product must be registred in order to get the store_id, see _beforeSave() in Mage/Bundle/Model/Selection.php
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Attribute.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
class ERPinCloud_Connector_Model_Catalog_Product_Attribute extends Mage_Catalog_Model_Api_Resource {
|
9 |
+
|
10 |
+
public function __construct() {
|
11 |
+
$this->_storeIdSessionField = 'product_store_id';
|
12 |
+
$this->_ignoredAttributeCodes[] = 'type_id';
|
13 |
+
$this->_ignoredAttributeTypes[] = 'gallery';
|
14 |
+
$this->_ignoredAttributeTypes[] = 'media_image';
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Retrieve attributes from specified attribute set
|
19 |
+
*
|
20 |
+
* @param int $setId
|
21 |
+
* @return array
|
22 |
+
*/
|
23 |
+
public function relations($setId) {
|
24 |
+
$attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId);
|
25 |
+
$result = array();
|
26 |
+
foreach ($attributes as $attribute) {
|
27 |
+
$result[] = Array(
|
28 |
+
'attribute_id' => $attribute->getId()
|
29 |
+
);
|
30 |
+
}
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function items($setId) {
|
35 |
+
$attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId);
|
36 |
+
$result = array();
|
37 |
+
|
38 |
+
foreach ($attributes as $attribute) {
|
39 |
+
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
|
40 |
+
if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) {
|
41 |
+
|
42 |
+
if (!$attribute->getId() || $attribute->isScopeGlobal()) {
|
43 |
+
$scope = 'global';
|
44 |
+
} elseif ($attribute->isScopeWebsite()) {
|
45 |
+
$scope = 'website';
|
46 |
+
} else {
|
47 |
+
$scope = 'store';
|
48 |
+
}
|
49 |
+
|
50 |
+
/* $result[] = array (
|
51 |
+
'attribute_id' => $attribute->getId(),
|
52 |
+
'code' => $attribute->getAttributeCode(),
|
53 |
+
'type' => $attribute->getFrontendInput(),
|
54 |
+
'required' => $attribute->getIsRequired(),
|
55 |
+
'attributeset' => $attribute->getattribute_set_info(),
|
56 |
+
'scope' => $scope
|
57 |
+
); */
|
58 |
+
//Override hooray
|
59 |
+
$attribute['scope'] = $scope;
|
60 |
+
$result[] = $attribute->toArray();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
return $result;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function info($attributeId) {
|
68 |
+
try {
|
69 |
+
return 'hello';
|
70 |
+
$attribute = Mage :: getModel('catalog/product')->getResource()->getAttribute($attributeId);
|
71 |
+
return $attribute->toArray();
|
72 |
+
} catch (Exception $e) {
|
73 |
+
$this->_fault('not_exists');
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Retrieve attribute options
|
79 |
+
*
|
80 |
+
* @param int $attributeId
|
81 |
+
* @param string|int $store
|
82 |
+
* @return array
|
83 |
+
*/
|
84 |
+
public function options($attributeId, $store = null) {
|
85 |
+
$storeId = $this->_getStoreId($store);
|
86 |
+
$attribute = Mage :: getModel('catalog/product')->setStoreId($storeId)->getResource()->getAttribute($attributeId)->setStoreId($storeId);
|
87 |
+
|
88 |
+
/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
|
89 |
+
if (!$attribute) {
|
90 |
+
$this->_fault('not_exists');
|
91 |
+
}
|
92 |
+
|
93 |
+
$options = array();
|
94 |
+
foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) {
|
95 |
+
if (is_array($optionValue)) {
|
96 |
+
$options[] = $optionValue;
|
97 |
+
} else {
|
98 |
+
$options[] = array(
|
99 |
+
'value' => $optionId,
|
100 |
+
'label' => $optionValue
|
101 |
+
);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
return $options;
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Attributegroup.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
class ERPinCloud_Connector_Model_Catalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource {
|
9 |
+
|
10 |
+
public function olditems($setId = null) {
|
11 |
+
$groups = Mage :: getModel('eav/entity_attribute_group')->getResourceCollection();
|
12 |
+
|
13 |
+
if (!is_null($setId) && !empty($setId) && is_numeric($setId)) {
|
14 |
+
$groups->setAttributeSetFilter($setId);
|
15 |
+
}
|
16 |
+
|
17 |
+
$groups->load();
|
18 |
+
|
19 |
+
$arrGroups = array();
|
20 |
+
|
21 |
+
foreach ($groups as $group) {
|
22 |
+
$arrGroups[] = array(
|
23 |
+
'attribute_group_id' => $group->getAttributeGroupId(),
|
24 |
+
'attribute_set_id' => $group->getAttributeSetId(),
|
25 |
+
'attribute_group_name' => $group->getAttributeGroupName(),
|
26 |
+
'sort_order' => $group->getSortOrder(),
|
27 |
+
'default_id' => $group->getDefaultId()
|
28 |
+
);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $arrGroups;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function items($filters = null) {
|
35 |
+
try {
|
36 |
+
$collection = Mage :: getModel('eav/entity_attribute_group')->getCollection();
|
37 |
+
} catch (Mage_Core_Exception $e) {
|
38 |
+
$this->_fault('group_not_exists');
|
39 |
+
}
|
40 |
+
|
41 |
+
if (is_array($filters)) {
|
42 |
+
try {
|
43 |
+
foreach ($filters as $field => $value) {
|
44 |
+
$collection->addFieldToFilter($field, $value);
|
45 |
+
}
|
46 |
+
} catch (Mage_Core_Exception $e) {
|
47 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
48 |
+
// If we are adding filter on non-existent attribute
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
$result = array();
|
53 |
+
foreach ($collection as $collection_item) {
|
54 |
+
$result[] = $collection_item->toArray();
|
55 |
+
}
|
56 |
+
|
57 |
+
return $result;
|
58 |
+
}
|
59 |
+
|
60 |
+
/*
|
61 |
+
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
|
62 |
+
<param><value><string>catalog_product_attribute_group.create</string></value></param>
|
63 |
+
<param>
|
64 |
+
<value>
|
65 |
+
<array>
|
66 |
+
<data>
|
67 |
+
<value><i4>26</i4></value>
|
68 |
+
<value><string>Leonelle</string></value>
|
69 |
+
</data>
|
70 |
+
</array>
|
71 |
+
</value>
|
72 |
+
</param>
|
73 |
+
*/
|
74 |
+
|
75 |
+
public function create($setId, array $data) {
|
76 |
+
try {
|
77 |
+
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
|
78 |
+
$attrOption = Mage :: getModel("eav/entity_attribute_group");
|
79 |
+
|
80 |
+
$attrOption->addData($data);
|
81 |
+
|
82 |
+
// check if there already exists a group with the give groupname
|
83 |
+
if ($attrOption->itemExists()) {
|
84 |
+
$this->_fault("group_already_exists");
|
85 |
+
}
|
86 |
+
|
87 |
+
$attrOption->save();
|
88 |
+
|
89 |
+
return (int) $attrOption->getAttributeGroupId();
|
90 |
+
} catch (Exception $ex) {
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
/*
|
96 |
+
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
|
97 |
+
<param><value><string>catalog_product_attribute_group.update</string></value></param>
|
98 |
+
<param>
|
99 |
+
<value>
|
100 |
+
<array>
|
101 |
+
<data>
|
102 |
+
<value><i4>85</i4></value>
|
103 |
+
<value><string>Leonelle2</string></value>
|
104 |
+
<value><i4>85</i4></value>
|
105 |
+
<value><i4>85</i4></value>
|
106 |
+
</data>
|
107 |
+
</array>
|
108 |
+
</value>
|
109 |
+
</param>
|
110 |
+
*/
|
111 |
+
|
112 |
+
public function update(array $data) {
|
113 |
+
try {
|
114 |
+
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
|
115 |
+
$attrOption = Mage :: getModel("eav/entity_attribute_group");
|
116 |
+
|
117 |
+
$attrOption->load($data["attribute_group_id"]);
|
118 |
+
|
119 |
+
// check if the requested group exists...
|
120 |
+
if (!$attrOption->getAttributeGroupId()) {
|
121 |
+
$this->_fault("group_not_exists");
|
122 |
+
}
|
123 |
+
|
124 |
+
$attrOption->addData($data);
|
125 |
+
|
126 |
+
$attrOption->save();
|
127 |
+
|
128 |
+
return true;
|
129 |
+
} catch (Exception $ex) {
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/*
|
135 |
+
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
|
136 |
+
<param><value><string>catalog_product_attribute_group.delete</string></value></param>
|
137 |
+
<param>
|
138 |
+
<value>
|
139 |
+
<array>
|
140 |
+
<data>
|
141 |
+
<value><i4>85</i4></value>
|
142 |
+
</data>
|
143 |
+
</array>
|
144 |
+
</value>
|
145 |
+
</param>
|
146 |
+
*/
|
147 |
+
|
148 |
+
public function delete($groupId) {
|
149 |
+
try {
|
150 |
+
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
|
151 |
+
$attrOption = Mage :: getModel("eav/entity_attribute_group");
|
152 |
+
|
153 |
+
$attrOption->load($groupId);
|
154 |
+
|
155 |
+
// check if the requested group exists...
|
156 |
+
if (!$attrOption->getAttributeGroupId()) {
|
157 |
+
$this->_fault("group_not_exists");
|
158 |
+
}
|
159 |
+
|
160 |
+
// save data
|
161 |
+
$attrOption->delete();
|
162 |
+
|
163 |
+
return true;
|
164 |
+
} catch (Exception $ex) {
|
165 |
+
return false;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Attributeset.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Catalog_Product_Attributeset extends Mage_Api_Model_Resource_Abstract {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Retrieve attribute set list
|
7 |
+
*
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function items() {
|
11 |
+
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
|
12 |
+
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
13 |
+
->setEntityTypeFilter($entityType->getId());
|
14 |
+
|
15 |
+
$result = array();
|
16 |
+
foreach ($collection as $attributeSet) {
|
17 |
+
$result[] = array(
|
18 |
+
'attribute_set_id' => $attributeSet->getId(),
|
19 |
+
'attribute_set_name' => $attributeSet->getAttributeSetName()
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
return $result;
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
// Class Mage_Catalog_Model_Product_Attribute_Set_Api End
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Link.php
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Catalog_Product_Link extends Mage_Catalog_Model_Product_Link_Api {//Mage_Core_Model_Abstract {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* get list product_super_link
|
7 |
+
*
|
8 |
+
* @param int $productId
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
|
12 |
+
public function items($productId) {
|
13 |
+
$product = $this->_initProduct($productId);
|
14 |
+
|
15 |
+
$childProducts = array();
|
16 |
+
|
17 |
+
//$configurableAttributes = $product->getTypeInstance()->getConfigurableAttributesAsArray();
|
18 |
+
//print_r($configurableAttributes);
|
19 |
+
$collection = $product->getTypeInstance()->getUsedProducts(); //getUsedProductCollection();
|
20 |
+
|
21 |
+
foreach ($collection as $simpleProduct) {
|
22 |
+
$row = $simpleProduct->toArray();
|
23 |
+
|
24 |
+
// naming convention
|
25 |
+
$row["product_id"] = $row["entity_id"];
|
26 |
+
$row["type"] = $row["type_id"];
|
27 |
+
$row["set"] = $row["attribute_set_id"];
|
28 |
+
$childProducts[] = $row; // $simpleProduct->toArray();
|
29 |
+
}
|
30 |
+
|
31 |
+
return $childProducts;
|
32 |
+
|
33 |
+
return array();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* set product_super_link
|
38 |
+
*
|
39 |
+
* @param int $productId
|
40 |
+
* @param array $linkedProductIds
|
41 |
+
* @param array $data
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function assign($productId, $linkedProductIds, $data = array()) {
|
45 |
+
$product = $this->_initProduct($productId);
|
46 |
+
$tmpProductIds = $product->getTypeInstance()->getUsedProductIds();
|
47 |
+
$productIds = array();
|
48 |
+
|
49 |
+
foreach ($tmpProductIds as $key => $prodId) {
|
50 |
+
$productIds[$prodId] = $prodId;
|
51 |
+
}
|
52 |
+
|
53 |
+
if (is_array($linkedProductIds)) {
|
54 |
+
foreach ($linkedProductIds as $prodId) {
|
55 |
+
if (!key_exists($prodId, $productIds)) {
|
56 |
+
$productIds[$prodId] = $prodId;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
} elseif (is_numeric($linkedProductIds)) {
|
60 |
+
if (!key_exists($linkedProductIds, $productIds)) {
|
61 |
+
$productIds[$linkedProductIds] = $linkedProductIds;
|
62 |
+
}
|
63 |
+
} else {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
$product->setConfigurableProductsData($productIds);
|
68 |
+
$product->save();
|
69 |
+
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* remove product_super_link
|
75 |
+
*
|
76 |
+
* @param int $productId
|
77 |
+
* @param array $linkedProductIds
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
public function remove($productId, $linkedProductIds) {
|
81 |
+
$product = $this->_initProduct($productId);
|
82 |
+
$tmpProductIds = $product->getTypeInstance()->getUsedProductIds();
|
83 |
+
$productIds = array();
|
84 |
+
|
85 |
+
foreach ($tmpProductIds as $key => $prodId) {
|
86 |
+
if (is_array($linkedProductIds)) {
|
87 |
+
if (!in_array($prodId, $linkedProductIds)) {
|
88 |
+
|
89 |
+
$productIds[$prodId] = $prodId;
|
90 |
+
}
|
91 |
+
} elseif (is_numeric($linkedProductIds)) {
|
92 |
+
if ($prodId != $linkedProductIds) {
|
93 |
+
$productIds[$prodId] = $prodId;
|
94 |
+
;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
$product->setConfigurableProductsData($productIds);
|
100 |
+
$product->save();
|
101 |
+
|
102 |
+
return true;
|
103 |
+
}
|
104 |
+
|
105 |
+
private function _getStores() {
|
106 |
+
$stores = Mage::getModel('core/store')
|
107 |
+
->getResourceCollection()
|
108 |
+
->setLoadDefault(true)
|
109 |
+
->load();
|
110 |
+
return $stores;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* List Configurables Atributes
|
115 |
+
*
|
116 |
+
* @param int $productId
|
117 |
+
* @return array
|
118 |
+
*/
|
119 |
+
public function listSuperAttributes($productIdOrSku) {
|
120 |
+
try {
|
121 |
+
// check if product Exists
|
122 |
+
$product = $this->_initProduct($productIdOrSku);
|
123 |
+
|
124 |
+
if ($product->getTypeId() != "configurable")
|
125 |
+
$this->_fault("not a configurable product");
|
126 |
+
|
127 |
+
$productId = $product->getEntityId();
|
128 |
+
|
129 |
+
$stores = $this->_getStores();
|
130 |
+
|
131 |
+
$superAttributes = array();
|
132 |
+
|
133 |
+
foreach ($stores as $store) {
|
134 |
+
$product = $product = Mage::getModel('catalog/product')->setStoreId($store->getStoreId());
|
135 |
+
$product->load($productId);
|
136 |
+
$attrs = $product->getTypeInstance()->getConfigurableAttributesAsArray();
|
137 |
+
|
138 |
+
foreach ($attrs as $key => $attr) {
|
139 |
+
if (!isset($superAttributes[$attr["id"]])) {
|
140 |
+
$superAttributes["" . $attr["id"] . ""] = $attr;
|
141 |
+
$superAttributes["" . $attr["id"] . ""]["product_id"] = $product->getEntityId();
|
142 |
+
$superAttributes["" . $attr["id"] . ""]["product_super_attribute_id"] = $attr["id"];
|
143 |
+
unset($superAttributes["" . $attr["id"] . ""]["id"]);
|
144 |
+
}
|
145 |
+
|
146 |
+
unset($superAttributes["" . $attr["id"] . ""]["label"]);
|
147 |
+
|
148 |
+
$superAttributes["" . $attr["id"] . ""]["labels"][$store->getStoreId()] = $attr["label"];
|
149 |
+
}
|
150 |
+
}
|
151 |
+
//print_r($superAttributes);
|
152 |
+
|
153 |
+
return array_values($superAttributes);
|
154 |
+
} catch (Exception $ex) {
|
155 |
+
echo $ex;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Create Configurables Atributes
|
161 |
+
*
|
162 |
+
* @param int $productId
|
163 |
+
* @param int $attributeID
|
164 |
+
* @param int position
|
165 |
+
* @param array labels
|
166 |
+
* @param array prices
|
167 |
+
* @return ID
|
168 |
+
*/
|
169 |
+
public function createSuperAttribute($productIDorSku, $attributeID, $position, array $labels, array $prices = null) {
|
170 |
+
$product = $this->_initProduct($productIDorSku);
|
171 |
+
//$confAttributes = $product->getTypeInstance()->getUsedProductIds();
|
172 |
+
|
173 |
+
$superAttr = Mage::getModel("catalog/product_type_configurable_attribute");
|
174 |
+
|
175 |
+
$superAttr->setProductId($product->getId());
|
176 |
+
$superAttr->setAttributeId($attributeID);
|
177 |
+
$superAttr->setPosition($position);
|
178 |
+
|
179 |
+
if (is_string($labels)) {
|
180 |
+
$superAttr->setStoreId(0);
|
181 |
+
$superAttr->setLabel($labels);
|
182 |
+
$superAttr->save();
|
183 |
+
} elseif (is_array($labels)) {
|
184 |
+
foreach ($labels as $storeID => $label) {
|
185 |
+
$superAttr->setStoreId($storeID);
|
186 |
+
$superAttr->setLabel($label);
|
187 |
+
$superAttr->save();
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
if (is_array($prices)) {
|
192 |
+
$superAttr->setValues($prices);
|
193 |
+
$superAttr->save();
|
194 |
+
}
|
195 |
+
|
196 |
+
return (int) $superAttr->getId();
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Set Configurables Atributes
|
201 |
+
*
|
202 |
+
* @param int $product
|
203 |
+
* @param int $attribute
|
204 |
+
* @return True
|
205 |
+
*/
|
206 |
+
public function setSuperAttributeValues($product, $attribute) {
|
207 |
+
#get if product exists
|
208 |
+
$product = Mage::getModel('catalog/product')->load($product)->getID();
|
209 |
+
if (!$product) {
|
210 |
+
return False;
|
211 |
+
}
|
212 |
+
#get if attribute exists
|
213 |
+
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id')->load($attribute)->getID();
|
214 |
+
if (!$attribute) {
|
215 |
+
return False;
|
216 |
+
}
|
217 |
+
|
218 |
+
#try add catalog_product_super_attribute
|
219 |
+
try {
|
220 |
+
$resource = Mage::getSingleton('core/resource');
|
221 |
+
$writeConnection = $resource->getConnection('core_write');
|
222 |
+
$query = 'INSERT INTO ' . $resource->getTableName('catalog_product_super_attribute') . ' (product_id, attribute_id) VALUES (' . $product . ', ' . $attribute . ');';
|
223 |
+
$writeConnection->query($query);
|
224 |
+
return True;
|
225 |
+
} catch (Exception $e) {
|
226 |
+
return False;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Remove Configurables Atributes
|
232 |
+
*
|
233 |
+
* @param int $superAttributeID
|
234 |
+
* @return ID
|
235 |
+
*/
|
236 |
+
public function removeSuperAttribute($superAttributeID) {
|
237 |
+
$superAttr = Mage::getModel("catalog/product_type_configurable_attribute");
|
238 |
+
$superAttr->load($superAttributeID);
|
239 |
+
|
240 |
+
$superAttr->delete();
|
241 |
+
//$superAttr->setValues($prices);
|
242 |
+
//$superAttr->save();
|
243 |
+
return true;
|
244 |
+
}
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Product/Tierprice.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Olcatalog_Product_Tierprice extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
const ATTRIBUTE_CODE = 'tier_price';
|
6 |
+
|
7 |
+
public function items($productIds = null) {
|
8 |
+
if (is_array($productIds)) {
|
9 |
+
$result = array();
|
10 |
+
foreach ($productIds as $productId) {
|
11 |
+
$product = Mage :: getModel('catalog/product')->load($productId);
|
12 |
+
if (!$product->getId()) {
|
13 |
+
$this->_fault('product_not_exists');
|
14 |
+
}
|
15 |
+
$tierPrices = $product->getData(self :: ATTRIBUTE_CODE);
|
16 |
+
$result[$productId] = $tierPrices;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
return $result;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function items2($productIds = null) {
|
23 |
+
$product = Mage :: getModel('catalog/product_attribute_backend_tierprice')->_get_set_go();
|
24 |
+
if (!$product->getId()) {
|
25 |
+
$this->_fault('product_not_exists');
|
26 |
+
}
|
27 |
+
|
28 |
+
$tierPrices = $product->getPriceModel()->getTierPriceCount();
|
29 |
+
return 'hello';
|
30 |
+
$result[$productIds] = $tierPrices;
|
31 |
+
|
32 |
+
|
33 |
+
return $result;
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/ERPinCloud/Connector/Model/Catalog/Products.php
ADDED
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Catalog_Products extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
protected $_filtersMap = array(
|
6 |
+
'product_id' => 'entity_id',
|
7 |
+
'set' => 'attribute_set_id',
|
8 |
+
'type' => 'type_id'
|
9 |
+
);
|
10 |
+
|
11 |
+
public function __construct() {
|
12 |
+
$this->_storeIdSessionField = 'product_store_id';
|
13 |
+
$this->_ignoredAttributeTypes[] = 'gallery';
|
14 |
+
$this->_ignoredAttributeTypes[] = 'media_image';
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Return the list of products ids
|
19 |
+
*
|
20 |
+
* @param array $filters
|
21 |
+
* @param string|int $store
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function search($filters = null, $store = null) {
|
25 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
26 |
+
->setStoreId($this->_getStoreId($store))
|
27 |
+
->addAttributeToSelect('name');
|
28 |
+
|
29 |
+
if (is_array($filters)) {
|
30 |
+
try {
|
31 |
+
foreach ($filters as $field => $value) {
|
32 |
+
if (isset($this->_filtersMap[$field])) {
|
33 |
+
$field = $this->_filtersMap[$field];
|
34 |
+
}
|
35 |
+
|
36 |
+
$collection->addFieldToFilter($field, $value);
|
37 |
+
}
|
38 |
+
} catch (Mage_Core_Exception $e) {
|
39 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
$result = array();
|
44 |
+
|
45 |
+
foreach ($collection as $product) {
|
46 |
+
$result[] = $product->getId();
|
47 |
+
}
|
48 |
+
|
49 |
+
return $result;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Retrieve list of products with basic info (id, sku, type, set, name)
|
54 |
+
*
|
55 |
+
* @param array $filters
|
56 |
+
* @param string|int $store
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
public function items($filters = null, $store = null) {
|
60 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
61 |
+
->setStoreId($this->_getStoreId($store))
|
62 |
+
->addAttributeToSelect('name');
|
63 |
+
|
64 |
+
if (is_array($filters)) {
|
65 |
+
try {
|
66 |
+
foreach ($filters as $field => $value) {
|
67 |
+
if (isset($this->_filtersMap[$field])) {
|
68 |
+
$field = $this->_filtersMap[$field];
|
69 |
+
}
|
70 |
+
|
71 |
+
$collection->addFieldToFilter($field, $value);
|
72 |
+
}
|
73 |
+
} catch (Mage_Core_Exception $e) {
|
74 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
$result = array();
|
79 |
+
|
80 |
+
foreach ($collection as $product) {
|
81 |
+
// $result[] = $product->getData();
|
82 |
+
$result[] = array(// Basic product data
|
83 |
+
'product_id' => $product->getId(),
|
84 |
+
'sku' => $product->getSku(),
|
85 |
+
'name' => $product->getName(),
|
86 |
+
'set' => $product->getAttributeSetId(),
|
87 |
+
'type' => $product->getTypeId(),
|
88 |
+
'category_ids' => $product->getCategoryIds()
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
return $result;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Retrieve product info
|
97 |
+
*
|
98 |
+
* @param int|string $productId
|
99 |
+
* @param string|int $store
|
100 |
+
* @param array $attributes
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
public function biglist($productId, $store = null, $filters = null) {
|
104 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
105 |
+
->setStoreId($this->_getStoreId($store))
|
106 |
+
->addAttributeToSelect('name');
|
107 |
+
|
108 |
+
if (is_array($filters)) {
|
109 |
+
try {
|
110 |
+
foreach ($filters as $field => $value) {
|
111 |
+
if (isset($this->_filtersMap[$field])) {
|
112 |
+
$field = $this->_filtersMap[$field];
|
113 |
+
}
|
114 |
+
|
115 |
+
$collection->addFieldToFilter($field, $value);
|
116 |
+
}
|
117 |
+
} catch (Mage_Core_Exception $e) {
|
118 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
119 |
+
}
|
120 |
+
}
|
121 |
+
foreach ($collection as $product) {
|
122 |
+
$data = array();
|
123 |
+
$data = array(// Basic product data
|
124 |
+
'product_id' => $product->getId(),
|
125 |
+
'sku' => $product->getSku(),
|
126 |
+
'set' => $product->getAttributeSetId(),
|
127 |
+
'type' => $product->getTypeId(),
|
128 |
+
'categories' => $product->getCategoryIds(),
|
129 |
+
'websites' => $product->getWebsiteIds()
|
130 |
+
);
|
131 |
+
|
132 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
133 |
+
$data[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode());
|
134 |
+
}
|
135 |
+
$result[] = $data;
|
136 |
+
}
|
137 |
+
return $result;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Create new product.
|
142 |
+
*
|
143 |
+
* @param string $type
|
144 |
+
* @param int $set
|
145 |
+
* @param array $productData
|
146 |
+
* @return int
|
147 |
+
*/
|
148 |
+
public function create($type, $set, $sku, $productData) {
|
149 |
+
if (!$type || !$set || !$sku) {
|
150 |
+
$this->_fault('data_invalid');
|
151 |
+
}
|
152 |
+
|
153 |
+
$product = Mage::getModel('catalog/product');
|
154 |
+
/* @var $product Mage_Catalog_Model_Product */
|
155 |
+
$product->setStoreId($this->_getStoreId($store))
|
156 |
+
->setAttributeSetId($set)
|
157 |
+
->setTypeId($type)
|
158 |
+
->setSku($sku);
|
159 |
+
|
160 |
+
if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
|
161 |
+
$product->setWebsiteIds($productData['website_ids']);
|
162 |
+
}
|
163 |
+
|
164 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
165 |
+
if ($this->_isAllowedAttribute($attribute) && isset($productData[$attribute->getAttributeCode()])) {
|
166 |
+
$product->setData(
|
167 |
+
$attribute->getAttributeCode(), $productData[$attribute->getAttributeCode()]
|
168 |
+
);
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
$this->_prepareDataForSave($product, $productData);
|
173 |
+
|
174 |
+
if (is_array($errors = $product->validate())) {
|
175 |
+
$this->_fault('data_invalid', implode("\n", $errors));
|
176 |
+
}
|
177 |
+
|
178 |
+
try {
|
179 |
+
$product->save();
|
180 |
+
} catch (Mage_Core_Exception $e) {
|
181 |
+
$this->_fault('data_invalid', $e->getMessage());
|
182 |
+
}
|
183 |
+
|
184 |
+
return $product->getId();
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Update product data
|
189 |
+
*
|
190 |
+
* @param int|string $productId
|
191 |
+
* @param array $productData
|
192 |
+
* @param string|int $store
|
193 |
+
* @return boolean
|
194 |
+
*/
|
195 |
+
public function update($productId, $productData = array(), $store = null) {
|
196 |
+
$product = $this->_getProduct($productId, $store);
|
197 |
+
|
198 |
+
if (!$product->getId()) {
|
199 |
+
$this->_fault('not_exists');
|
200 |
+
}
|
201 |
+
|
202 |
+
if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
|
203 |
+
$product->setWebsiteIds($productData['website_ids']);
|
204 |
+
}
|
205 |
+
|
206 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
207 |
+
if ($this->_isAllowedAttribute($attribute) && isset($productData[$attribute->getAttributeCode()])) {
|
208 |
+
$product->setData(
|
209 |
+
$attribute->getAttributeCode(), $productData[$attribute->getAttributeCode()]
|
210 |
+
);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
$this->_prepareDataForSave($product, $productData);
|
215 |
+
|
216 |
+
try {
|
217 |
+
if (is_array($errors = $product->validate())) {
|
218 |
+
$this->_fault('data_invalid', implode("\n", $errors));
|
219 |
+
}
|
220 |
+
} catch (Mage_Core_Exception $e) {
|
221 |
+
$this->_fault('data_invalid', $e->getMessage());
|
222 |
+
}
|
223 |
+
|
224 |
+
try {
|
225 |
+
$product->save();
|
226 |
+
} catch (Mage_Core_Exception $e) {
|
227 |
+
$this->_fault('data_invalid', $e->getMessage());
|
228 |
+
}
|
229 |
+
|
230 |
+
return true;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Set additional data before product saved
|
235 |
+
*
|
236 |
+
* @param Mage_Catalog_Model_Product $product
|
237 |
+
* @param array $productData
|
238 |
+
* @return object
|
239 |
+
*/
|
240 |
+
protected function _prepareDataForSave($product, $productData) {
|
241 |
+
if (isset($productData['categories']) && is_array($productData['categories'])) {
|
242 |
+
$product->setCategoryIds($productData['categories']);
|
243 |
+
}
|
244 |
+
|
245 |
+
if (isset($productData['websites']) && is_array($productData['websites'])) {
|
246 |
+
foreach ($productData['websites'] as &$website) {
|
247 |
+
if (is_string($website)) {
|
248 |
+
try {
|
249 |
+
$website = Mage::app()->getWebsite($website)->getId();
|
250 |
+
} catch (Exception $e) {
|
251 |
+
|
252 |
+
}
|
253 |
+
}
|
254 |
+
}
|
255 |
+
$product->setWebsiteIds($productData['websites']);
|
256 |
+
}
|
257 |
+
|
258 |
+
if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
|
259 |
+
$product->setStockData($productData['stock_data']);
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Update product special price
|
265 |
+
*
|
266 |
+
* @param int|string $productId
|
267 |
+
* @param float $specialPrice
|
268 |
+
* @param string $fromDate
|
269 |
+
* @param string $toDate
|
270 |
+
* @param string|int $store
|
271 |
+
* @return boolean
|
272 |
+
*/
|
273 |
+
public function setSpecialPrice($productId, $specialPrice = null, $fromDate = null, $toDate = null, $store = null) {
|
274 |
+
return $this->update($productId, array(
|
275 |
+
'special_price' => $specialPrice,
|
276 |
+
'special_from_date' => $fromDate,
|
277 |
+
'special_to_date' => $toDate
|
278 |
+
), $store);
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Retrieve product special price
|
283 |
+
*
|
284 |
+
* @param int|string $productId
|
285 |
+
* @param string|int $store
|
286 |
+
* @return array
|
287 |
+
*/
|
288 |
+
public function getSpecialPrice($productId, $store = null) {
|
289 |
+
return $this->info($productId, $store, array('special_price', 'special_from_date', 'special_to_date'));
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Delete product
|
294 |
+
*
|
295 |
+
* @param int|string $productId
|
296 |
+
* @return boolean
|
297 |
+
*/
|
298 |
+
public function delete($productId) {
|
299 |
+
$product = $this->_getProduct($productId);
|
300 |
+
|
301 |
+
if (!$product->getId()) {
|
302 |
+
$this->_fault('not_exists');
|
303 |
+
}
|
304 |
+
|
305 |
+
try {
|
306 |
+
$product->delete();
|
307 |
+
} catch (Mage_Core_Exception $e) {
|
308 |
+
$this->_fault('not_deleted', $e->getMessage());
|
309 |
+
}
|
310 |
+
|
311 |
+
return true;
|
312 |
+
}
|
313 |
+
|
314 |
+
}
|
315 |
+
|
316 |
+
// Class Mage_Catalog_Model_Product_Api End
|
app/code/community/ERPinCloud/Connector/Model/Observer.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Mohammed NAHHAS
|
6 |
+
* @package ERPinCloud_Connector
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class ERPinCloud_Connector_Model_Observer extends Mage_Core_Model_Abstract {
|
10 |
+
/* Initialize attribtue 'imported' if version < 1.4.0.0 */
|
11 |
+
|
12 |
+
public function initImported($observer) {
|
13 |
+
if (str_replace('.', '', Mage::getVersion()) < 1400) {
|
14 |
+
$order = $observer->getOrder();
|
15 |
+
try {
|
16 |
+
$order->setImported(0)->save();
|
17 |
+
} catch (Exception $e) {
|
18 |
+
/* If logs are enabled (backend : system->configuration->developer->logSettings), it creates a file named OpenErp_Connector.log in /var/log/ which contains the errors */
|
19 |
+
Mage::log('Error, order increment_id = ' . $order->getIncrementId() . ', attribute "imported" was not initialized - error : ' . $e->getMessage(), null, 'OpenErp_Connector.log');
|
20 |
+
}
|
21 |
+
$order->setImported(0)->save();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/community/ERPinCloud/Connector/Model/Oerpcore/Groups.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Oerpcore_Groups extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Return the list of partner ids which match the filters
|
7 |
+
*
|
8 |
+
* @param array $filters
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function search($filters) {
|
12 |
+
|
13 |
+
$collection = Mage::getModel('core/store_group')->getCollection();
|
14 |
+
|
15 |
+
if (is_array($filters)) {
|
16 |
+
try {
|
17 |
+
foreach ($filters as $field => $value) {
|
18 |
+
$collection->addFieldToFilter($field, $value);
|
19 |
+
}
|
20 |
+
} catch (Mage_Core_Exception $e) {
|
21 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $collection->getAllIds();
|
26 |
+
}
|
27 |
+
|
28 |
+
public function items($filters = null) {
|
29 |
+
try {
|
30 |
+
$collection = Mage::getModel('core/store_group')->getCollection(); //->addAttributeToSelect('*');
|
31 |
+
} catch (Mage_Core_Exception $e) {
|
32 |
+
$this->_fault('group_not_exists');
|
33 |
+
}
|
34 |
+
|
35 |
+
if (is_array($filters)) {
|
36 |
+
try {
|
37 |
+
foreach ($filters as $field => $value) {
|
38 |
+
$collection->addFieldToFilter($field, $value);
|
39 |
+
}
|
40 |
+
} catch (Mage_Core_Exception $e) {
|
41 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
42 |
+
// If we are adding filter on non-existent attribute
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
$result = array();
|
47 |
+
foreach ($collection as $customer) {
|
48 |
+
$result[] = $customer->toArray();
|
49 |
+
}
|
50 |
+
|
51 |
+
return $result;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function info($groupIds = null) {
|
55 |
+
$groups = array();
|
56 |
+
|
57 |
+
if (is_array($groupIds)) {
|
58 |
+
foreach ($groupIds as $groupId) {
|
59 |
+
try {
|
60 |
+
$groups[] = Mage::getModel('core/store_group')->load($groupId)->toArray();
|
61 |
+
} catch (Mage_Core_Exception $e) {
|
62 |
+
$this->_fault('group_not_exists');
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return $groups;
|
66 |
+
} elseif (is_numeric($groupIds)) {
|
67 |
+
try {
|
68 |
+
return Mage::getModel('core/store_group')->load($groupIds)->toArray();
|
69 |
+
} catch (Mage_Core_Exception $e) {
|
70 |
+
$this->_fault('group_not_exists');
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
public function create($groupdata) {
|
76 |
+
try {
|
77 |
+
$group = Mage::getModel('core/store_group')
|
78 |
+
->setData($groupdata)
|
79 |
+
->save();
|
80 |
+
} catch (Magento_Core_Exception $e) {
|
81 |
+
$this->_fault('data_invalid', $e->getMessage());
|
82 |
+
} catch (Exception $e) {
|
83 |
+
$this->_fault('data_invalid', $e->getMessage());
|
84 |
+
}
|
85 |
+
return $group->getId();
|
86 |
+
}
|
87 |
+
|
88 |
+
public function update($groupid, $groupdata) {
|
89 |
+
try {
|
90 |
+
$group = Mage::getModel('core/store_group')
|
91 |
+
->load($groupid);
|
92 |
+
if (!$group->getId()) {
|
93 |
+
$this->_fault('group_not_exists');
|
94 |
+
}
|
95 |
+
$group->addData($groupdata)->save();
|
96 |
+
} catch (Magento_Core_Exception $e) {
|
97 |
+
$this->_fault('data_invalid', $e->getMessage());
|
98 |
+
} catch (Exception $e) {
|
99 |
+
$this->_fault('data_invalid', $e->getMessage());
|
100 |
+
}
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function delete($groupid) {
|
105 |
+
try {
|
106 |
+
$group = Mage::getModel('core/store_group')
|
107 |
+
->load($groupid);
|
108 |
+
if (!$group->getId()) {
|
109 |
+
$this->_fault('group_not_exists');
|
110 |
+
}
|
111 |
+
$group->delete();
|
112 |
+
} catch (Magento_Core_Exception $e) {
|
113 |
+
$this->_fault('data_invalid', $e->getMessage());
|
114 |
+
} catch (Exception $e) {
|
115 |
+
$this->_fault('data_invalid', $e->getMessage());
|
116 |
+
}
|
117 |
+
return true;
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Oerpcore/Storeviews.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Oerpcore_Storeviews extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Return the list of storeviews ids which match the filters
|
7 |
+
*
|
8 |
+
* @param array $filters
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function search($filters) {
|
12 |
+
|
13 |
+
$collection = Mage::getModel('core/store')->getCollection();
|
14 |
+
|
15 |
+
if (is_array($filters)) {
|
16 |
+
try {
|
17 |
+
foreach ($filters as $field => $value) {
|
18 |
+
$collection->addFieldToFilter($field, $value);
|
19 |
+
}
|
20 |
+
} catch (Mage_Core_Exception $e) {
|
21 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
return $collection->getAllIds();
|
26 |
+
}
|
27 |
+
|
28 |
+
public function items($filters = null) {
|
29 |
+
try {
|
30 |
+
$collection = Mage::getModel('core/store')->getCollection(); //->addAttributeToSelect('*');
|
31 |
+
} catch (Mage_Core_Exception $e) {
|
32 |
+
$this->_fault('store_not_exists');
|
33 |
+
}
|
34 |
+
|
35 |
+
if (is_array($filters)) {
|
36 |
+
try {
|
37 |
+
foreach ($filters as $field => $value) {
|
38 |
+
$collection->addFieldToFilter($field, $value);
|
39 |
+
}
|
40 |
+
} catch (Mage_Core_Exception $e) {
|
41 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
42 |
+
// If we are adding filter on non-existent attribute
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
$result = array();
|
47 |
+
foreach ($collection as $customer) {
|
48 |
+
$result[] = $customer->toArray();
|
49 |
+
}
|
50 |
+
|
51 |
+
return $result;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function info($storeIds = null) {
|
55 |
+
$stores = array();
|
56 |
+
|
57 |
+
if (is_array($storeIds)) {
|
58 |
+
foreach ($storeIds as $storeId) {
|
59 |
+
try {
|
60 |
+
$stores[] = Mage::getModel('core/store')->load($storeId)->toArray();
|
61 |
+
} catch (Mage_Core_Exception $e) {
|
62 |
+
$this->_fault('store_not_exists');
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return $stores;
|
66 |
+
} elseif (is_numeric($storeIds)) {
|
67 |
+
try {
|
68 |
+
return Mage::getModel('core/store')->load($storeIds)->toArray();
|
69 |
+
} catch (Mage_Core_Exception $e) {
|
70 |
+
$this->_fault('store_not_exists');
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
public function create($storedata) {
|
76 |
+
try {
|
77 |
+
$store = Mage::getModel('core/store')
|
78 |
+
->setData($storedata)
|
79 |
+
->save();
|
80 |
+
} catch (Magento_Core_Exception $e) {
|
81 |
+
$this->_fault('data_invalid', $e->getMessage());
|
82 |
+
} catch (Exception $e) {
|
83 |
+
$this->_fault('data_invalid', $e->getMessage());
|
84 |
+
}
|
85 |
+
return $store->getId();
|
86 |
+
}
|
87 |
+
|
88 |
+
public function update($storeid, $storedata) {
|
89 |
+
try {
|
90 |
+
$store = Mage::getModel('core/store')
|
91 |
+
->load($storeid);
|
92 |
+
if (!$store->getId()) {
|
93 |
+
$this->_fault('store_not_exists');
|
94 |
+
}
|
95 |
+
$store->addData($storedata)->save();
|
96 |
+
} catch (Magento_Core_Exception $e) {
|
97 |
+
$this->_fault('data_invalid', $e->getMessage());
|
98 |
+
} catch (Exception $e) {
|
99 |
+
$this->_fault('data_invalid', $e->getMessage());
|
100 |
+
}
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
|
104 |
+
public function delete($storeid) {
|
105 |
+
try {
|
106 |
+
$store = Mage::getModel('core/store')
|
107 |
+
->load($storeid);
|
108 |
+
if (!$store->getId()) {
|
109 |
+
$this->_fault('store_not_exists');
|
110 |
+
}
|
111 |
+
$store->delete();
|
112 |
+
} catch (Magento_Core_Exception $e) {
|
113 |
+
$this->_fault('data_invalid', $e->getMessage());
|
114 |
+
} catch (Exception $e) {
|
115 |
+
$this->_fault('data_invalid', $e->getMessage());
|
116 |
+
}
|
117 |
+
return true;
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Oerpcore/Website.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
class ERPinCloud_Connector_Model_Oerpcore_Website extends Mage_Catalog_Model_Api_Resource {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Return the list of website ids which match the filters
|
12 |
+
*
|
13 |
+
* @param array $filters
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function search($filters) {
|
17 |
+
|
18 |
+
$collection = Mage::getModel('core/website')->getCollection();
|
19 |
+
|
20 |
+
if (is_array($filters)) {
|
21 |
+
try {
|
22 |
+
foreach ($filters as $field => $value) {
|
23 |
+
$collection->addFieldToFilter($field, $value);
|
24 |
+
}
|
25 |
+
} catch (Mage_Core_Exception $e) {
|
26 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
return $collection->getAllIds();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function items($filters = null) {
|
34 |
+
try {
|
35 |
+
$collection = Mage::getModel('core/website')->getCollection(); //->addAttributeToSelect('*');
|
36 |
+
} catch (Mage_Core_Exception $e) {
|
37 |
+
$this->_fault('store_not_exists');
|
38 |
+
}
|
39 |
+
|
40 |
+
if (is_array($filters)) {
|
41 |
+
try {
|
42 |
+
foreach ($filters as $field => $value) {
|
43 |
+
$collection->addFieldToFilter($field, $value);
|
44 |
+
}
|
45 |
+
} catch (Mage_Core_Exception $e) {
|
46 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
47 |
+
// If we are adding filter on non-existent attribute
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$result = array();
|
52 |
+
foreach ($collection as $customer) {
|
53 |
+
$result[] = $customer->toArray();
|
54 |
+
}
|
55 |
+
|
56 |
+
return $result;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function info($storeIds = null) {
|
60 |
+
$stores = array();
|
61 |
+
|
62 |
+
if (is_array($storeIds)) {
|
63 |
+
foreach ($storeIds as $storeId) {
|
64 |
+
try {
|
65 |
+
$stores[] = Mage::getModel('core/website')->load($storeId)->toArray();
|
66 |
+
} catch (Mage_Core_Exception $e) {
|
67 |
+
$this->_fault('store_not_exists');
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return $stores;
|
71 |
+
} elseif (is_numeric($storeIds)) {
|
72 |
+
try {
|
73 |
+
return Mage::getModel('core/website')->load($storeIds)->toArray();
|
74 |
+
} catch (Mage_Core_Exception $e) {
|
75 |
+
$this->_fault('store_not_exists');
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
//This is a protected function used by items & info for fetching website information
|
81 |
+
|
82 |
+
public function create($websitedata) {
|
83 |
+
try {
|
84 |
+
$website = Mage::getModel('core/website')
|
85 |
+
->setData($websitedata)
|
86 |
+
->save();
|
87 |
+
} catch (Magento_Core_Exception $e) {
|
88 |
+
$this->_fault('data_invalid', $e->getMessage());
|
89 |
+
} catch (Exception $e) {
|
90 |
+
$this->_fault('data_invalid', $e->getMessage());
|
91 |
+
}
|
92 |
+
return $website->getId();
|
93 |
+
}
|
94 |
+
|
95 |
+
public function update($websiteid, $websitedata) {
|
96 |
+
try {
|
97 |
+
$website = Mage::getModel('core/website')
|
98 |
+
->load($websiteid);
|
99 |
+
if (!$website->getId()) {
|
100 |
+
$this->_fault('website_not_exists');
|
101 |
+
}
|
102 |
+
$website->addData($websitedata)->save();
|
103 |
+
} catch (Magento_Core_Exception $e) {
|
104 |
+
$this->_fault('data_invalid', $e->getMessage());
|
105 |
+
} catch (Exception $e) {
|
106 |
+
$this->_fault('data_invalid', $e->getMessage());
|
107 |
+
}
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function delete($websiteid) {
|
112 |
+
try {
|
113 |
+
$website = Mage::getModel('core/website')
|
114 |
+
->load($websiteid);
|
115 |
+
if (!$website->getId()) {
|
116 |
+
$this->_fault('website_not_exists');
|
117 |
+
}
|
118 |
+
$website->delete();
|
119 |
+
} catch (Magento_Core_Exception $e) {
|
120 |
+
$this->_fault('data_invalid', $e->getMessage());
|
121 |
+
} catch (Exception $e) {
|
122 |
+
$this->_fault('data_invalid', $e->getMessage());
|
123 |
+
}
|
124 |
+
return true;
|
125 |
+
}
|
126 |
+
|
127 |
+
public function tree() {
|
128 |
+
$tree = array();
|
129 |
+
|
130 |
+
$websites = $this->websites();
|
131 |
+
|
132 |
+
foreach ($websites as $website) {
|
133 |
+
$groups = $this->groups($website['group_ids']);
|
134 |
+
$tree[$website['code']] = $website;
|
135 |
+
foreach ($groups as $group) {
|
136 |
+
$stores = $this->stores($group["store_ids"]);
|
137 |
+
|
138 |
+
$tree[$website['code']]['groups']['group_' . $group['group_id']] = $group;
|
139 |
+
|
140 |
+
foreach ($stores as $store) {
|
141 |
+
$tree[$website['code']]['groups']['group_' . $group['group_id']]['stores'][$store['code']] = $store;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
return $tree;
|
147 |
+
}
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Address.php
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Oerpcustomer_Address extends Mage_Customer_Model_Api_Resource {
|
4 |
+
|
5 |
+
protected $_mapAttributes = array(
|
6 |
+
'customer_id' => 'entity_id'
|
7 |
+
);
|
8 |
+
|
9 |
+
public function __construct() {
|
10 |
+
$this->_ignoredAttributeCodes[] = 'parent_id';
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Retrive customer addresses list
|
15 |
+
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function items($customerId) {
|
20 |
+
$customer = Mage::getModel('customer/customer')
|
21 |
+
->load($customerId);
|
22 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
23 |
+
|
24 |
+
if (!$customer->getId()) {
|
25 |
+
$this->_fault('customer_not_exists');
|
26 |
+
}
|
27 |
+
|
28 |
+
$result = array();
|
29 |
+
foreach ($customer->getAddresses() as $address) {
|
30 |
+
$data = $address->toArray();
|
31 |
+
$data['default_billing'] = $customer->getDefaultBilling() == $address->getId();
|
32 |
+
$data['default_shipping'] = $customer->getDefaultShipping() == $address->getId();
|
33 |
+
$result[] = $data;
|
34 |
+
/* $data = $address->toArray();
|
35 |
+
$row = array();
|
36 |
+
|
37 |
+
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
|
38 |
+
$row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null;
|
39 |
+
}
|
40 |
+
|
41 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
|
42 |
+
if (isset($data[$attributeCode])) {
|
43 |
+
$row[$attributeCode] = $data[$attributeCode];
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
$row['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId();
|
48 |
+
$row['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId();
|
49 |
+
|
50 |
+
$result[] = $row; */
|
51 |
+
}
|
52 |
+
|
53 |
+
return $result;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Create new address for customer
|
58 |
+
*
|
59 |
+
* @param int $customerId
|
60 |
+
* @param array $addressData
|
61 |
+
* @return int
|
62 |
+
*/
|
63 |
+
public function create($customerId, $addressData) {
|
64 |
+
$customer = Mage::getModel('customer/customer')
|
65 |
+
->load($customerId);
|
66 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
67 |
+
|
68 |
+
if (!$customer->getId()) {
|
69 |
+
$this->_fault('customer_not_exists');
|
70 |
+
}
|
71 |
+
|
72 |
+
$address = Mage::getModel('customer/address');
|
73 |
+
|
74 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
|
75 |
+
if (isset($addressData[$attributeCode])) {
|
76 |
+
$address->setData($attributeCode, $addressData[$attributeCode]);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
if (isset($addressData['is_default_billing'])) {
|
81 |
+
$address->setIsDefaultBilling($addressData['is_default_billing']);
|
82 |
+
}
|
83 |
+
|
84 |
+
if (isset($addressData['is_default_shipping'])) {
|
85 |
+
$address->setIsDefaultShipping($addressData['is_default_shipping']);
|
86 |
+
}
|
87 |
+
|
88 |
+
$address->setCustomerId($customer->getId());
|
89 |
+
|
90 |
+
$valid = $address->validate();
|
91 |
+
|
92 |
+
if (is_array($valid)) {
|
93 |
+
$this->_fault('data_invalid', implode("\n", $valid));
|
94 |
+
}
|
95 |
+
|
96 |
+
try {
|
97 |
+
$address->save();
|
98 |
+
} catch (Mage_Core_Exception $e) {
|
99 |
+
$this->_fault('data_invalid', $e->getMessage());
|
100 |
+
}
|
101 |
+
|
102 |
+
return $address->getId();
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Retrieve address data
|
107 |
+
*
|
108 |
+
* @param int $addressId
|
109 |
+
* @return array
|
110 |
+
*/
|
111 |
+
public function info($addressId) {
|
112 |
+
$address = Mage::getModel('customer/address')
|
113 |
+
->load($addressId);
|
114 |
+
|
115 |
+
if (!$address->getId()) {
|
116 |
+
$this->_fault('not_exists');
|
117 |
+
}
|
118 |
+
|
119 |
+
$result = array();
|
120 |
+
|
121 |
+
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
|
122 |
+
$result[$attributeAlias] = $address->getData($attributeCode);
|
123 |
+
}
|
124 |
+
|
125 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
|
126 |
+
$result[$attributeCode] = $address->getData($attributeCode);
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
if ($customer = $address->getCustomer()) {
|
131 |
+
$result['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId();
|
132 |
+
$result['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId();
|
133 |
+
}
|
134 |
+
|
135 |
+
return $result;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Update address data
|
140 |
+
*
|
141 |
+
* @param int $addressId
|
142 |
+
* @param array $addressData
|
143 |
+
* @return boolean
|
144 |
+
*/
|
145 |
+
public function update($addressId, $addressData) {
|
146 |
+
$address = Mage::getModel('customer/address')
|
147 |
+
->load($addressId);
|
148 |
+
|
149 |
+
if (!$address->getId()) {
|
150 |
+
$this->_fault('not_exists');
|
151 |
+
}
|
152 |
+
|
153 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
|
154 |
+
if (isset($addressData[$attributeCode])) {
|
155 |
+
$address->setData($attributeCode, $addressData[$attributeCode]);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
if (isset($addressData['is_default_billing'])) {
|
160 |
+
$address->setIsDefaultBilling($addressData['is_default_billing']);
|
161 |
+
}
|
162 |
+
|
163 |
+
if (isset($addressData['is_default_shipping'])) {
|
164 |
+
$address->setIsDefaultShipping($addressData['is_default_shipping']);
|
165 |
+
}
|
166 |
+
|
167 |
+
$valid = $address->validate();
|
168 |
+
if (is_array($valid)) {
|
169 |
+
$this->_fault('data_invalid', implode("\n", $valid));
|
170 |
+
}
|
171 |
+
|
172 |
+
try {
|
173 |
+
$address->save();
|
174 |
+
} catch (Mage_Core_Exception $e) {
|
175 |
+
$this->_fault('data_invalid', $e->getMessage());
|
176 |
+
}
|
177 |
+
|
178 |
+
return true;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Delete address
|
183 |
+
*
|
184 |
+
* @param int $addressId
|
185 |
+
* @return boolean
|
186 |
+
*/
|
187 |
+
public function delete($addressId) {
|
188 |
+
$address = Mage::getModel('customer/address')
|
189 |
+
->load($addressId);
|
190 |
+
|
191 |
+
if (!$address->getId()) {
|
192 |
+
$this->_fault('not_exists');
|
193 |
+
}
|
194 |
+
|
195 |
+
try {
|
196 |
+
$address->delete();
|
197 |
+
} catch (Mage_Core_Exception $e) {
|
198 |
+
$this->_fault('not_deleted', $e->getMessage());
|
199 |
+
}
|
200 |
+
|
201 |
+
return true;
|
202 |
+
}
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
// Class Mage_Customer_Model_Address_Api End
|
app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Customer.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Oerpcustomer_Customer extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
protected $_mapFilters = array(
|
6 |
+
'customer_id' => 'entity_id'
|
7 |
+
);
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Return the list of partner ids which match the filters
|
11 |
+
*
|
12 |
+
* @param array $filters
|
13 |
+
* @return array
|
14 |
+
*/
|
15 |
+
public function search($filters) {
|
16 |
+
|
17 |
+
$collection = Mage::getModel('customer/customer')->getCollection()
|
18 |
+
->addAttributeToSelect('*');
|
19 |
+
|
20 |
+
if (is_array($filters)) {
|
21 |
+
try {
|
22 |
+
foreach ($filters as $field => $value) {
|
23 |
+
if (isset($this->_mapFilters[$field])) {
|
24 |
+
$field = $this->_mapFilters[$field];
|
25 |
+
}
|
26 |
+
|
27 |
+
$collection->addFieldToFilter($field, $value);
|
28 |
+
}
|
29 |
+
} catch (Mage_Core_Exception $e) {
|
30 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
$result = array();
|
35 |
+
|
36 |
+
foreach ($collection as $product) {
|
37 |
+
$result[] = $product->getId();
|
38 |
+
}
|
39 |
+
|
40 |
+
return $result;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function items($filters = null) {
|
44 |
+
try {
|
45 |
+
$collection = Mage::getModel('customer/customer')->getCollection(); //->addAttributeToSelect('*');
|
46 |
+
} catch (Mage_Core_Exception $e) {
|
47 |
+
$this->_fault('customer_not_exists');
|
48 |
+
}
|
49 |
+
|
50 |
+
if (is_array($filters)) {
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
// If we are adding filter on non-existent attribute
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$result = array();
|
62 |
+
foreach ($collection as $customer) {
|
63 |
+
$result[] = $customer->toArray();
|
64 |
+
}
|
65 |
+
|
66 |
+
return $result;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function info($groupIds = null) {
|
70 |
+
$groups = array();
|
71 |
+
|
72 |
+
if (is_array($groupIds)) {
|
73 |
+
foreach ($groupIds as $groupId) {
|
74 |
+
try {
|
75 |
+
$groups[] = Mage::getModel('customer/customer')->load($groupId)->toArray();
|
76 |
+
} catch (Mage_Core_Exception $e) {
|
77 |
+
$this->_fault('customer_not_exists');
|
78 |
+
}
|
79 |
+
}
|
80 |
+
return $groups;
|
81 |
+
} elseif (is_numeric($groupIds)) {
|
82 |
+
try {
|
83 |
+
return Mage::getModel('customer/customer')->load($groupIds)->toArray();
|
84 |
+
} catch (Mage_Core_Exception $e) {
|
85 |
+
$this->_fault('customer_not_exists');
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
public function create($groupdata) {
|
91 |
+
try {
|
92 |
+
$group = Mage::getModel('customer/customer')
|
93 |
+
->setData($groupdata)
|
94 |
+
->save();
|
95 |
+
} catch (Magento_Core_Exception $e) {
|
96 |
+
$this->_fault('data_invalid', $e->getMessage());
|
97 |
+
} catch (Exception $e) {
|
98 |
+
$this->_fault('data_invalid', $e->getMessage());
|
99 |
+
}
|
100 |
+
return $group->getId();
|
101 |
+
}
|
102 |
+
|
103 |
+
public function update($groupid, $groupdata) {
|
104 |
+
try {
|
105 |
+
$group = Mage::getModel('customer/customer')
|
106 |
+
->load($groupid);
|
107 |
+
if (!$group->getId()) {
|
108 |
+
$this->_fault('customer_not_exists');
|
109 |
+
}
|
110 |
+
$group->addData($groupdata)->save();
|
111 |
+
} catch (Magento_Core_Exception $e) {
|
112 |
+
$this->_fault('data_invalid', $e->getMessage());
|
113 |
+
} catch (Exception $e) {
|
114 |
+
$this->_fault('data_invalid', $e->getMessage());
|
115 |
+
}
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
|
119 |
+
public function delete($groupid) {
|
120 |
+
try {
|
121 |
+
$group = Mage::getModel('customer/customer')
|
122 |
+
->load($groupid);
|
123 |
+
if (!$group->getId()) {
|
124 |
+
$this->_fault('customer_not_exists');
|
125 |
+
}
|
126 |
+
$group->delete();
|
127 |
+
} catch (Magento_Core_Exception $e) {
|
128 |
+
$this->_fault('data_invalid', $e->getMessage());
|
129 |
+
} catch (Exception $e) {
|
130 |
+
$this->_fault('data_invalid', $e->getMessage());
|
131 |
+
}
|
132 |
+
return true;
|
133 |
+
}
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Group.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Oerpcustomer_Group extends Mage_Catalog_Model_Api_Resource {
|
4 |
+
|
5 |
+
public function items($filters = null) {
|
6 |
+
try {
|
7 |
+
$collection = Mage::getModel('customer/group')->getCollection(); //->addAttributeToSelect('*');
|
8 |
+
} catch (Mage_Core_Exception $e) {
|
9 |
+
$this->_fault('group_not_exists');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (is_array($filters)) {
|
13 |
+
try {
|
14 |
+
foreach ($filters as $field => $value) {
|
15 |
+
$collection->addFieldToFilter($field, $value);
|
16 |
+
}
|
17 |
+
} catch (Mage_Core_Exception $e) {
|
18 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
19 |
+
// If we are adding filter on non-existent attribute
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
$result = array();
|
24 |
+
foreach ($collection as $customer) {
|
25 |
+
$result[] = $customer->toArray();
|
26 |
+
}
|
27 |
+
|
28 |
+
return $result;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function info($groupIds = null) {
|
32 |
+
$groups = array();
|
33 |
+
|
34 |
+
if (is_array($groupIds)) {
|
35 |
+
foreach ($groupIds as $groupId) {
|
36 |
+
try {
|
37 |
+
$groups[] = Mage::getModel('customer/group')->load($groupId)->toArray();
|
38 |
+
} catch (Mage_Core_Exception $e) {
|
39 |
+
$this->_fault('group_not_exists');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
return $groups;
|
43 |
+
} elseif (is_numeric($groupIds)) {
|
44 |
+
try {
|
45 |
+
return Mage::getModel('customer/group')->load($groupIds)->toArray();
|
46 |
+
} catch (Mage_Core_Exception $e) {
|
47 |
+
$this->_fault('group_not_exists');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
public function create($groupdata) {
|
53 |
+
try {
|
54 |
+
$group = Mage::getModel('customer/group')
|
55 |
+
->setData($groupdata)
|
56 |
+
->save();
|
57 |
+
} catch (Magento_Core_Exception $e) {
|
58 |
+
$this->_fault('data_invalid', $e->getMessage());
|
59 |
+
} catch (Exception $e) {
|
60 |
+
$this->_fault('data_invalid', $e->getMessage());
|
61 |
+
}
|
62 |
+
return $group->getId();
|
63 |
+
}
|
64 |
+
|
65 |
+
public function update($groupid, $groupdata) {
|
66 |
+
try {
|
67 |
+
$group = Mage::getModel('customer/group')
|
68 |
+
->load($groupid);
|
69 |
+
if (!$group->getId()) {
|
70 |
+
$this->_fault('group_not_exists');
|
71 |
+
}
|
72 |
+
$group->addData($groupdata)->save();
|
73 |
+
} catch (Magento_Core_Exception $e) {
|
74 |
+
$this->_fault('data_invalid', $e->getMessage());
|
75 |
+
} catch (Exception $e) {
|
76 |
+
$this->_fault('data_invalid', $e->getMessage());
|
77 |
+
}
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function delete($groupid) {
|
82 |
+
try {
|
83 |
+
$group = Mage::getModel('customer/group')
|
84 |
+
->load($groupid);
|
85 |
+
if (!$group->getId()) {
|
86 |
+
$this->_fault('group_not_exists');
|
87 |
+
}
|
88 |
+
$group->delete();
|
89 |
+
} catch (Magento_Core_Exception $e) {
|
90 |
+
$this->_fault('data_invalid', $e->getMessage());
|
91 |
+
} catch (Exception $e) {
|
92 |
+
$this->_fault('data_invalid', $e->getMessage());
|
93 |
+
}
|
94 |
+
return true;
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
?>
|
app/code/community/ERPinCloud/Connector/Model/Oerpcustomer/Subscriber.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_Model_Oerpcustomer_Subscriber extends Mage_Customer_Model_Api_Resource {
|
4 |
+
|
5 |
+
protected $_mapAttributes = array(
|
6 |
+
'customer_id' => 'entity_id'
|
7 |
+
);
|
8 |
+
|
9 |
+
public function __construct() {
|
10 |
+
$this->_ignoredAttributeCodes[] = 'parent_id';
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Retrive subscriber list
|
15 |
+
*
|
16 |
+
* @param int $filters
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function items($filters = null) {
|
20 |
+
$collection = Mage::getModel('customer/customer')->getCollection()
|
21 |
+
->addAttributeToSelect('*');
|
22 |
+
|
23 |
+
|
24 |
+
if (is_array($filters)) {
|
25 |
+
try {
|
26 |
+
foreach ($filters as $field => $value) {
|
27 |
+
$collection->addFieldToFilter($field, $value);
|
28 |
+
}
|
29 |
+
} catch (Mage_Core_Exception $e) {
|
30 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
31 |
+
// If we are adding filter on non-existent attribute
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
$result = array();
|
36 |
+
|
37 |
+
foreach ($collection as $customer) {
|
38 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']);
|
39 |
+
if ($subscriber->getId())
|
40 |
+
$result[] = $subscriber->getId();
|
41 |
+
}
|
42 |
+
|
43 |
+
return $result;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Create new address for customer
|
48 |
+
*
|
49 |
+
* @param int $customerId
|
50 |
+
* @param array $email
|
51 |
+
* @return int
|
52 |
+
*/
|
53 |
+
public function create($customerId, $email) {
|
54 |
+
|
55 |
+
if ($customerId && $email) {
|
56 |
+
$customer = Mage::getModel("newsletter/subscriber");
|
57 |
+
|
58 |
+
$customer->setCustomerId($customerId);
|
59 |
+
$customer->setEmail($email);
|
60 |
+
$customer->subscriber_status = "1";
|
61 |
+
|
62 |
+
$customer->save();
|
63 |
+
|
64 |
+
return $customer->getId();
|
65 |
+
}
|
66 |
+
return False;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Retrieve subscriber data
|
71 |
+
*
|
72 |
+
* @param int $subscriberId
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function info($subscriberId) {
|
76 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId);
|
77 |
+
|
78 |
+
if ($subscriber->getId()):
|
79 |
+
$result[
|
80 |
+
] = $subscriber->toArray(
|
81 |
+
);
|
82 |
+
endif;
|
83 |
+
|
84 |
+
return $result;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Update subscriber data (subscriber)
|
89 |
+
*
|
90 |
+
* @param $email
|
91 |
+
* @return boolean
|
92 |
+
*/
|
93 |
+
public function update($email) {
|
94 |
+
if ($email):
|
95 |
+
|
96 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
97 |
+
|
98 |
+
if ($subscriber->getId()):
|
99 |
+
$customer = Mage::getModel("newsletter/subscriber")->load($subscriber->getId());
|
100 |
+
$customer->subscriber_status = "1";
|
101 |
+
$customer->save();
|
102 |
+
endif;
|
103 |
+
|
104 |
+
return $subscriber->getId();
|
105 |
+
else:
|
106 |
+
return False;
|
107 |
+
endif;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Delete subscriber (unsubscriber)
|
112 |
+
*
|
113 |
+
* @param $email
|
114 |
+
* @return boolean
|
115 |
+
*/
|
116 |
+
public function delete($email) {
|
117 |
+
if ($email):
|
118 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
119 |
+
|
120 |
+
if ($subscriber->getId()):
|
121 |
+
Mage::getModel('newsletter/subscriber')->load($subscriber->getId())->unsubscribe();
|
122 |
+
endif;
|
123 |
+
|
124 |
+
return $subscriber->getId();
|
125 |
+
else:
|
126 |
+
return False;
|
127 |
+
endif;
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
// Class Mage_Customer_Model_Address_Api End
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
|
141 |
+
|
app/code/community/ERPinCloud/Connector/Model/Oerpstock/Item/Api.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
# -*- encoding: utf-8 -*-
|
4 |
+
###############################################################################
|
5 |
+
#
|
6 |
+
# Webservice extension for Magento
|
7 |
+
# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. All Rights Reserved
|
8 |
+
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
9 |
+
# This program is free software: you can redistribute it and/or modify
|
10 |
+
# it under the terms of the GNU Affero General Public License as
|
11 |
+
# published by the Free Software Foundation, either version 3 of the
|
12 |
+
# License, or (at your option) any later version.
|
13 |
+
#
|
14 |
+
# This program is distributed in the hope that it will be useful,
|
15 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
+
# GNU Affero General Public License for more details.
|
18 |
+
#
|
19 |
+
# You should have received a copy of the GNU Affero General Public License
|
20 |
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
#
|
22 |
+
###############################################################################
|
23 |
+
|
24 |
+
/* Inspired from http://www.sonassi.com/knowledge-base/magento-kb/mass-update-stock-levels-in-magento-fast/
|
25 |
+
*/
|
26 |
+
|
27 |
+
class ERPinCloud_Connector_Model_Oerpstock_item_api extends Mage_CatalogInventory_Model_Stock_Item_Api {
|
28 |
+
|
29 |
+
protected function _getProduct($productId, $store = null, $identifierType = 'id') {
|
30 |
+
$product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);
|
31 |
+
if (is_null($product->getId())) {
|
32 |
+
$this->_fault('product_not_exists');
|
33 |
+
}
|
34 |
+
return $product;
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function _updateStock($productId, $data) {
|
38 |
+
// test if product exist
|
39 |
+
$product = $this->_getProduct($productId);
|
40 |
+
|
41 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
42 |
+
$stockItemId = $stockItem->getId();
|
43 |
+
|
44 |
+
if (!$stockItemId) {
|
45 |
+
$stockItem->setData('product_id', $productId);
|
46 |
+
$stockItem->setData('stock_id', 1);
|
47 |
+
} else {
|
48 |
+
$stock = $stockItem->getData();
|
49 |
+
}
|
50 |
+
|
51 |
+
foreach ($data as $field => $value) {
|
52 |
+
$stockItem->setData($field, $value ? $value : 0);
|
53 |
+
}
|
54 |
+
|
55 |
+
$stockItem->save();
|
56 |
+
return true;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function update($productId, $data) {
|
60 |
+
return $this->_updateStock($productId, $data);
|
61 |
+
}
|
62 |
+
|
63 |
+
public function massive_update($datas) {
|
64 |
+
foreach ($datas as $productId => $data) {
|
65 |
+
$this->_updateStock($productId, $data);
|
66 |
+
}
|
67 |
+
return true;
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
// Class Mage_CatalogInventory_Model_Stock_Item_Api End
|
app/code/community/ERPinCloud/Connector/Model/Sales/Order/Api.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Mohammed NAHHAS
|
6 |
+
* @package ERPinCloud_Connector
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class ERPinCloud_Connector_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Return the list of products ids that match with the filter
|
13 |
+
* The filter imported is required
|
14 |
+
* @param array
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
public function search($data) {
|
18 |
+
$result = array();
|
19 |
+
if (isset($data['imported'])) {
|
20 |
+
|
21 |
+
$collection = Mage::getModel("sales/order")->getCollection()
|
22 |
+
->addAttributeToSelect('increment_id')
|
23 |
+
->addAttributeToFilter('imported', array('eq' => $data['imported']));
|
24 |
+
|
25 |
+
if (isset($data['limit'])) {
|
26 |
+
$collection->setPageSize($data['limit']);
|
27 |
+
$collection->setOrder('entity_id', 'ASC');
|
28 |
+
}
|
29 |
+
|
30 |
+
if (isset($data['filters']) && is_array($data['filters'])) {
|
31 |
+
$filters = $data['filters'];
|
32 |
+
foreach ($filters as $field => $value) {
|
33 |
+
$collection->addAttributeToFilter($field, $value);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
foreach ($collection as $order) {
|
37 |
+
$result[] = $order['increment_id'];
|
38 |
+
}
|
39 |
+
|
40 |
+
return $result;
|
41 |
+
} else {
|
42 |
+
$this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified");
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* Retrieve orders data based on the value of the flag 'imported'
|
49 |
+
* @param array
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function retrieveOrders($data) {
|
53 |
+
|
54 |
+
$result = array();
|
55 |
+
if (isset($data['imported'])) {
|
56 |
+
|
57 |
+
$collection = Mage::getModel("sales/order")->getCollection()
|
58 |
+
->addAttributeToSelect('*')
|
59 |
+
->addAttributeToFilter('imported', array('eq' => $data['imported']));
|
60 |
+
|
61 |
+
/* addAddressFields() is called only if version >= 1400 */
|
62 |
+
if (str_replace('.', '', Mage::getVersion()) >= 1400) {
|
63 |
+
$collection->addAddressFields();
|
64 |
+
}
|
65 |
+
|
66 |
+
if (isset($data['limit'])) {
|
67 |
+
$collection->setPageSize($data['limit']);
|
68 |
+
$collection->setOrder('entity_id', 'ASC');
|
69 |
+
}
|
70 |
+
|
71 |
+
if (isset($data['filters']) && is_array($data['filters'])) {
|
72 |
+
$filters = $data['filters'];
|
73 |
+
foreach ($filters as $field => $value) {
|
74 |
+
$collection->addAttributeToFilter($field, $value);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
foreach ($collection as $order) {
|
79 |
+
$tmp = $this->_getAttributes($order, 'order');
|
80 |
+
|
81 |
+
/* if version < 1400, billing and shipping information are added manually to order data */
|
82 |
+
if (str_replace('.', '', Mage::getVersion()) < 1400) {
|
83 |
+
$address_data = $this->_getAttributes($order->getShippingAddress(), 'order_address');
|
84 |
+
if (!empty($address_data)) {
|
85 |
+
$tmp['shipping_firstname'] = $address_data['firstname'];
|
86 |
+
$tmp['shipping_lastname'] = $address_data['lastname'];
|
87 |
+
}
|
88 |
+
|
89 |
+
$address_data = $this->_getAttributes($order->getBillingAddress(), 'order_address');
|
90 |
+
if (!empty($address_data)) {
|
91 |
+
$tmp['billing_firstname'] = $address_data['firstname'];
|
92 |
+
$tmp['billing_lastname'] = $address_data['lastname'];
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$result[] = $tmp;
|
97 |
+
}
|
98 |
+
return $result;
|
99 |
+
} else {
|
100 |
+
$this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified");
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
public function setFlagForOrder($incrementId) {
|
105 |
+
$_order = $this->_initOrder($incrementId);
|
106 |
+
$_order->setImported(1);
|
107 |
+
try {
|
108 |
+
$_order->save();
|
109 |
+
return true;
|
110 |
+
} catch (Mage_Core_Exception $e) {
|
111 |
+
$this->_fault('data_invalid', $e->getMessage());
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
/* Retrieve increment_id of the child order */
|
116 |
+
|
117 |
+
public function getOrderChild($incrementId) {
|
118 |
+
|
119 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
120 |
+
/**
|
121 |
+
* Check order existing
|
122 |
+
*/
|
123 |
+
if (!$order->getId()) {
|
124 |
+
$this->_fault('order_not_exists');
|
125 |
+
}
|
126 |
+
|
127 |
+
if ($order->getRelationChildId()) {
|
128 |
+
return $order->getRelationChildRealId();
|
129 |
+
} else {
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/* Retrieve increment_id of the parent order */
|
135 |
+
|
136 |
+
public function getOrderParent($incrementId) {
|
137 |
+
|
138 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
139 |
+
/**
|
140 |
+
* Check order existing
|
141 |
+
*/
|
142 |
+
if (!$order->getId()) {
|
143 |
+
$this->_fault('order_not_exists');
|
144 |
+
}
|
145 |
+
|
146 |
+
if ($order->getRelationParentId()) {
|
147 |
+
return $order->getRelationParentRealId();
|
148 |
+
} else {
|
149 |
+
return false;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/* Retrieve invoices increment ids of the order */
|
154 |
+
|
155 |
+
public function getInvoiceIds($incrementId) {
|
156 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
157 |
+
/**
|
158 |
+
* Check order existing
|
159 |
+
*/
|
160 |
+
if (!$order->getId()) {
|
161 |
+
$this->_fault('order_not_exists');
|
162 |
+
}
|
163 |
+
$res = array();
|
164 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
165 |
+
array_push($res, $invoice->getIncrementId());
|
166 |
+
};
|
167 |
+
return $res;
|
168 |
+
}
|
169 |
+
|
170 |
+
/* Retrieve shipment increment ids of the order */
|
171 |
+
|
172 |
+
public function getShipmentIds($incrementId) {
|
173 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
174 |
+
/**
|
175 |
+
* Check order existing
|
176 |
+
*/
|
177 |
+
if (!$order->getId()) {
|
178 |
+
$this->_fault('order_not_exists');
|
179 |
+
}
|
180 |
+
$res = array();
|
181 |
+
foreach ($order->getShipmentsCollection() as $shipping) {
|
182 |
+
array_push($res, $shipping->getIncrementId());
|
183 |
+
};
|
184 |
+
return $res;
|
185 |
+
}
|
186 |
+
|
187 |
+
}
|
app/code/community/ERPinCloud/Connector/controllers/Adminhtml/InitController.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Imran Bista
|
6 |
+
* @package ERPinCloud_Connector
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class ERPinCloud_Connector_Adminhtml_InitController extends Mage_Adminhtml_Controller_Action {
|
10 |
+
|
11 |
+
protected $_imported = 'imported';
|
12 |
+
|
13 |
+
/* Initialize the Attribute 'Imported' for orders placed before installing ERPinCloud_Connector Extension */
|
14 |
+
|
15 |
+
public function ordersAction() {
|
16 |
+
/* 'imported' value will be initialized if magento version is < 1.4.0.0 */
|
17 |
+
if (str_replace('.', '', Mage::getVersion()) < 1400) {
|
18 |
+
$orders = array();
|
19 |
+
|
20 |
+
/* 'imported' attribute values are stored in sales_order_int */
|
21 |
+
$imported_attribute_table_name = 'sales_order_int';
|
22 |
+
|
23 |
+
/* retrieve entity_type_id for order */
|
24 |
+
$entity_type = Mage::getModel('eav/entity_type')->loadByCode('order');
|
25 |
+
|
26 |
+
/* Load 'imported' attribute to get its attribute_id */
|
27 |
+
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
28 |
+
->setCodeFilter($this->_imported)
|
29 |
+
->setEntityTypeFilter($entity_type->getEntityTypeId())
|
30 |
+
->getFirstItem();
|
31 |
+
|
32 |
+
/* load order collection */
|
33 |
+
$collection = Mage::getResourceModel('sales/order_collection')
|
34 |
+
->addAttributeToSelect($this->_imported);
|
35 |
+
|
36 |
+
if (count($collection->getItems()) > 0) {
|
37 |
+
foreach ($collection as $order) {
|
38 |
+
try {
|
39 |
+
$test = $order->getResource()->getAttribute($this->_imported);
|
40 |
+
$orders[] = $order->getIncrementId();
|
41 |
+
$order->setImported(0)->save();
|
42 |
+
$request = "INSERT IGNORE INTO " . $imported_attribute_table_name . " (entity_type_id, attribute_id, entity_id, value) VALUES (" . $entity_type->getEntityTypeId() . ", " . $attributeInfo->getAttributeId() . ", " . $order->getEntityId() . ", 0)";
|
43 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
44 |
+
$query = $write->query($request);
|
45 |
+
} catch (Exception $e) {
|
46 |
+
echo 'Error : ' . $e->getMessage();
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
echo 'Number of Orders Initialized : ' . count($collection->getItems()) . '<br />';
|
51 |
+
echo 'Orders List : ' . '<br />';
|
52 |
+
echo '<pre>';
|
53 |
+
print_r($orders);
|
54 |
+
echo '</pre>';
|
55 |
+
}
|
56 |
+
} else {
|
57 |
+
echo 'Magento Version : ' . Mage::getVersion() . '<br />';
|
58 |
+
echo 'There is no need to initialize orders';
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
app/code/community/ERPinCloud/Connector/controllers/OpenerpsyncController.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ERPinCloud_Connector_OpenerpsyncController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
}
|
app/code/community/ERPinCloud/Connector/etc/api.xml
ADDED
@@ -0,0 +1,629 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<api>
|
3 |
+
<resources>
|
4 |
+
<eic_websites translate="title" module="core">
|
5 |
+
<title>Website Management</title>
|
6 |
+
<model>erpincloudconnector/oerpcore_website</model>
|
7 |
+
<acl>core/store</acl>
|
8 |
+
<methods>
|
9 |
+
<search translate="title" module="core">
|
10 |
+
<title>Return the list of website ids that match with the filter</title>
|
11 |
+
<method>search</method>
|
12 |
+
</search>
|
13 |
+
<list translate="title" module="core">
|
14 |
+
<title>Enumerate websites</title>
|
15 |
+
<method>items</method>
|
16 |
+
</list>
|
17 |
+
<create translate="title" module="core">
|
18 |
+
<title>Create Websites</title>
|
19 |
+
<!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
|
20 |
+
<method>create</method>
|
21 |
+
</create>
|
22 |
+
<info translate="title" module="core">
|
23 |
+
<title>Fetch detail of websites</title>
|
24 |
+
<method>info</method>
|
25 |
+
</info>
|
26 |
+
<update translate="title" module="core">
|
27 |
+
<title>Update websites info</title>
|
28 |
+
<method>update</method>
|
29 |
+
</update>
|
30 |
+
<delete translate="title" module="core">
|
31 |
+
<title>Delete websites</title>
|
32 |
+
<method>delete</method>
|
33 |
+
</delete>
|
34 |
+
</methods>
|
35 |
+
<faults module="core">
|
36 |
+
<website_not_exists>
|
37 |
+
<code>101</code>
|
38 |
+
<message>Requested website not found.</message>
|
39 |
+
</website_not_exists>
|
40 |
+
<data_invalid>
|
41 |
+
<code>102</code>
|
42 |
+
<message>Website creation failed due to invalid data.</message>
|
43 |
+
</data_invalid>
|
44 |
+
</faults>
|
45 |
+
</eic_websites>
|
46 |
+
<eic_groups translate="title" module="core">
|
47 |
+
<title>Groups Management</title>
|
48 |
+
<model>erpincloudconnector/oerpcore_groups</model>
|
49 |
+
<acl>core/store</acl>
|
50 |
+
<methods>
|
51 |
+
<search translate="title" module="core">
|
52 |
+
<title>Return the list of groups ids that match with the filter</title>
|
53 |
+
<method>search</method>
|
54 |
+
</search>
|
55 |
+
<list translate="title" module="core">
|
56 |
+
<title>Enumerate groups</title>
|
57 |
+
<method>items</method>
|
58 |
+
</list>
|
59 |
+
<create translate="title" module="core">
|
60 |
+
<title>Create groups</title>
|
61 |
+
<!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
|
62 |
+
<method>create</method>
|
63 |
+
</create>
|
64 |
+
<info translate="title" module="core">
|
65 |
+
<title>Fetch detail of groups</title>
|
66 |
+
<method>info</method>
|
67 |
+
</info>
|
68 |
+
<update translate="title" module="core">
|
69 |
+
<title>Update groups info</title>
|
70 |
+
<method>update</method>
|
71 |
+
</update>
|
72 |
+
<delete translate="title" module="core">
|
73 |
+
<title>Delete groups</title>
|
74 |
+
<method>delete</method>
|
75 |
+
</delete>
|
76 |
+
</methods>
|
77 |
+
<faults module="core">
|
78 |
+
<group_not_exists>
|
79 |
+
<code>101</code>
|
80 |
+
<message>Requested group not found.</message>
|
81 |
+
</group_not_exists>
|
82 |
+
<data_invalid>
|
83 |
+
<code>102</code>
|
84 |
+
<message>group creation failed due to invalid data.</message>
|
85 |
+
</data_invalid>
|
86 |
+
<filters_invalid>
|
87 |
+
<code>103</code>
|
88 |
+
<message>Invalid data fetch filter.</message>
|
89 |
+
</filters_invalid>
|
90 |
+
</faults>
|
91 |
+
</eic_groups>
|
92 |
+
<eic_storeviews translate="title" module="core">
|
93 |
+
<title>Stores Management</title>
|
94 |
+
<model>erpincloudconnector/oerpcore_storeviews</model>
|
95 |
+
<acl>core/store</acl>
|
96 |
+
<methods>
|
97 |
+
<search translate="title" module="core">
|
98 |
+
<title>Return the list of storeviews ids that match with the filter</title>
|
99 |
+
<method>search</method>
|
100 |
+
</search>
|
101 |
+
<list translate="title" module="core">
|
102 |
+
<title>Enumerate stores</title>
|
103 |
+
<method>items</method>
|
104 |
+
</list>
|
105 |
+
<create translate="title" module="core">
|
106 |
+
<title>Create stores</title>
|
107 |
+
<!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
|
108 |
+
<method>create</method>
|
109 |
+
</create>
|
110 |
+
<info translate="title" module="core">
|
111 |
+
<title>Fetch detail of stores</title>
|
112 |
+
<method>info</method>
|
113 |
+
</info>
|
114 |
+
<update translate="title" module="core">
|
115 |
+
<title>Update stores info</title>
|
116 |
+
<method>update</method>
|
117 |
+
</update>
|
118 |
+
<delete translate="title" module="core">
|
119 |
+
<title>Delete stores</title>
|
120 |
+
<method>delete</method>
|
121 |
+
</delete>
|
122 |
+
</methods>
|
123 |
+
<faults module="core">
|
124 |
+
<store_not_exists>
|
125 |
+
<code>101</code>
|
126 |
+
<message>Requested store not found.</message>
|
127 |
+
</store_not_exists>
|
128 |
+
<data_invalid>
|
129 |
+
<code>102</code>
|
130 |
+
<message>Store creation failed due to invalid data.</message>
|
131 |
+
</data_invalid>
|
132 |
+
<filters_invalid>
|
133 |
+
<code>103</code>
|
134 |
+
<message>Invalid data fetch filter.</message>
|
135 |
+
</filters_invalid>
|
136 |
+
</faults>
|
137 |
+
</eic_storeviews>
|
138 |
+
<eic_catalog_category_media translate="title" module="catalog">
|
139 |
+
<title>Product Images API</title>
|
140 |
+
<model>erpincloudconnector/catalog_categories</model>
|
141 |
+
<acl>catalog/category</acl>
|
142 |
+
<methods>
|
143 |
+
<list translate="title" module="catalog">
|
144 |
+
<title>Retrieve product image list</title>
|
145 |
+
<method>items</method>
|
146 |
+
</list>
|
147 |
+
<info translate="title" module="catalog">
|
148 |
+
<title>Retrieve product category image</title>
|
149 |
+
</info>
|
150 |
+
<types translate="title" module="catalog">
|
151 |
+
<title>Retrieve product category image types</title>
|
152 |
+
</types>
|
153 |
+
<create translate="title" module="catalog">
|
154 |
+
<title>Upload new product category image </title>
|
155 |
+
<acl>catalog/product/media/create</acl>
|
156 |
+
</create>
|
157 |
+
<update translate="title" module="catalog">
|
158 |
+
<title>Update product category image</title>
|
159 |
+
<acl>catalog/product/media/update</acl>
|
160 |
+
</update>
|
161 |
+
<remove translate="title" module="catalog">
|
162 |
+
<title>Remove product category image</title>
|
163 |
+
<acl>catalog/product/media/remove</acl>
|
164 |
+
</remove>
|
165 |
+
</methods>
|
166 |
+
<faults module="catalog">
|
167 |
+
<create_failure>
|
168 |
+
<code>100</code>
|
169 |
+
<message>Could not create file, check permissions.</message>
|
170 |
+
</create_failure>
|
171 |
+
<category_not_exists>
|
172 |
+
<code>101</code>
|
173 |
+
<message>Product not exists.</message>
|
174 |
+
</category_not_exists>
|
175 |
+
<data_invalid>
|
176 |
+
<code>102</code>
|
177 |
+
<message>Invalid data given. Details in error message.</message>
|
178 |
+
</data_invalid>
|
179 |
+
<not_exists>
|
180 |
+
<code>103</code>
|
181 |
+
<message>Requested image not exists in product images' gallery.</message>
|
182 |
+
</not_exists>
|
183 |
+
<not_created>
|
184 |
+
<code>104</code>
|
185 |
+
<message>Image creation failed. Details in error message.</message>
|
186 |
+
</not_created>
|
187 |
+
<not_updated>
|
188 |
+
<code>105</code>
|
189 |
+
<message>Image not updated. Details in error message.</message>
|
190 |
+
</not_updated>
|
191 |
+
<not_removed>
|
192 |
+
<code>106</code>
|
193 |
+
<message>Image not removed. Details in error message.</message>
|
194 |
+
</not_removed>
|
195 |
+
<not_media>
|
196 |
+
<code>107</code>
|
197 |
+
<message>Error in opening image file</message>
|
198 |
+
</not_media>
|
199 |
+
<filters_invalid>
|
200 |
+
<code>108</code>
|
201 |
+
<message>Invalid data fetch filter.</message>
|
202 |
+
</filters_invalid>
|
203 |
+
</faults>
|
204 |
+
</eic_catalog_category_media>
|
205 |
+
<eic_catalog_product_attribute translate="title" module="catalog">
|
206 |
+
<title>Product Images API</title>
|
207 |
+
<model>erpincloudconnector/catalog_product_attribute</model>
|
208 |
+
<acl>catalog/category</acl>
|
209 |
+
<methods>
|
210 |
+
<list translate="title" module="catalog">
|
211 |
+
<title>Retrieve attribute list</title>
|
212 |
+
<method>items</method>
|
213 |
+
</list>
|
214 |
+
<relations translate="title" module="catalog">
|
215 |
+
<title>Retrieve attribute sets attribute ids</title>
|
216 |
+
<method>relations</method>
|
217 |
+
</relations>
|
218 |
+
<info translate="title" module="catalog">
|
219 |
+
<title>Retrieve full attribute details</title>
|
220 |
+
<method>info</method>
|
221 |
+
</info>
|
222 |
+
<options translate="title" module="catalog">
|
223 |
+
<title>Retrieve options of attributes</title>
|
224 |
+
<method>options</method>
|
225 |
+
</options>
|
226 |
+
</methods>
|
227 |
+
<faults>
|
228 |
+
</faults>
|
229 |
+
</eic_catalog_product_attribute>
|
230 |
+
<eic_catalog_product_attribute_group translate="title" module="catalog">
|
231 |
+
<title>Product Images API</title>
|
232 |
+
<model>erpincloudconnector/catalog_product_attributegroup</model>
|
233 |
+
<acl>catalog/category</acl>
|
234 |
+
<methods>
|
235 |
+
<list translate="title" module="catalog">
|
236 |
+
<title>Retrieve attribute group list</title>
|
237 |
+
<method>items</method>
|
238 |
+
</list>
|
239 |
+
<info translate="title" module="catalog">
|
240 |
+
<title>Retrieve full attribute details</title>
|
241 |
+
<method>info</method>
|
242 |
+
</info>
|
243 |
+
</methods>
|
244 |
+
<faults>
|
245 |
+
</faults>
|
246 |
+
</eic_catalog_product_attribute_group>
|
247 |
+
<eic_customer_groups translate="title" module="core">
|
248 |
+
<title>Groups Management</title>
|
249 |
+
<model>erpincloudconnector/oerpcustomer_group</model>
|
250 |
+
<acl>customer/group</acl>
|
251 |
+
<methods>
|
252 |
+
<list translate="title" module="core">
|
253 |
+
<title>Enumerate groups</title>
|
254 |
+
<method>items</method>
|
255 |
+
</list>
|
256 |
+
<create translate="title" module="core">
|
257 |
+
<title>Create groups</title>
|
258 |
+
<method>create</method>
|
259 |
+
</create>
|
260 |
+
<info translate="title" module="core">
|
261 |
+
<title>Fetch detail of groups</title>
|
262 |
+
<method>info</method>
|
263 |
+
</info>
|
264 |
+
<update translate="title" module="core">
|
265 |
+
<title>Update groups info</title>
|
266 |
+
<method>update</method>
|
267 |
+
</update>
|
268 |
+
<delete translate="title" module="core">
|
269 |
+
<title>Delete groups</title>
|
270 |
+
<method>delete</method>
|
271 |
+
</delete>
|
272 |
+
</methods>
|
273 |
+
<faults module="core">
|
274 |
+
<group_not_exists>
|
275 |
+
<code>101</code>
|
276 |
+
<message>Requested group not found.</message>
|
277 |
+
</group_not_exists>
|
278 |
+
<data_invalid>
|
279 |
+
<code>102</code>
|
280 |
+
<message>group creation failed due to invalid data.</message>
|
281 |
+
</data_invalid>
|
282 |
+
<filters_invalid>
|
283 |
+
<code>103</code>
|
284 |
+
<message>Invalid data fetch filter.</message>
|
285 |
+
</filters_invalid>
|
286 |
+
</faults>
|
287 |
+
</eic_customer_groups>
|
288 |
+
<eic_customer_address translate="title" module="core">
|
289 |
+
<title>Address Management</title>
|
290 |
+
<model>erpincloudconnector/oerpcustomer_address</model>
|
291 |
+
<acl>customer/group</acl>
|
292 |
+
<methods>
|
293 |
+
<list translate="title" module="core">
|
294 |
+
<title>Enumerate groups</title>
|
295 |
+
<method>items</method>
|
296 |
+
</list>
|
297 |
+
<create translate="title" module="core">
|
298 |
+
<title>Create groups</title>
|
299 |
+
<method>create</method>
|
300 |
+
</create>
|
301 |
+
<info translate="title" module="core">
|
302 |
+
<title>Fetch detail of groups</title>
|
303 |
+
<method>info</method>
|
304 |
+
</info>
|
305 |
+
<update translate="title" module="core">
|
306 |
+
<title>Update groups info</title>
|
307 |
+
<method>update</method>
|
308 |
+
</update>
|
309 |
+
<delete translate="title" module="core">
|
310 |
+
<title>Delete groups</title>
|
311 |
+
<method>delete</method>
|
312 |
+
</delete>
|
313 |
+
</methods>
|
314 |
+
<faults module="core">
|
315 |
+
<customer_not_exists>
|
316 |
+
<code>101</code>
|
317 |
+
<message>Requested Customer not found.</message>
|
318 |
+
</customer_not_exists>
|
319 |
+
<data_invalid>
|
320 |
+
<code>102</code>
|
321 |
+
<message>group creation failed due to invalid data.</message>
|
322 |
+
</data_invalid>
|
323 |
+
<filters_invalid>
|
324 |
+
<code>103</code>
|
325 |
+
<message>Invalid data fetch filter.</message>
|
326 |
+
</filters_invalid>
|
327 |
+
</faults>
|
328 |
+
</eic_customer_address>
|
329 |
+
<eic_customer_subscriber translate="title" module="core">
|
330 |
+
<title>Subscriber Management</title>
|
331 |
+
<model>erpincloudconnector/oerpcustomer_subscriber</model>
|
332 |
+
<acl>customer/group</acl>
|
333 |
+
<methods>
|
334 |
+
<list translate="title" module="core">
|
335 |
+
<title>Enumerate subscriber</title>
|
336 |
+
<method>items</method>
|
337 |
+
</list>
|
338 |
+
<create translate="title" module="core">
|
339 |
+
<title>Create subscriber</title>
|
340 |
+
<method>create</method>
|
341 |
+
</create>
|
342 |
+
<info translate="title" module="core">
|
343 |
+
<title>Fetch detail of subscriber</title>
|
344 |
+
<method>info</method>
|
345 |
+
</info>
|
346 |
+
<update translate="title" module="core">
|
347 |
+
<title>Update subscriber info</title>
|
348 |
+
<method>update</method>
|
349 |
+
</update>
|
350 |
+
<delete translate="title" module="core">
|
351 |
+
<title>Delete subscriber</title>
|
352 |
+
<method>delete</method>
|
353 |
+
</delete>
|
354 |
+
</methods>
|
355 |
+
<faults module="core">
|
356 |
+
<customer_not_exists>
|
357 |
+
<code>101</code>
|
358 |
+
<message>Requested Customer not found.</message>
|
359 |
+
</customer_not_exists>
|
360 |
+
<data_invalid>
|
361 |
+
<code>102</code>
|
362 |
+
<message>group creation failed due to invalid data.</message>
|
363 |
+
</data_invalid>
|
364 |
+
<filters_invalid>
|
365 |
+
<code>103</code>
|
366 |
+
<message>Invalid data fetch filter.</message>
|
367 |
+
</filters_invalid>
|
368 |
+
</faults>
|
369 |
+
</eic_customer_subscriber>
|
370 |
+
<eic_customer translate="title" module="core">
|
371 |
+
<title>Customers Management</title>
|
372 |
+
<model>erpincloudconnector/oerpcustomer_customer</model>
|
373 |
+
<acl>customer/group</acl>
|
374 |
+
<methods>
|
375 |
+
<search translate="title" module="core">
|
376 |
+
<title>Return the list of customer ids that match with the filter</title>
|
377 |
+
<method>search</method>
|
378 |
+
</search>
|
379 |
+
<list translate="title" module="core">
|
380 |
+
<title>Enumerate Customers</title>
|
381 |
+
<method>items</method>
|
382 |
+
</list>
|
383 |
+
<create translate="title" module="core">
|
384 |
+
<title>Create Customers</title>
|
385 |
+
<method>create</method>
|
386 |
+
</create>
|
387 |
+
<info translate="title" module="core">
|
388 |
+
<title>Fetch detail of customers</title>
|
389 |
+
<method>info</method>
|
390 |
+
</info>
|
391 |
+
<update translate="title" module="core">
|
392 |
+
<title>Update customers info</title>
|
393 |
+
<method>update</method>
|
394 |
+
</update>
|
395 |
+
<delete translate="title" module="core">
|
396 |
+
<title>Delete customers</title>
|
397 |
+
<method>delete</method>
|
398 |
+
</delete>
|
399 |
+
</methods>
|
400 |
+
<faults module="core">
|
401 |
+
<customer_not_exists>
|
402 |
+
<code>101</code>
|
403 |
+
<message>Requested customer not found.</message>
|
404 |
+
</customer_not_exists>
|
405 |
+
<data_invalid>
|
406 |
+
<code>102</code>
|
407 |
+
<message>Customer creation failed due to invalid data.</message>
|
408 |
+
</data_invalid>
|
409 |
+
<filters_invalid>
|
410 |
+
<code>103</code>
|
411 |
+
<message>Invalid data fetch filter.</message>
|
412 |
+
</filters_invalid>
|
413 |
+
</faults>
|
414 |
+
</eic_customer>
|
415 |
+
<eic_catalog_product_tierprice translate="title" module="catalog">
|
416 |
+
<title>Product Tier Price API</title>
|
417 |
+
<model>erpincloudconnector/catalog_product_tierprice</model>
|
418 |
+
<acl>catalog/category</acl>
|
419 |
+
<methods>
|
420 |
+
<list translate="title" module="catalog">
|
421 |
+
<title>Retrieve attribute list</title>
|
422 |
+
<method>items</method>
|
423 |
+
</list>
|
424 |
+
<items2 translate="title" module="catalog">
|
425 |
+
<title>Retrieve attribute list</title>
|
426 |
+
<method>items2</method>
|
427 |
+
</items2>
|
428 |
+
</methods>
|
429 |
+
<faults>
|
430 |
+
<product_not_exists>
|
431 |
+
<code>101</code>
|
432 |
+
<message>Requested product not found.</message>
|
433 |
+
</product_not_exists>
|
434 |
+
<filters_invalid>
|
435 |
+
<code>103</code>
|
436 |
+
<message>Invalid data fetch filter.</message>
|
437 |
+
</filters_invalid>
|
438 |
+
</faults>
|
439 |
+
</eic_catalog_product_tierprice>
|
440 |
+
<eic_catalog_product translate="title" module="core">
|
441 |
+
<title>Address Management</title>
|
442 |
+
<model>erpincloudconnector/catalog_products</model>
|
443 |
+
<acl>catalog/product</acl>
|
444 |
+
<methods>
|
445 |
+
<search translate="title" module="core">
|
446 |
+
<title>Return the list of products ids that match with the filter</title>
|
447 |
+
<method>search</method>
|
448 |
+
</search>
|
449 |
+
<list translate="title" module="core">
|
450 |
+
<title>Enumerate Products</title>
|
451 |
+
<method>items</method>
|
452 |
+
</list>
|
453 |
+
<create translate="title" module="core">
|
454 |
+
<title>Create Products</title>
|
455 |
+
<method>create</method>
|
456 |
+
</create>
|
457 |
+
<biglist translate="title" module="core">
|
458 |
+
<title>Fetch detail of products</title>
|
459 |
+
<method>biglist</method>
|
460 |
+
</biglist>
|
461 |
+
<update translate="title" module="core">
|
462 |
+
<title>Update groups info</title>
|
463 |
+
<method>update</method>
|
464 |
+
</update>
|
465 |
+
<delete translate="title" module="core">
|
466 |
+
<title>Delete groups</title>
|
467 |
+
<method>delete</method>
|
468 |
+
</delete>
|
469 |
+
</methods>
|
470 |
+
<faults module="core">
|
471 |
+
<customer_not_exists>
|
472 |
+
<code>101</code>
|
473 |
+
<message>Requested Customer not found.</message>
|
474 |
+
</customer_not_exists>
|
475 |
+
<data_invalid>
|
476 |
+
<code>102</code>
|
477 |
+
<message>group creation failed due to invalid data.</message>
|
478 |
+
</data_invalid>
|
479 |
+
<filters_invalid>
|
480 |
+
<code>103</code>
|
481 |
+
<message>Invalid data fetch filter.</message>
|
482 |
+
</filters_invalid>
|
483 |
+
</faults>
|
484 |
+
</eic_catalog_product>
|
485 |
+
<eic_catalog_product_attributeset translate="title" module="core">
|
486 |
+
<title>Attribute Set Management</title>
|
487 |
+
<model>erpincloudconnector/catalog_product_attributeset</model>
|
488 |
+
<acl>catalog/product</acl>
|
489 |
+
<methods>
|
490 |
+
<list translate="title" module="core">
|
491 |
+
<title>Enumerate Attribute sets</title>
|
492 |
+
<method>items</method>
|
493 |
+
</list>
|
494 |
+
</methods>
|
495 |
+
<faults module="core">
|
496 |
+
<customer_not_exists>
|
497 |
+
<code>101</code>
|
498 |
+
<message>Requested Customer not found.</message>
|
499 |
+
</customer_not_exists>
|
500 |
+
<data_invalid>
|
501 |
+
<code>102</code>
|
502 |
+
<message>group creation failed due to invalid data.</message>
|
503 |
+
</data_invalid>
|
504 |
+
<filters_invalid>
|
505 |
+
<code>103</code>
|
506 |
+
<message>Invalid data fetch filter.</message>
|
507 |
+
</filters_invalid>
|
508 |
+
</faults>
|
509 |
+
</eic_catalog_product_attributeset>
|
510 |
+
<eic_catalog_product_link>
|
511 |
+
<title>Product Link</title>
|
512 |
+
<model>erpincloudconnector/catalog_product_link</model>
|
513 |
+
<acl>catalog/product</acl>
|
514 |
+
<methods>
|
515 |
+
<list translate="title" module="core">
|
516 |
+
<title>Enumerate configurable Products</title>
|
517 |
+
<method>items</method>
|
518 |
+
</list>
|
519 |
+
<assign translate="title" module="catalog">
|
520 |
+
<title>Assign simple product in configurable product</title>
|
521 |
+
</assign>
|
522 |
+
<remove translate="title" module="catalog">
|
523 |
+
<title>Remove simple products in configurable product</title>
|
524 |
+
</remove>
|
525 |
+
<listSuperAttributes translate="title" module="catalog">
|
526 |
+
<title>Get configurable attribute values for a configurable product</title>
|
527 |
+
</listSuperAttributes>
|
528 |
+
<createSuperAttribute translate="title" module="catalog">
|
529 |
+
<title>Create configurable attribute for a configurable product</title>
|
530 |
+
</createSuperAttribute>
|
531 |
+
<removeSuperAttribute translate="title" module="catalog">
|
532 |
+
<title>Remove super attribute</title>
|
533 |
+
</removeSuperAttribute>
|
534 |
+
<setSuperAttributeValues translate="title" module="catalog">
|
535 |
+
<title>Set configurable attribute values for super attribute</title>
|
536 |
+
</setSuperAttributeValues>
|
537 |
+
</methods>
|
538 |
+
</eic_catalog_product_link>
|
539 |
+
<sales_order translate="title" module="connector">
|
540 |
+
<model>sales/order_api</model>
|
541 |
+
<title>Custom Sales Orders API</title>
|
542 |
+
<methods>
|
543 |
+
<search translate="title" module="connector">
|
544 |
+
<title>Return the list of products ids that match with the filter</title>
|
545 |
+
<method>search</method>
|
546 |
+
</search>
|
547 |
+
<retrieve translate="title" module="connector">
|
548 |
+
<title>Retrieve list of orders by filters, nb max, etc...</title>
|
549 |
+
<method>retrieveOrders</method>
|
550 |
+
</retrieve>
|
551 |
+
<done translate="title" module="connector">
|
552 |
+
<title>Set Flag to TRUE for imported orders</title>
|
553 |
+
<method>setFlagForOrder</method>
|
554 |
+
</done>
|
555 |
+
<get_child translate="title" module="connector">
|
556 |
+
<title>get The Child of The Order Edited</title>
|
557 |
+
<method>getOrderChild</method>
|
558 |
+
</get_child>
|
559 |
+
<get_parent translate="title" module="connector">
|
560 |
+
<title>get The Parent of the order annulated</title>
|
561 |
+
<method>getOrderParent</method>
|
562 |
+
</get_parent>
|
563 |
+
<get_invoice_ids translate="title" module="connector">
|
564 |
+
<title>get The Invoices Increment ids of the order</title>
|
565 |
+
<method>getInvoiceIds</method>
|
566 |
+
</get_invoice_ids>
|
567 |
+
<get_shipment_ids translate="title" module="connector">
|
568 |
+
<title>get The Shipment Increment ids of the order</title>
|
569 |
+
<method>getShipmentIds</method>
|
570 |
+
</get_shipment_ids>
|
571 |
+
</methods>
|
572 |
+
</sales_order>
|
573 |
+
<catalog_product translate="title" module="catalog">
|
574 |
+
<title>Product API</title>
|
575 |
+
<model>catalog/product_api</model>
|
576 |
+
<acl>catalog/product</acl>
|
577 |
+
<methods>
|
578 |
+
<create_bundle translate="title" module="connector">
|
579 |
+
<title>Create Bundle Products with Custom Options and Bundle Items</title>
|
580 |
+
<method>createBundleProducts</method>
|
581 |
+
</create_bundle>
|
582 |
+
</methods>
|
583 |
+
</catalog_product>
|
584 |
+
<oerp_catalog_category translate="title" module="connector">
|
585 |
+
<title>Product Category API</title>
|
586 |
+
<model>erpincloudconnector/oerpcatalog_category_api</model>
|
587 |
+
<acl>catalog/category/move</acl>
|
588 |
+
<methods>
|
589 |
+
<search translate="title" module="core">
|
590 |
+
<title>Return the list of product category ids that match with the filter</title>
|
591 |
+
<method>search</method>
|
592 |
+
</search>
|
593 |
+
<move translate="title" module="connector">
|
594 |
+
<title>Move category in tree</title>
|
595 |
+
<method>move</method>
|
596 |
+
</move>
|
597 |
+
</methods>
|
598 |
+
</oerp_catalog_category>
|
599 |
+
|
600 |
+
<oerp_cataloginventory_stock_item translate="title" module="connector">
|
601 |
+
<model>erpincloudconnector/oerpstock_item_api</model>
|
602 |
+
<title>Inventory API</title>
|
603 |
+
<acl>cataloginventory</acl>
|
604 |
+
<methods>
|
605 |
+
<update translate="title" module="connector">
|
606 |
+
<title>Update product stock data</title>
|
607 |
+
<acl>cataloginventory/update</acl>
|
608 |
+
<method>update</method>
|
609 |
+
</update>
|
610 |
+
<massive_update translate="title" module="connector">
|
611 |
+
<title>Massive Update product stock data</title>
|
612 |
+
<acl>cataloginventory/update</acl>
|
613 |
+
<method>massive_update</method>
|
614 |
+
</massive_update>
|
615 |
+
</methods>
|
616 |
+
<faults module="cataloginventory">
|
617 |
+
<product_not_exists>
|
618 |
+
<code>101</code>
|
619 |
+
<message>Product not exists.</message>
|
620 |
+
</product_not_exists>
|
621 |
+
<not_updated>
|
622 |
+
<code>102</code>
|
623 |
+
<message>Product inventory not updated. Details in error message.</message>
|
624 |
+
</not_updated>
|
625 |
+
</faults>
|
626 |
+
</oerp_cataloginventory_stock_item>
|
627 |
+
</resources>
|
628 |
+
</api>
|
629 |
+
</config>
|
app/code/community/ERPinCloud/Connector/etc/config.xml
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ERPinCloud_Connector>
|
5 |
+
<version>2.1.2</version>
|
6 |
+
</ERPinCloud_Connector>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<erpincloudconnector>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>ERPinCloud_Connector</module>
|
14 |
+
<frontName>openerpsync</frontName>
|
15 |
+
</args>
|
16 |
+
</erpincloudconnector>
|
17 |
+
</routers>
|
18 |
+
</frontend>
|
19 |
+
<global>
|
20 |
+
<models>
|
21 |
+
<erpincloudconnector>
|
22 |
+
<class>ERPinCloud_Connector_Model</class>
|
23 |
+
</erpincloudconnector>
|
24 |
+
<sales>
|
25 |
+
<rewrite>
|
26 |
+
<order_api>ERPinCloud_Connector_Model_Sales_Order_Api</order_api>
|
27 |
+
</rewrite>
|
28 |
+
</sales>
|
29 |
+
<catalog>
|
30 |
+
<rewrite>
|
31 |
+
<product_api>ERPinCloud_Connector_Model_Catalog_Product_Api</product_api>
|
32 |
+
</rewrite>
|
33 |
+
<rewrite>
|
34 |
+
<category_api>ERPinCloud_Connector_Model_Catalog_Category_Api</category_api>
|
35 |
+
</rewrite>
|
36 |
+
</catalog>
|
37 |
+
</models>
|
38 |
+
<resources>
|
39 |
+
<erpincloudconnector_setup>
|
40 |
+
<setup>
|
41 |
+
<module>ERPinCloud_Connector</module>
|
42 |
+
</setup>
|
43 |
+
<connection>
|
44 |
+
<use>core_setup</use>
|
45 |
+
</connection>
|
46 |
+
</erpincloudconnector_setup>
|
47 |
+
<erpincloudconnector_write>
|
48 |
+
<connection>
|
49 |
+
<use>core_write</use>
|
50 |
+
</connection>
|
51 |
+
</erpincloudconnector_write>
|
52 |
+
<erpincloudconnector_read>
|
53 |
+
<connection>
|
54 |
+
<use>core_read</use>
|
55 |
+
</connection>
|
56 |
+
</erpincloudconnector_read>
|
57 |
+
</resources>
|
58 |
+
<blocks>
|
59 |
+
<erpincloudconnector>
|
60 |
+
<class>ERPinCloud_Connector_Block</class>
|
61 |
+
</erpincloudconnector>
|
62 |
+
</blocks>
|
63 |
+
<helpers>
|
64 |
+
<erpincloudconnector>
|
65 |
+
<class>ERPinCloud_Connector_Helper</class>
|
66 |
+
</erpincloudconnector>
|
67 |
+
</helpers>
|
68 |
+
<events>
|
69 |
+
<sales_order_place_after>
|
70 |
+
<observers>
|
71 |
+
<init_imported_after_place_order>
|
72 |
+
<type>singleton</type>
|
73 |
+
<class>connector/observer</class>
|
74 |
+
<method>initImported</method>
|
75 |
+
</init_imported_after_place_order>
|
76 |
+
</observers>
|
77 |
+
</sales_order_place_after>
|
78 |
+
</events>
|
79 |
+
</global>
|
80 |
+
<admin>
|
81 |
+
<routers>
|
82 |
+
<erpincloudconnector>
|
83 |
+
<use>admin</use>
|
84 |
+
<args>
|
85 |
+
<module>ERPinCloud_Connector</module>
|
86 |
+
<frontName>connector</frontName>
|
87 |
+
</args>
|
88 |
+
</erpincloudconnector>
|
89 |
+
</routers>
|
90 |
+
</admin>
|
91 |
+
</config>
|
app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Mohammed NAHHAS
|
6 |
+
* @package ERPinCloud_Connector
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
/* Retrieve the version of Magento */
|
10 |
+
$version = Mage::getVersion();
|
11 |
+
|
12 |
+
/* Need to add a sales_order attribute if the version < 1.4.x.x - sales_order is an EAV Model */
|
13 |
+
/* Else add a simple column to sales_flat_order Table */
|
14 |
+
$version = str_replace('.', '', $version);
|
15 |
+
if ($version >= 1400) {
|
16 |
+
$installer = $this;
|
17 |
+
$installer->startSetup();
|
18 |
+
$tableName = 'sales_flat_order';
|
19 |
+
$db = $installer->getConnection();
|
20 |
+
|
21 |
+
/* Delete the column if it exists before re-create it */
|
22 |
+
if ($db->tableColumnExists($this->getTable($tableName), 'imported')) {
|
23 |
+
$installer->run("ALTER TABLE {$this->getTable($tableName)} drop column imported");
|
24 |
+
}
|
25 |
+
|
26 |
+
/* re-create 'imported' column */
|
27 |
+
if (!$db->tableColumnExists($this->getTable($tableName), 'imported')) {
|
28 |
+
$installer->run("
|
29 |
+
ALTER TABLE {$this->getTable($tableName)} ADD imported tinyint(1) unsigned NOT NULL default '0';
|
30 |
+
");
|
31 |
+
}
|
32 |
+
} else {
|
33 |
+
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
|
34 |
+
$installer->startSetup();
|
35 |
+
|
36 |
+
/* Attribute Data */
|
37 |
+
$attribute_data = array(
|
38 |
+
'type' => 'int',
|
39 |
+
'default' => 0,
|
40 |
+
'visible' => false,
|
41 |
+
'required' => false,
|
42 |
+
'user_defined' => false,
|
43 |
+
'searchable' => false,
|
44 |
+
'filterable' => false,
|
45 |
+
'comparable' => false
|
46 |
+
);
|
47 |
+
/* Add a sales_order attribute named 'imported' */
|
48 |
+
$installer->addAttribute('order', 'imported', $attribute_data);
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/* End */
|
53 |
+
$installer->endSetup();
|
app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-0.0.1-2.0.0.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->endSetup();
|
5 |
+
?>
|
app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-2.0.0-2.1.0.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->endSetup();
|
5 |
+
?>
|
app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-2.1.0-2.1.1.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->endSetup();
|
5 |
+
?>
|
app/code/community/ERPinCloud/Connector/sql/erpincloudconnector_setup/mysql4-upgrade-2.1.1-2.1.2.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->endSetup();
|
5 |
+
?>
|
app/etc/modules/ERPinCloud_Connector.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ERPinCloud_Connector>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</ERPinCloud_Connector>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>ERPinCloudConnector</name>
|
4 |
+
<version>2.1.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>ERPinCloud Connector</summary>
|
10 |
+
<description>ERPinCloud Connector</description>
|
11 |
+
<notes>ERPinCloud Connector</notes>
|
12 |
+
<authors><author><name>Team ERPInCloud</name><user>teameic</user><email>sales@erpincloud.com</email></author></authors>
|
13 |
+
<date>2014-09-23</date>
|
14 |
+
<time>10:46:09</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="ERPinCloud"><dir name="Connector"><dir name="controllers"><dir name="Adminhtml"><file name="InitController.php" hash="0c33cbb19dff407d42bac6ae3bcf1603"/></dir><file name="OpenerpsyncController.php" hash="bb16d769e95d4b266f50a22d4600f4a1"/></dir><dir name="etc"><file name="api.xml" hash="42cc140b563cf220de889101d904f9fd"/><file name="config.xml" hash="6f96b2a3646e3b345ebdbf2c0ce34828"/></dir><dir name="Helper"><file name="Data.php" hash="ee0825f5a4dc63493dda423db76a1337"/></dir><dir name="Model"><dir name="Catalog"><file name="Categories.php" hash="58de667fc289d97e542d35b64bafa9b1"/><dir name="Category"><file name="Api.php" hash="60e0e8ad01d1a74d0d518aff96c831e3"/></dir><dir name="Product"><file name="Api.php" hash="9f8deaa123f3b09eb1b89a43effb997c"/><file name="Attributegroup.php" hash="b981dab2ed49b964dcefeb611b4d4b79"/><file name="Attribute.php" hash="85ed7b7cac160520db198108cab323dc"/><file name="Attributeset.php" hash="dca36b9c1b77e8357b1b143d1e8dc03e"/><file name="Link.php" hash="560e91507104c715145c328fff6e82cf"/><file name="Tierprice.php" hash="e9c383174f39caa5b834fc90d9b53d3c"/></dir><file name="Products.php" hash="810fda187e2f16f39471d51436c0bb29"/></dir><file name="Observer.php" hash="fe221305f528d980b7c7954a5651806e"/><dir name="Oerpcore"><file name="Groups.php" hash="651edd6916060cf2adaaa19a66a0a7a7"/><file name="Storeviews.php" hash="c2299f30aaf1f250d25e38622a095576"/><file name="Website.php" hash="1b42acd86e1d5cb4b1926f1882121f63"/></dir><dir name="Oerpcustomer"><file name="Address.php" hash="cc2a4b28af34bde7601f0496b15e04f9"/><file name="Customer.php" hash="00ce50494bb692c2c146b0b967dfd4a7"/><file name="Group.php" hash="83e3f35c2a74306f19737051ca5e717f"/><file name="Subscriber.php" hash="8a419ebf2fc356ab0c877ba1703fcd3c"/></dir><dir name="Oerpstock"><dir name="Item"><file name="Api.php" hash="16fa1b8d6d323b873f727dd1d01a8c88"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Api.php" hash="9b9b33591292976965f6aa608e37db06"/></dir></dir></dir><dir name="sql"><dir name="erpincloudconnector_setup"><file name="mysql4-install-0.0.1.php" hash="9acb1a07cb99fb2d4e0475972ea26108"/><file name="mysql4-upgrade-0.0.1-2.0.0.php" hash="b07c7fa8f9fbd43ce85fdced95879a6b"/><file name="mysql4-upgrade-2.0.0-2.1.0.php" hash="b07c7fa8f9fbd43ce85fdced95879a6b"/><file name="mysql4-upgrade-2.1.0-2.1.1.php" hash="b07c7fa8f9fbd43ce85fdced95879a6b"/><file name="mysql4-upgrade-2.1.1-2.1.2.php" hash="b07c7fa8f9fbd43ce85fdced95879a6b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ERPinCloud_Connector.xml" hash="8bba33fa44691eebf98c233292604df8"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>core</channel><min>1.6.0.0</min><max>1.7</max></package><extension><name>gd</name><min>2.0.28</min><max>3.0</max></extension></required></dependencies>
|
18 |
+
</package>
|