Version Notes
This is initial version of Fulfil.io ERP connector.
Download this release
Release Info
Developer | Tarun Bhardwaj |
Extension | fulfil-io |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- app/code/community/Fulfil/Erpconnector/Helper/Data.php +6 -0
- app/code/community/Fulfil/Erpconnector/Model/Catalog/Product/Api.php +80 -0
- app/code/community/Fulfil/Erpconnector/Model/Ferpcatalog/Category/Api.php +91 -0
- app/code/community/Fulfil/Erpconnector/Model/Ferpstock/Item/Api.php +75 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Categories.php +111 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Attribute.php +109 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Attributegroup.php +167 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Attributeset.php +58 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Link.php +277 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Tierprice.php +71 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Products.php +325 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcore/Groups.php +167 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcore/Storeviews.php +167 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcore/Website.php +195 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Address.php +241 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Customer.php +182 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Group.php +142 -0
- app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Subscriber.php +163 -0
- app/code/community/Fulfil/Erpconnector/Model/Observer.php +24 -0
- app/code/community/Fulfil/Erpconnector/Model/Sales/Order/Api.php +232 -0
- app/code/community/Fulfil/Erpconnector/controllers/Adminhtml/InitController.php +61 -0
- app/code/community/Fulfil/Erpconnector/controllers/ErpconnectorController.php +9 -0
- app/code/community/Fulfil/Erpconnector/etc/api.xml +638 -0
- app/code/community/Fulfil/Erpconnector/etc/config.xml +88 -0
- app/code/community/Fulfil/Erpconnector/sql/erpconnector_setup/mysql4-install-0.0.1.php +54 -0
- app/etc/modules/Fulfil_Erpconnector.xml +41 -0
- package.xml +18 -0
app/code/community/Fulfil/Erpconnector/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fulfil_Erpconnector_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
//fulfil api
|
5 |
+
}
|
6 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Catalog/Product/Api.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Fulfil
|
5 |
+
* @package Fulfil_Erpconnector
|
6 |
+
*/
|
7 |
+
|
8 |
+
class Fulfil_Erpconnector_Model_Catalog_Product_Api extends Mage_Catalog_Model_Product_Api
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Set additional data before product saved
|
12 |
+
*
|
13 |
+
* @param Mage_Catalog_Model_Product $product
|
14 |
+
* @param array $productData
|
15 |
+
* @return object
|
16 |
+
*/
|
17 |
+
protected function _prepareDataForSave ($product, $productData)
|
18 |
+
{
|
19 |
+
if (isset($productData['categories']) && is_array($productData['categories'])) {
|
20 |
+
$product->setCategoryIds($productData['categories']);
|
21 |
+
}
|
22 |
+
|
23 |
+
if (isset($productData['websites']) && is_array($productData['websites'])) {
|
24 |
+
foreach ($productData['websites'] as &$website) {
|
25 |
+
if (is_string($website)) {
|
26 |
+
try {
|
27 |
+
$website = Mage::app()->getWebsite($website)->getId();
|
28 |
+
} catch (Exception $e) { }
|
29 |
+
}
|
30 |
+
}
|
31 |
+
$product->setWebsiteIds($productData['websites']);
|
32 |
+
}
|
33 |
+
|
34 |
+
if (Mage::app()->isSingleStoreMode()) {
|
35 |
+
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
|
36 |
+
}
|
37 |
+
|
38 |
+
if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
|
39 |
+
$product->setStockData($productData['stock_data']);
|
40 |
+
} else {
|
41 |
+
$product->setStockData(array('use_config_manage_stock' => 0));
|
42 |
+
}
|
43 |
+
|
44 |
+
if (isset($productData['tier_price']) && is_array($productData['tier_price'])) {
|
45 |
+
$tierPrices = Mage::getModel('catalog/product_attribute_tierprice_api')->prepareTierPrices($product, $productData['tier_price']);
|
46 |
+
$product->setData(Mage_Catalog_Model_Product_Attribute_Tierprice_Api::ATTRIBUTE_CODE, $tierPrices);
|
47 |
+
}
|
48 |
+
|
49 |
+
/*
|
50 |
+
* Check if configurable product data array passed
|
51 |
+
*/
|
52 |
+
if(isset($productData['configurable_products_data']) && is_array($productData['configurable_products_data'])) {
|
53 |
+
$product->setConfigurableProductsData($productData['configurable_products_data']);
|
54 |
+
}
|
55 |
+
|
56 |
+
if(isset($productData['configurable_attributes_data']) && is_array($productData['configurable_attributes_data'])) {
|
57 |
+
foreach($productData['configurable_attributes_data'] as $key => $data) {
|
58 |
+
|
59 |
+
//Check to see if these values exist, otherwise try and populate from existing values
|
60 |
+
$data['label'] = (!empty($data['label'])) ? $data['label'] : $product->getResource()->getAttribute($data['attribute_code'])->getStoreLabel();
|
61 |
+
$data['frontend_label'] = (!empty($data['frontend_label'])) ? $data['frontend_label'] : $product->getResource()->getAttribute($data['attribute_code'])->getFrontendLabel();
|
62 |
+
$productData['configurable_attributes_data'][$key] = $data;
|
63 |
+
}
|
64 |
+
$product->setConfigurableAttributesData($productData['configurable_attributes_data']);
|
65 |
+
$product->setCanSaveConfigurableAttributes(true);
|
66 |
+
}
|
67 |
+
|
68 |
+
/*
|
69 |
+
* Check if bundle product data, options and bundle items arrays passed
|
70 |
+
*/
|
71 |
+
if(isset($productData['bundle_items_data']) && isset($productData['options_data']) && is_array($productData['bundle_items_data']) && is_array($productData['options_data'])) {
|
72 |
+
|
73 |
+
$product->setBundleOptionsData($productData['options_data']);
|
74 |
+
$product->setBundleSelectionsData($productData['bundle_items_data']);
|
75 |
+
$product->setCanSaveBundleSelections(true);
|
76 |
+
$product->setAffectBundleProductSelections(true);
|
77 |
+
Mage::register('product', $product); // product must be registred in order to get the store_id, see _beforeSave() in Mage/Bundle/Model/Selection.php
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
app/code/community/Fulfil/Erpconnector/Model/Ferpcatalog/Category/Api.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
class Fulfil_Erpconnector_Model_Ferpcatalog_category_api extends Mage_Catalog_Model_Category_Api
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return the list of products category ids
|
29 |
+
*
|
30 |
+
* @param array $filters
|
31 |
+
* @param string|int $store
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public function search($filters = null, $store = null)
|
35 |
+
{
|
36 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
37 |
+
->setStoreId($this->_getStoreId($store))
|
38 |
+
->addAttributeToSelect('name');
|
39 |
+
|
40 |
+
if (is_array($filters)) {
|
41 |
+
try {
|
42 |
+
foreach ($filters as $field => $value) {
|
43 |
+
if (isset($this->_filtersMap[$field])) {
|
44 |
+
$field = $this->_filtersMap[$field];
|
45 |
+
}
|
46 |
+
|
47 |
+
$collection->addFieldToFilter($field, $value);
|
48 |
+
}
|
49 |
+
} catch (Mage_Core_Exception $e) {
|
50 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
$result = array();
|
55 |
+
|
56 |
+
foreach ($collection as $product) {
|
57 |
+
$result[] = $product->getId();
|
58 |
+
}
|
59 |
+
|
60 |
+
return $result;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function move($categoryId, $parentId, $afterId = null)
|
64 |
+
{
|
65 |
+
$category = $this->_initCategory($categoryId);
|
66 |
+
$parent_category = $this->_initCategory($parentId);
|
67 |
+
|
68 |
+
$parentChildren = $parent_category->getChildren();
|
69 |
+
$child = explode(',', $parentChildren);
|
70 |
+
// TODO Improve speed when using $afterId
|
71 |
+
if (!in_array($categoryId, $child) || $afterId != null) {
|
72 |
+
// if $afterId is null - move category to the down
|
73 |
+
if ($afterId === null && $parent_category->hasChildren()) {
|
74 |
+
|
75 |
+
$afterId = array_pop($child);
|
76 |
+
}
|
77 |
+
|
78 |
+
if( strpos($parent_category->getPath(), $category->getPath()) === 0) {
|
79 |
+
$this->_fault('not_moved', "Operation do not allow to move a parent category to any of children category");
|
80 |
+
}
|
81 |
+
|
82 |
+
try {
|
83 |
+
$category->move($parentId, $afterId);
|
84 |
+
} catch (Mage_Core_Exception $e) {
|
85 |
+
$this->_fault('not_moved', $e->getMessage());
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return true;
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
app/code/community/Fulfil/Erpconnector/Model/Ferpstock/Item/Api.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Fulfil_Erpconnector_Model_Ferpstock_item_api extends Mage_CatalogInventory_Model_Stock_Item_Api
|
28 |
+
{
|
29 |
+
|
30 |
+
protected function _getProduct($productId, $store = null, $identifierType = 'id')
|
31 |
+
{
|
32 |
+
$product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);
|
33 |
+
if (is_null($product->getId())) {
|
34 |
+
$this->_fault('product_not_exists');
|
35 |
+
}
|
36 |
+
return $product;
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _updateStock($productId, $data)
|
40 |
+
{
|
41 |
+
// test if product exist
|
42 |
+
$product = $this->_getProduct($productId);
|
43 |
+
|
44 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
45 |
+
$stockItemId = $stockItem->getId();
|
46 |
+
|
47 |
+
if (!$stockItemId) {
|
48 |
+
$stockItem->setData('product_id', $productId);
|
49 |
+
$stockItem->setData('stock_id', 1);
|
50 |
+
} else {
|
51 |
+
$stock = $stockItem->getData();
|
52 |
+
}
|
53 |
+
|
54 |
+
foreach($data as $field=>$value) {
|
55 |
+
$stockItem->setData($field, $value?$value:0);
|
56 |
+
}
|
57 |
+
|
58 |
+
$stockItem->save();
|
59 |
+
return true;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function update($productId, $data)
|
63 |
+
{
|
64 |
+
return $this->_updateStock($productId, $data);
|
65 |
+
}
|
66 |
+
|
67 |
+
public function massive_update($datas)
|
68 |
+
{
|
69 |
+
foreach($datas as $productId=>$data) {
|
70 |
+
$this->_updateStock($productId, $data);
|
71 |
+
}
|
72 |
+
return true;
|
73 |
+
}
|
74 |
+
|
75 |
+
} // Class Mage_CatalogInventory_Model_Stock_Item_Api End
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Categories.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @author Sharoon Thomas
|
6 |
+
* Inspired from Dieter's Magento Extender
|
7 |
+
* @copyright 2009
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_Categories extends Mage_Catalog_Model_Api_Resource
|
11 |
+
{
|
12 |
+
public function items($filters = null) {
|
13 |
+
try {
|
14 |
+
$collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image');
|
15 |
+
} catch (Mage_Core_Exception $e) {
|
16 |
+
$this->_fault('category_not_exists');
|
17 |
+
}
|
18 |
+
if (is_array($filters)) {
|
19 |
+
try {
|
20 |
+
foreach ($filters as $field => $value) {
|
21 |
+
$collection->addFieldToFilter($field, $value);
|
22 |
+
}
|
23 |
+
} catch (Mage_Core_Exception $e) {
|
24 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
25 |
+
// If we are adding filter on non-existent attribute
|
26 |
+
}
|
27 |
+
}
|
28 |
+
$result = array ();
|
29 |
+
foreach ($collection as $category) {
|
30 |
+
//$result[] = $customer->toArray();
|
31 |
+
$result[] = array (
|
32 |
+
'category_id' => $category->getId(),
|
33 |
+
'image' => $category->getImage(),
|
34 |
+
);
|
35 |
+
}
|
36 |
+
return $result;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function info($categoryId = null) {
|
40 |
+
if (is_numeric($categoryId)) {
|
41 |
+
try {
|
42 |
+
$collection = Mage :: getModel('catalog/category/attribute')->load($categoryId)->getCollection()->addAttributeToSelect('image');
|
43 |
+
$result = array ();
|
44 |
+
foreach ($collection as $category) {
|
45 |
+
//$result[] = $customer->toArray();
|
46 |
+
if ($category->getId() == $categoryId) {
|
47 |
+
$image = $category->getImage();
|
48 |
+
if ($image) {
|
49 |
+
$path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
|
50 |
+
$fullpath = $path . $image;
|
51 |
+
try {
|
52 |
+
$fp = fopen($fullpath, "rb");
|
53 |
+
$imagebin = fread($fp, filesize($fullpath));
|
54 |
+
$img_data = base64_encode($imagebin);
|
55 |
+
fclose($fp);
|
56 |
+
} catch (Exception $e) {
|
57 |
+
$this->_fault('not_media');
|
58 |
+
}
|
59 |
+
}
|
60 |
+
$result[] = array (
|
61 |
+
'category_id' => $category->getId(),
|
62 |
+
'image' => $category->getImage(),
|
63 |
+
'image_data' => $img_data
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
return $result;
|
69 |
+
|
70 |
+
} catch (Mage_Core_Exception $e) {
|
71 |
+
$this->_fault('group_not_exists');
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
public function create($filename,$imgdata) {
|
79 |
+
if ($filename)
|
80 |
+
{
|
81 |
+
$path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
|
82 |
+
$fullpath = $path . $filename;
|
83 |
+
try
|
84 |
+
{
|
85 |
+
$fp = fopen($fullpath, "w");
|
86 |
+
if ($fp==false)
|
87 |
+
{
|
88 |
+
return "Error in file creation";
|
89 |
+
}
|
90 |
+
$img_data = base64_decode($imgdata);
|
91 |
+
$imagebin = fwrite($fp,$img_data);
|
92 |
+
fclose($fp);
|
93 |
+
return $imagebin;
|
94 |
+
}
|
95 |
+
catch (Exception $e)
|
96 |
+
{
|
97 |
+
$this->_fault('not_created');
|
98 |
+
}
|
99 |
+
return False;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
public function update($something=null)
|
103 |
+
{
|
104 |
+
return "Not implemented yet";
|
105 |
+
}
|
106 |
+
public function remove($something=null)
|
107 |
+
{
|
108 |
+
return "Not implemented yet";
|
109 |
+
}
|
110 |
+
}
|
111 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Attribute.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @author Sharoon Thomas
|
6 |
+
* Inspired from Dieter's Magento Extender
|
7 |
+
* @copyright 2009
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_Product_Attribute extends Mage_Catalog_Model_Api_Resource {
|
11 |
+
public function __construct() {
|
12 |
+
$this->_storeIdSessionField = 'product_store_id';
|
13 |
+
$this->_ignoredAttributeCodes[] = 'type_id';
|
14 |
+
$this->_ignoredAttributeTypes[] = 'gallery';
|
15 |
+
$this->_ignoredAttributeTypes[] = 'media_image';
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Retrieve attributes from specified attribute set
|
20 |
+
*
|
21 |
+
* @param int $setId
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function relations($setId){
|
25 |
+
$attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId);
|
26 |
+
$result = array ();
|
27 |
+
foreach ($attributes as $attribute){
|
28 |
+
$result[] = Array(
|
29 |
+
'attribute_id' => $attribute->getId()
|
30 |
+
);
|
31 |
+
}
|
32 |
+
return $result;
|
33 |
+
|
34 |
+
}
|
35 |
+
public function items($setId) {
|
36 |
+
$attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId);
|
37 |
+
$result = array ();
|
38 |
+
|
39 |
+
foreach ($attributes as $attribute) {
|
40 |
+
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
|
41 |
+
if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) {
|
42 |
+
|
43 |
+
if (!$attribute->getId() || $attribute->isScopeGlobal()) {
|
44 |
+
$scope = 'global';
|
45 |
+
}
|
46 |
+
elseif ($attribute->isScopeWebsite()) {
|
47 |
+
$scope = 'website';
|
48 |
+
} else {
|
49 |
+
$scope = 'store';
|
50 |
+
}
|
51 |
+
|
52 |
+
/*$result[] = array (
|
53 |
+
'attribute_id' => $attribute->getId(),
|
54 |
+
'code' => $attribute->getAttributeCode(),
|
55 |
+
'type' => $attribute->getFrontendInput(),
|
56 |
+
'required' => $attribute->getIsRequired(),
|
57 |
+
'attributeset' => $attribute->getattribute_set_info(),
|
58 |
+
'scope' => $scope
|
59 |
+
);*/
|
60 |
+
//Override hooray
|
61 |
+
$attribute['scope'] = $scope;
|
62 |
+
$result[]=$attribute->toArray();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
return $result;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function info($attributeId) {
|
70 |
+
try {
|
71 |
+
return 'hello';
|
72 |
+
$attribute = Mage :: getModel('catalog/product')->getResource()->getAttribute($attributeId);
|
73 |
+
return $attribute->toArray();
|
74 |
+
} catch (Exception $e) {
|
75 |
+
$this->_fault('not_exists');
|
76 |
+
}
|
77 |
+
}
|
78 |
+
/**
|
79 |
+
* Retrieve attribute options
|
80 |
+
*
|
81 |
+
* @param int $attributeId
|
82 |
+
* @param string|int $store
|
83 |
+
* @return array
|
84 |
+
*/
|
85 |
+
public function options($attributeId, $store = null) {
|
86 |
+
$storeId = $this->_getStoreId($store);
|
87 |
+
$attribute = Mage :: getModel('catalog/product')->setStoreId($storeId)->getResource()->getAttribute($attributeId)->setStoreId($storeId);
|
88 |
+
|
89 |
+
/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
|
90 |
+
if (!$attribute) {
|
91 |
+
$this->_fault('not_exists');
|
92 |
+
}
|
93 |
+
|
94 |
+
$options = array ();
|
95 |
+
foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) {
|
96 |
+
if (is_array($optionValue)) {
|
97 |
+
$options[] = $optionValue;
|
98 |
+
}
|
99 |
+
else {
|
100 |
+
$options[] = array (
|
101 |
+
'value' => $optionId,
|
102 |
+
'label' => $optionValue
|
103 |
+
);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
return $options;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Attributegroup.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @author Sharoon Thomas
|
6 |
+
* Inspired from Dieter's Magento Extender
|
7 |
+
* @copyright 2009
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource {
|
11 |
+
public function olditems($setId = null) {
|
12 |
+
$groups = Mage :: getModel('eav/entity_attribute_group')->getResourceCollection();
|
13 |
+
|
14 |
+
if (!is_null($setId) && !empty ($setId) && is_numeric($setId)) {
|
15 |
+
$groups->setAttributeSetFilter($setId);
|
16 |
+
}
|
17 |
+
|
18 |
+
$groups->load();
|
19 |
+
|
20 |
+
$arrGroups = array ();
|
21 |
+
|
22 |
+
foreach ($groups as $group) {
|
23 |
+
$arrGroups[] = array (
|
24 |
+
'attribute_group_id' => $group->getAttributeGroupId(),
|
25 |
+
'attribute_set_id' => $group->getAttributeSetId(),
|
26 |
+
'attribute_group_name' => $group->getAttributeGroupName(),
|
27 |
+
'sort_order' => $group->getSortOrder(),
|
28 |
+
'default_id' => $group->getDefaultId()
|
29 |
+
);
|
30 |
+
}
|
31 |
+
|
32 |
+
return $arrGroups;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function items($filters = null) {
|
36 |
+
try {
|
37 |
+
$collection = Mage :: getModel('eav/entity_attribute_group')->getCollection();
|
38 |
+
} catch (Mage_Core_Exception $e) {
|
39 |
+
$this->_fault('group_not_exists');
|
40 |
+
}
|
41 |
+
|
42 |
+
if (is_array($filters)) {
|
43 |
+
try {
|
44 |
+
foreach ($filters as $field => $value) {
|
45 |
+
$collection->addFieldToFilter($field, $value);
|
46 |
+
}
|
47 |
+
} catch (Mage_Core_Exception $e) {
|
48 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
49 |
+
// If we are adding filter on non-existent attribute
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
$result = array ();
|
54 |
+
foreach ($collection as $collection_item) {
|
55 |
+
$result[] = $collection_item->toArray();
|
56 |
+
}
|
57 |
+
|
58 |
+
return $result;
|
59 |
+
|
60 |
+
}
|
61 |
+
/*
|
62 |
+
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
|
63 |
+
<param><value><string>catalog_product_attribute_group.create</string></value></param>
|
64 |
+
<param>
|
65 |
+
<value>
|
66 |
+
<array>
|
67 |
+
<data>
|
68 |
+
<value><i4>26</i4></value>
|
69 |
+
<value><string>Leonelle</string></value>
|
70 |
+
</data>
|
71 |
+
</array>
|
72 |
+
</value>
|
73 |
+
</param>
|
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 |
+
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
|
96 |
+
<param><value><string>catalog_product_attribute_group.update</string></value></param>
|
97 |
+
<param>
|
98 |
+
<value>
|
99 |
+
<array>
|
100 |
+
<data>
|
101 |
+
<value><i4>85</i4></value>
|
102 |
+
<value><string>Leonelle2</string></value>
|
103 |
+
<value><i4>85</i4></value>
|
104 |
+
<value><i4>85</i4></value>
|
105 |
+
</data>
|
106 |
+
</array>
|
107 |
+
</value>
|
108 |
+
</param>
|
109 |
+
*/
|
110 |
+
public function update(array $data) {
|
111 |
+
try {
|
112 |
+
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
|
113 |
+
$attrOption = Mage :: getModel("eav/entity_attribute_group");
|
114 |
+
|
115 |
+
$attrOption->load($data["attribute_group_id"]);
|
116 |
+
|
117 |
+
// check if the requested group exists...
|
118 |
+
if (!$attrOption->getAttributeGroupId()) {
|
119 |
+
$this->_fault("group_not_exists");
|
120 |
+
}
|
121 |
+
|
122 |
+
$attrOption->addData($data);
|
123 |
+
|
124 |
+
$attrOption->save();
|
125 |
+
|
126 |
+
return true;
|
127 |
+
} catch (Exception $ex) {
|
128 |
+
return false;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/*
|
133 |
+
<param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
|
134 |
+
<param><value><string>catalog_product_attribute_group.delete</string></value></param>
|
135 |
+
<param>
|
136 |
+
<value>
|
137 |
+
<array>
|
138 |
+
<data>
|
139 |
+
<value><i4>85</i4></value>
|
140 |
+
</data>
|
141 |
+
</array>
|
142 |
+
</value>
|
143 |
+
</param>
|
144 |
+
*/
|
145 |
+
public function delete($groupId) {
|
146 |
+
try {
|
147 |
+
// $attrOption = Mage_Eav_Model_Entity_Attribute_Group
|
148 |
+
$attrOption = Mage :: getModel("eav/entity_attribute_group");
|
149 |
+
|
150 |
+
$attrOption->load($groupId);
|
151 |
+
|
152 |
+
// check if the requested group exists...
|
153 |
+
if (!$attrOption->getAttributeGroupId()) {
|
154 |
+
$this->_fault("group_not_exists");
|
155 |
+
}
|
156 |
+
|
157 |
+
// save data
|
158 |
+
$attrOption->delete();
|
159 |
+
|
160 |
+
return true;
|
161 |
+
} catch (Exception $ex) {
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Attributeset.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Catalog product attribute set api
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Catalog
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_Product_Attributeset extends Mage_Api_Model_Resource_Abstract
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Retrieve attribute set list
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function items()
|
42 |
+
{
|
43 |
+
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
|
44 |
+
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
45 |
+
->setEntityTypeFilter($entityType->getId());
|
46 |
+
|
47 |
+
$result = array();
|
48 |
+
foreach ($collection as $attributeSet) {
|
49 |
+
$result[] = array(
|
50 |
+
'attribute_set_id' => $attributeSet->getId(),
|
51 |
+
'attribute_set_name' => $attributeSet->getAttributeSetName()
|
52 |
+
);
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
return $result;
|
57 |
+
}
|
58 |
+
} // Class Mage_Catalog_Model_Product_Attribute_Set_Api End
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Link.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Raimon Esteve
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_Product_Link extends Mage_Catalog_Model_Product_Link_Api //Mage_Core_Model_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* get list product_super_link
|
14 |
+
*
|
15 |
+
* @param int $productId
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function items($productId)
|
19 |
+
{
|
20 |
+
$product = $this->_initProduct($productId);
|
21 |
+
|
22 |
+
$childProducts=array();
|
23 |
+
|
24 |
+
//$configurableAttributes = $product->getTypeInstance()->getConfigurableAttributesAsArray();
|
25 |
+
|
26 |
+
//print_r($configurableAttributes);
|
27 |
+
$collection = $product->getTypeInstance()->getUsedProducts();//getUsedProductCollection();
|
28 |
+
|
29 |
+
foreach($collection as $simpleProduct)
|
30 |
+
{
|
31 |
+
$row = $simpleProduct->toArray();
|
32 |
+
|
33 |
+
// naming convention
|
34 |
+
$row["product_id"] = $row["entity_id"];
|
35 |
+
$row["type"] = $row["type_id"];
|
36 |
+
$row["set"] = $row["attribute_set_id"];
|
37 |
+
$childProducts[] = $row;// $simpleProduct->toArray();
|
38 |
+
}
|
39 |
+
|
40 |
+
return $childProducts;
|
41 |
+
|
42 |
+
return array();
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* set product_super_link
|
47 |
+
*
|
48 |
+
* @param int $productId
|
49 |
+
* @param array $linkedProductIds
|
50 |
+
* @param array $data
|
51 |
+
* @return array
|
52 |
+
*/
|
53 |
+
public function assign($productId, $linkedProductIds, $data = array())
|
54 |
+
{
|
55 |
+
$product = $this->_initProduct($productId);
|
56 |
+
$tmpProductIds = $product->getTypeInstance()->getUsedProductIds();
|
57 |
+
$productIds = array();
|
58 |
+
|
59 |
+
foreach($tmpProductIds as $key => $prodId)
|
60 |
+
{
|
61 |
+
$productIds[$prodId] = $prodId;
|
62 |
+
}
|
63 |
+
|
64 |
+
if(is_array($linkedProductIds)) {
|
65 |
+
foreach($linkedProductIds as $prodId)
|
66 |
+
{
|
67 |
+
if(!key_exists($prodId,$productIds)) {$productIds[$prodId] = $prodId;}
|
68 |
+
}
|
69 |
+
} elseif(is_numeric($linkedProductIds)) {
|
70 |
+
if(!key_exists($linkedProductIds,$productIds)) {$productIds[$linkedProductIds] = $linkedProductIds;}
|
71 |
+
} else {
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
$product->setConfigurableProductsData($productIds);
|
76 |
+
$product->save();
|
77 |
+
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* remove product_super_link
|
83 |
+
*
|
84 |
+
* @param int $productId
|
85 |
+
* @param array $linkedProductIds
|
86 |
+
* @return array
|
87 |
+
*/
|
88 |
+
public function remove($productId, $linkedProductIds)
|
89 |
+
{
|
90 |
+
$product = $this->_initProduct($productId);
|
91 |
+
$tmpProductIds = $product->getTypeInstance()->getUsedProductIds();
|
92 |
+
$productIds = array();
|
93 |
+
|
94 |
+
foreach($tmpProductIds as $key => $prodId)
|
95 |
+
{
|
96 |
+
if(is_array($linkedProductIds))
|
97 |
+
{
|
98 |
+
if(!in_array($prodId, $linkedProductIds))
|
99 |
+
{
|
100 |
+
|
101 |
+
$productIds[$prodId] = $prodId;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
elseif(is_numeric($linkedProductIds))
|
105 |
+
{
|
106 |
+
if($prodId!=$linkedProductIds)
|
107 |
+
{
|
108 |
+
$productIds[$prodId] = $prodId;;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
$product->setConfigurableProductsData($productIds);
|
114 |
+
$product->save();
|
115 |
+
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
|
119 |
+
private function _getStores()
|
120 |
+
{
|
121 |
+
$stores = Mage::getModel('core/store')
|
122 |
+
->getResourceCollection()
|
123 |
+
->setLoadDefault(true)
|
124 |
+
->load();
|
125 |
+
return $stores;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* List Configurables Atributes
|
130 |
+
*
|
131 |
+
* @param int $productId
|
132 |
+
* @return array
|
133 |
+
*/
|
134 |
+
public function listSuperAttributes($productIdOrSku)
|
135 |
+
{
|
136 |
+
try
|
137 |
+
{
|
138 |
+
// check if product Exists
|
139 |
+
$product = $this->_initProduct($productIdOrSku);
|
140 |
+
|
141 |
+
if($product->getTypeId()!="configurable") $this->_fault("not a configurable product");
|
142 |
+
|
143 |
+
$productId = $product->getEntityId();
|
144 |
+
|
145 |
+
$stores = $this->_getStores();
|
146 |
+
|
147 |
+
$superAttributes=array();
|
148 |
+
|
149 |
+
foreach($stores as $store)
|
150 |
+
{
|
151 |
+
$product = $product = Mage::getModel('catalog/product')->setStoreId($store->getStoreId());
|
152 |
+
$product->load($productId);
|
153 |
+
$attrs = $product->getTypeInstance()->getConfigurableAttributesAsArray();
|
154 |
+
|
155 |
+
foreach($attrs as $key=>$attr)
|
156 |
+
{
|
157 |
+
if(!isset($superAttributes[$attr["id"]]))
|
158 |
+
{
|
159 |
+
$superAttributes["".$attr["id"].""] = $attr;
|
160 |
+
$superAttributes["".$attr["id"].""]["product_id"] = $product->getEntityId();
|
161 |
+
$superAttributes["".$attr["id"].""]["product_super_attribute_id"] = $attr["id"];
|
162 |
+
unset($superAttributes["".$attr["id"].""]["id"]);
|
163 |
+
}
|
164 |
+
|
165 |
+
unset($superAttributes["".$attr["id"].""]["label"]);
|
166 |
+
|
167 |
+
$superAttributes["".$attr["id"].""]["labels"][$store->getStoreId()] = $attr["label"];
|
168 |
+
}
|
169 |
+
}
|
170 |
+
//print_r($superAttributes);
|
171 |
+
|
172 |
+
return array_values($superAttributes);
|
173 |
+
}
|
174 |
+
catch (Exception $ex)
|
175 |
+
{
|
176 |
+
echo $ex;
|
177 |
+
}
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Create Configurables Atributes
|
183 |
+
*
|
184 |
+
* @param int $productId
|
185 |
+
* @param int $attributeID
|
186 |
+
* @param int position
|
187 |
+
* @param array labels
|
188 |
+
* @param array prices
|
189 |
+
* @return ID
|
190 |
+
*/
|
191 |
+
public function createSuperAttribute($productIDorSku, $attributeID, $position, array $labels, array $prices = null)
|
192 |
+
{
|
193 |
+
$product = $this->_initProduct($productIDorSku);
|
194 |
+
//$confAttributes = $product->getTypeInstance()->getUsedProductIds();
|
195 |
+
|
196 |
+
$superAttr = Mage::getModel("catalog/product_type_configurable_attribute");
|
197 |
+
|
198 |
+
$superAttr->setProductId($product->getId());
|
199 |
+
$superAttr->setAttributeId($attributeID);
|
200 |
+
$superAttr->setPosition($position);
|
201 |
+
|
202 |
+
if(is_string($labels))
|
203 |
+
{
|
204 |
+
$superAttr->setStoreId(0);
|
205 |
+
$superAttr->setLabel($labels);
|
206 |
+
$superAttr->save();
|
207 |
+
}
|
208 |
+
elseif(is_array($labels))
|
209 |
+
{
|
210 |
+
foreach($labels as $storeID => $label)
|
211 |
+
{
|
212 |
+
$superAttr->setStoreId($storeID);
|
213 |
+
$superAttr->setLabel($label);
|
214 |
+
$superAttr->save();
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
if(is_array($prices))
|
219 |
+
{
|
220 |
+
$superAttr->setValues($prices);
|
221 |
+
$superAttr->save();
|
222 |
+
}
|
223 |
+
|
224 |
+
return (int)$superAttr->getId();
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Set Configurables Atributes
|
229 |
+
*
|
230 |
+
* @param int $product
|
231 |
+
* @param int $attribute
|
232 |
+
* @return True
|
233 |
+
*/
|
234 |
+
public function setSuperAttributeValues($product, $attribute)
|
235 |
+
{
|
236 |
+
#get if product exists
|
237 |
+
$product = Mage::getModel('catalog/product')->load($product)->getID();
|
238 |
+
if(!$product){
|
239 |
+
return False;
|
240 |
+
}
|
241 |
+
#get if attribute exists
|
242 |
+
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id')->load($attribute)->getID();
|
243 |
+
if(!$attribute){
|
244 |
+
return False;
|
245 |
+
}
|
246 |
+
|
247 |
+
#try add catalog_product_super_attribute
|
248 |
+
try {
|
249 |
+
$resource = Mage::getSingleton('core/resource');
|
250 |
+
$writeConnection = $resource->getConnection('core_write');
|
251 |
+
$query = 'INSERT INTO '.$resource->getTableName('catalog_product_super_attribute').' (product_id, attribute_id) VALUES ('.$product.', '.$attribute.');';
|
252 |
+
$writeConnection->query($query);
|
253 |
+
return True;
|
254 |
+
} catch (Exception $e) {
|
255 |
+
return False;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Remove Configurables Atributes
|
261 |
+
*
|
262 |
+
* @param int $superAttributeID
|
263 |
+
* @return ID
|
264 |
+
*/
|
265 |
+
public function removeSuperAttribute($superAttributeID)
|
266 |
+
{
|
267 |
+
$superAttr = Mage::getModel("catalog/product_type_configurable_attribute");
|
268 |
+
$superAttr->load($superAttributeID);
|
269 |
+
|
270 |
+
$superAttr->delete();
|
271 |
+
//$superAttr->setValues($prices);
|
272 |
+
//$superAttr->save();
|
273 |
+
return true;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Product/Tierprice.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category Mage
|
23 |
+
* @package Mage_Catalog
|
24 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Catalog Product tier price api
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Catalog
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_Product_Tierprice extends Mage_Catalog_Model_Api_Resource {
|
36 |
+
const ATTRIBUTE_CODE = 'tier_price';
|
37 |
+
|
38 |
+
|
39 |
+
public function items($productIds=null) {
|
40 |
+
if (is_array($productIds)) {
|
41 |
+
$result = array ();
|
42 |
+
foreach ($productIds as $productId) {
|
43 |
+
$product = Mage :: getModel('catalog/product')->load($productId);
|
44 |
+
if (!$product->getId()) {
|
45 |
+
$this->_fault('product_not_exists');
|
46 |
+
}
|
47 |
+
$tierPrices = $product->getData(self :: ATTRIBUTE_CODE);
|
48 |
+
$result[$productId] = $tierPrices;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
return $result;
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
public function items2($productIds=null) {
|
56 |
+
$product = Mage :: getModel('catalog/product_attribute_backend_tierprice')->_get_set_go();
|
57 |
+
if (!$product->getId()) {
|
58 |
+
$this->_fault('product_not_exists');
|
59 |
+
}
|
60 |
+
|
61 |
+
$tierPrices = $product->getPriceModel()->getTierPriceCount();
|
62 |
+
return 'hello';
|
63 |
+
$result[$productIds] = $tierPrices;
|
64 |
+
|
65 |
+
|
66 |
+
return $result;
|
67 |
+
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
app/code/community/Fulfil/Erpconnector/Model/Ffcatalog/Products.php
ADDED
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fulfil_Erpconnector_Model_Ffcatalog_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 |
+
{
|
13 |
+
$this->_storeIdSessionField = 'product_store_id';
|
14 |
+
$this->_ignoredAttributeTypes[] = 'gallery';
|
15 |
+
$this->_ignoredAttributeTypes[] = 'media_image';
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Return the list of products ids
|
20 |
+
*
|
21 |
+
* @param array $filters
|
22 |
+
* @param string|int $store
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function search($filters = null, $store = null)
|
26 |
+
{
|
27 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
28 |
+
->setStoreId($this->_getStoreId($store))
|
29 |
+
->addAttributeToSelect('name');
|
30 |
+
|
31 |
+
if (is_array($filters)) {
|
32 |
+
try {
|
33 |
+
foreach ($filters as $field => $value) {
|
34 |
+
if (isset($this->_filtersMap[$field])) {
|
35 |
+
$field = $this->_filtersMap[$field];
|
36 |
+
}
|
37 |
+
|
38 |
+
$collection->addFieldToFilter($field, $value);
|
39 |
+
}
|
40 |
+
} catch (Mage_Core_Exception $e) {
|
41 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
$result = array();
|
46 |
+
|
47 |
+
foreach ($collection as $product) {
|
48 |
+
$result[] = $product->getId();
|
49 |
+
}
|
50 |
+
|
51 |
+
return $result;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Retrieve list of products with basic info (id, sku, type, set, name)
|
56 |
+
*
|
57 |
+
* @param array $filters
|
58 |
+
* @param string|int $store
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function items($filters = null, $store = null)
|
62 |
+
{
|
63 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
64 |
+
->setStoreId($this->_getStoreId($store))
|
65 |
+
->addAttributeToSelect('name');
|
66 |
+
|
67 |
+
if (is_array($filters)) {
|
68 |
+
try {
|
69 |
+
foreach ($filters as $field => $value) {
|
70 |
+
if (isset($this->_filtersMap[$field])) {
|
71 |
+
$field = $this->_filtersMap[$field];
|
72 |
+
}
|
73 |
+
|
74 |
+
$collection->addFieldToFilter($field, $value);
|
75 |
+
}
|
76 |
+
} catch (Mage_Core_Exception $e) {
|
77 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
$result = array();
|
82 |
+
|
83 |
+
foreach ($collection as $product) {
|
84 |
+
// $result[] = $product->getData();
|
85 |
+
$result[] = array( // Basic product data
|
86 |
+
'product_id' => $product->getId(),
|
87 |
+
'sku' => $product->getSku(),
|
88 |
+
'name' => $product->getName(),
|
89 |
+
'set' => $product->getAttributeSetId(),
|
90 |
+
'type' => $product->getTypeId(),
|
91 |
+
'category_ids' => $product->getCategoryIds()
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
return $result;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Retrieve product info
|
100 |
+
*
|
101 |
+
* @param int|string $productId
|
102 |
+
* @param string|int $store
|
103 |
+
* @param array $attributes
|
104 |
+
* @return array
|
105 |
+
*/
|
106 |
+
public function biglist($productId, $store = null, $filters = null)
|
107 |
+
{
|
108 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
109 |
+
->setStoreId($this->_getStoreId($store))
|
110 |
+
->addAttributeToSelect('name');
|
111 |
+
|
112 |
+
if (is_array($filters)) {
|
113 |
+
try {
|
114 |
+
foreach ($filters as $field => $value) {
|
115 |
+
if (isset($this->_filtersMap[$field])) {
|
116 |
+
$field = $this->_filtersMap[$field];
|
117 |
+
}
|
118 |
+
|
119 |
+
$collection->addFieldToFilter($field, $value);
|
120 |
+
}
|
121 |
+
} catch (Mage_Core_Exception $e) {
|
122 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
123 |
+
}
|
124 |
+
}
|
125 |
+
foreach ($collection as $product) {
|
126 |
+
$data = array();
|
127 |
+
$data = array( // Basic product data
|
128 |
+
'product_id' => $product->getId(),
|
129 |
+
'sku' => $product->getSku(),
|
130 |
+
'set' => $product->getAttributeSetId(),
|
131 |
+
'type' => $product->getTypeId(),
|
132 |
+
'categories' => $product->getCategoryIds(),
|
133 |
+
'websites' => $product->getWebsiteIds()
|
134 |
+
);
|
135 |
+
|
136 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
137 |
+
$data[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode());
|
138 |
+
}
|
139 |
+
$result[]=$data;
|
140 |
+
}
|
141 |
+
return $result;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Create new product.
|
146 |
+
*
|
147 |
+
* @param string $type
|
148 |
+
* @param int $set
|
149 |
+
* @param array $productData
|
150 |
+
* @return int
|
151 |
+
*/
|
152 |
+
public function create($type, $set, $sku, $productData)
|
153 |
+
{
|
154 |
+
if (!$type || !$set || !$sku) {
|
155 |
+
$this->_fault('data_invalid');
|
156 |
+
}
|
157 |
+
|
158 |
+
$product = Mage::getModel('catalog/product');
|
159 |
+
/* @var $product Mage_Catalog_Model_Product */
|
160 |
+
$product->setStoreId($this->_getStoreId($store))
|
161 |
+
->setAttributeSetId($set)
|
162 |
+
->setTypeId($type)
|
163 |
+
->setSku($sku);
|
164 |
+
|
165 |
+
if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
|
166 |
+
$product->setWebsiteIds($productData['website_ids']);
|
167 |
+
}
|
168 |
+
|
169 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
170 |
+
if ($this->_isAllowedAttribute($attribute)
|
171 |
+
&& isset($productData[$attribute->getAttributeCode()])) {
|
172 |
+
$product->setData(
|
173 |
+
$attribute->getAttributeCode(),
|
174 |
+
$productData[$attribute->getAttributeCode()]
|
175 |
+
);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
$this->_prepareDataForSave($product, $productData);
|
180 |
+
|
181 |
+
if (is_array($errors = $product->validate())) {
|
182 |
+
$this->_fault('data_invalid', implode("\n", $errors));
|
183 |
+
}
|
184 |
+
|
185 |
+
try {
|
186 |
+
$product->save();
|
187 |
+
} catch (Mage_Core_Exception $e) {
|
188 |
+
$this->_fault('data_invalid', $e->getMessage());
|
189 |
+
}
|
190 |
+
|
191 |
+
return $product->getId();
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Update product data
|
196 |
+
*
|
197 |
+
* @param int|string $productId
|
198 |
+
* @param array $productData
|
199 |
+
* @param string|int $store
|
200 |
+
* @return boolean
|
201 |
+
*/
|
202 |
+
public function update($productId, $productData = array(), $store = null)
|
203 |
+
{
|
204 |
+
$product = $this->_getProduct($productId, $store);
|
205 |
+
|
206 |
+
if (!$product->getId()) {
|
207 |
+
$this->_fault('not_exists');
|
208 |
+
}
|
209 |
+
|
210 |
+
if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
|
211 |
+
$product->setWebsiteIds($productData['website_ids']);
|
212 |
+
}
|
213 |
+
|
214 |
+
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
|
215 |
+
if ($this->_isAllowedAttribute($attribute)
|
216 |
+
&& isset($productData[$attribute->getAttributeCode()])) {
|
217 |
+
$product->setData(
|
218 |
+
$attribute->getAttributeCode(),
|
219 |
+
$productData[$attribute->getAttributeCode()]
|
220 |
+
);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
$this->_prepareDataForSave($product, $productData);
|
225 |
+
|
226 |
+
try {
|
227 |
+
if (is_array($errors = $product->validate())) {
|
228 |
+
$this->_fault('data_invalid', implode("\n", $errors));
|
229 |
+
}
|
230 |
+
} catch (Mage_Core_Exception $e) {
|
231 |
+
$this->_fault('data_invalid', $e->getMessage());
|
232 |
+
}
|
233 |
+
|
234 |
+
try {
|
235 |
+
$product->save();
|
236 |
+
} catch (Mage_Core_Exception $e) {
|
237 |
+
$this->_fault('data_invalid', $e->getMessage());
|
238 |
+
}
|
239 |
+
|
240 |
+
return true;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Set additional data before product saved
|
245 |
+
*
|
246 |
+
* @param Mage_Catalog_Model_Product $product
|
247 |
+
* @param array $productData
|
248 |
+
* @return object
|
249 |
+
*/
|
250 |
+
protected function _prepareDataForSave ($product, $productData)
|
251 |
+
{
|
252 |
+
if (isset($productData['categories']) && is_array($productData['categories'])) {
|
253 |
+
$product->setCategoryIds($productData['categories']);
|
254 |
+
}
|
255 |
+
|
256 |
+
if (isset($productData['websites']) && is_array($productData['websites'])) {
|
257 |
+
foreach ($productData['websites'] as &$website) {
|
258 |
+
if (is_string($website)) {
|
259 |
+
try {
|
260 |
+
$website = Mage::app()->getWebsite($website)->getId();
|
261 |
+
} catch (Exception $e) { }
|
262 |
+
}
|
263 |
+
}
|
264 |
+
$product->setWebsiteIds($productData['websites']);
|
265 |
+
}
|
266 |
+
|
267 |
+
if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
|
268 |
+
$product->setStockData($productData['stock_data']);
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Update product special price
|
274 |
+
*
|
275 |
+
* @param int|string $productId
|
276 |
+
* @param float $specialPrice
|
277 |
+
* @param string $fromDate
|
278 |
+
* @param string $toDate
|
279 |
+
* @param string|int $store
|
280 |
+
* @return boolean
|
281 |
+
*/
|
282 |
+
public function setSpecialPrice($productId, $specialPrice = null, $fromDate = null, $toDate = null, $store = null)
|
283 |
+
{
|
284 |
+
return $this->update($productId, array(
|
285 |
+
'special_price' => $specialPrice,
|
286 |
+
'special_from_date' => $fromDate,
|
287 |
+
'special_to_date' => $toDate
|
288 |
+
), $store);
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Retrieve product special price
|
293 |
+
*
|
294 |
+
* @param int|string $productId
|
295 |
+
* @param string|int $store
|
296 |
+
* @return array
|
297 |
+
*/
|
298 |
+
public function getSpecialPrice($productId, $store = null)
|
299 |
+
{
|
300 |
+
return $this->info($productId, $store, array('special_price', 'special_from_date', 'special_to_date'));
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Delete product
|
305 |
+
*
|
306 |
+
* @param int|string $productId
|
307 |
+
* @return boolean
|
308 |
+
*/
|
309 |
+
public function delete($productId)
|
310 |
+
{
|
311 |
+
$product = $this->_getProduct($productId);
|
312 |
+
|
313 |
+
if (!$product->getId()) {
|
314 |
+
$this->_fault('not_exists');
|
315 |
+
}
|
316 |
+
|
317 |
+
try {
|
318 |
+
$product->delete();
|
319 |
+
} catch (Mage_Core_Exception $e) {
|
320 |
+
$this->_fault('not_deleted', $e->getMessage());
|
321 |
+
}
|
322 |
+
|
323 |
+
return true;
|
324 |
+
}
|
325 |
+
} // Class Mage_Catalog_Model_Product_Api End
|
app/code/community/Fulfil/Erpconnector/Model/Ffcore/Groups.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Ffcore_Groups extends Mage_Catalog_Model_Api_Resource
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Return the list of partner ids which match the filters
|
14 |
+
*
|
15 |
+
* @param array $filters
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function search($filters)
|
19 |
+
{
|
20 |
+
|
21 |
+
$collection = Mage::getModel('core/store_group')->getCollection();
|
22 |
+
|
23 |
+
if (is_array($filters)) {
|
24 |
+
try {
|
25 |
+
foreach ($filters as $field => $value) {
|
26 |
+
$collection->addFieldToFilter($field, $value);
|
27 |
+
}
|
28 |
+
} catch (Mage_Core_Exception $e) {
|
29 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $collection->getAllIds();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function items($filters=null)
|
37 |
+
{
|
38 |
+
try
|
39 |
+
{
|
40 |
+
$collection = Mage::getModel('core/store_group')->getCollection();//->addAttributeToSelect('*');
|
41 |
+
}
|
42 |
+
catch (Mage_Core_Exception $e)
|
43 |
+
{
|
44 |
+
$this->_fault('group_not_exists');
|
45 |
+
}
|
46 |
+
|
47 |
+
if (is_array($filters)) {
|
48 |
+
try {
|
49 |
+
foreach ($filters as $field => $value) {
|
50 |
+
$collection->addFieldToFilter($field, $value);
|
51 |
+
}
|
52 |
+
} catch (Mage_Core_Exception $e) {
|
53 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
54 |
+
// If we are adding filter on non-existent attribute
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $customer) {
|
60 |
+
$result[] = $customer->toArray();
|
61 |
+
}
|
62 |
+
|
63 |
+
return $result;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function info($groupIds = null)
|
67 |
+
{
|
68 |
+
$groups = array();
|
69 |
+
|
70 |
+
if(is_array($groupIds))
|
71 |
+
{
|
72 |
+
foreach($groupIds as $groupId)
|
73 |
+
{
|
74 |
+
try
|
75 |
+
{
|
76 |
+
$groups[] = Mage::getModel('core/store_group')->load($groupId)->toArray();
|
77 |
+
}
|
78 |
+
catch (Mage_Core_Exception $e)
|
79 |
+
{
|
80 |
+
$this->_fault('group_not_exists');
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $groups;
|
84 |
+
}
|
85 |
+
elseif(is_numeric($groupIds))
|
86 |
+
{
|
87 |
+
try
|
88 |
+
{
|
89 |
+
return Mage::getModel('core/store_group')->load($groupIds)->toArray();
|
90 |
+
}
|
91 |
+
catch (Mage_Core_Exception $e)
|
92 |
+
{
|
93 |
+
$this->_fault('group_not_exists');
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
public function create($groupdata)
|
101 |
+
{
|
102 |
+
try
|
103 |
+
{
|
104 |
+
$group = Mage::getModel('core/store_group')
|
105 |
+
->setData($groupdata)
|
106 |
+
->save();
|
107 |
+
|
108 |
+
}
|
109 |
+
catch (Magento_Core_Exception $e)
|
110 |
+
{
|
111 |
+
$this->_fault('data_invalid',$e->getMessage());
|
112 |
+
}
|
113 |
+
catch (Exception $e)
|
114 |
+
{
|
115 |
+
$this->_fault('data_invalid',$e->getMessage());
|
116 |
+
}
|
117 |
+
return $group->getId();
|
118 |
+
}
|
119 |
+
|
120 |
+
public function update($groupid,$groupdata)
|
121 |
+
{
|
122 |
+
try
|
123 |
+
{
|
124 |
+
$group = Mage::getModel('core/store_group')
|
125 |
+
->load($groupid);
|
126 |
+
if (!$group->getId())
|
127 |
+
{
|
128 |
+
$this->_fault('group_not_exists');
|
129 |
+
}
|
130 |
+
$group->addData($groupdata)->save();
|
131 |
+
}
|
132 |
+
catch (Magento_Core_Exception $e)
|
133 |
+
{
|
134 |
+
$this->_fault('data_invalid',$e->getMessage());
|
135 |
+
}
|
136 |
+
catch (Exception $e)
|
137 |
+
{
|
138 |
+
$this->_fault('data_invalid',$e->getMessage());
|
139 |
+
}
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
|
143 |
+
public function delete($groupid)
|
144 |
+
{
|
145 |
+
try
|
146 |
+
{
|
147 |
+
$group = Mage::getModel('core/store_group')
|
148 |
+
->load($groupid);
|
149 |
+
if (!$group->getId())
|
150 |
+
{
|
151 |
+
$this->_fault('group_not_exists');
|
152 |
+
}
|
153 |
+
$group->delete();
|
154 |
+
|
155 |
+
}
|
156 |
+
catch (Magento_Core_Exception $e)
|
157 |
+
{
|
158 |
+
$this->_fault('data_invalid',$e->getMessage());
|
159 |
+
}
|
160 |
+
catch (Exception $e)
|
161 |
+
{
|
162 |
+
$this->_fault('data_invalid',$e->getMessage());
|
163 |
+
}
|
164 |
+
return true;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcore/Storeviews.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Ffcore_Storeviews extends Mage_Catalog_Model_Api_Resource
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Return the list of storeviews ids which match the filters
|
14 |
+
*
|
15 |
+
* @param array $filters
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function search($filters)
|
19 |
+
{
|
20 |
+
|
21 |
+
$collection = Mage::getModel('core/store')->getCollection();
|
22 |
+
|
23 |
+
if (is_array($filters)) {
|
24 |
+
try {
|
25 |
+
foreach ($filters as $field => $value) {
|
26 |
+
$collection->addFieldToFilter($field, $value);
|
27 |
+
}
|
28 |
+
} catch (Mage_Core_Exception $e) {
|
29 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $collection->getAllIds();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function items($filters=null)
|
37 |
+
{
|
38 |
+
try
|
39 |
+
{
|
40 |
+
$collection = Mage::getModel('core/store')->getCollection();//->addAttributeToSelect('*');
|
41 |
+
}
|
42 |
+
catch (Mage_Core_Exception $e)
|
43 |
+
{
|
44 |
+
$this->_fault('store_not_exists');
|
45 |
+
}
|
46 |
+
|
47 |
+
if (is_array($filters)) {
|
48 |
+
try {
|
49 |
+
foreach ($filters as $field => $value) {
|
50 |
+
$collection->addFieldToFilter($field, $value);
|
51 |
+
}
|
52 |
+
} catch (Mage_Core_Exception $e) {
|
53 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
54 |
+
// If we are adding filter on non-existent attribute
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $customer) {
|
60 |
+
$result[] = $customer->toArray();
|
61 |
+
}
|
62 |
+
|
63 |
+
return $result;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function info($storeIds = null)
|
67 |
+
{
|
68 |
+
$stores = array();
|
69 |
+
|
70 |
+
if(is_array($storeIds))
|
71 |
+
{
|
72 |
+
foreach($storeIds as $storeId)
|
73 |
+
{
|
74 |
+
try
|
75 |
+
{
|
76 |
+
$stores[] = Mage::getModel('core/store')->load($storeId)->toArray();
|
77 |
+
}
|
78 |
+
catch (Mage_Core_Exception $e)
|
79 |
+
{
|
80 |
+
$this->_fault('store_not_exists');
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $stores;
|
84 |
+
}
|
85 |
+
elseif(is_numeric($storeIds))
|
86 |
+
{
|
87 |
+
try
|
88 |
+
{
|
89 |
+
return Mage::getModel('core/store')->load($storeIds)->toArray();
|
90 |
+
}
|
91 |
+
catch (Mage_Core_Exception $e)
|
92 |
+
{
|
93 |
+
$this->_fault('store_not_exists');
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
public function create($storedata)
|
101 |
+
{
|
102 |
+
try
|
103 |
+
{
|
104 |
+
$store = Mage::getModel('core/store')
|
105 |
+
->setData($storedata)
|
106 |
+
->save();
|
107 |
+
|
108 |
+
}
|
109 |
+
catch (Magento_Core_Exception $e)
|
110 |
+
{
|
111 |
+
$this->_fault('data_invalid',$e->getMessage());
|
112 |
+
}
|
113 |
+
catch (Exception $e)
|
114 |
+
{
|
115 |
+
$this->_fault('data_invalid',$e->getMessage());
|
116 |
+
}
|
117 |
+
return $store->getId();
|
118 |
+
}
|
119 |
+
|
120 |
+
public function update($storeid,$storedata)
|
121 |
+
{
|
122 |
+
try
|
123 |
+
{
|
124 |
+
$store = Mage::getModel('core/store')
|
125 |
+
->load($storeid);
|
126 |
+
if (!$store->getId())
|
127 |
+
{
|
128 |
+
$this->_fault('store_not_exists');
|
129 |
+
}
|
130 |
+
$store->addData($storedata)->save();
|
131 |
+
}
|
132 |
+
catch (Magento_Core_Exception $e)
|
133 |
+
{
|
134 |
+
$this->_fault('data_invalid',$e->getMessage());
|
135 |
+
}
|
136 |
+
catch (Exception $e)
|
137 |
+
{
|
138 |
+
$this->_fault('data_invalid',$e->getMessage());
|
139 |
+
}
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
|
143 |
+
public function delete($storeid)
|
144 |
+
{
|
145 |
+
try
|
146 |
+
{
|
147 |
+
$store = Mage::getModel('core/store')
|
148 |
+
->load($storeid);
|
149 |
+
if (!$store->getId())
|
150 |
+
{
|
151 |
+
$this->_fault('store_not_exists');
|
152 |
+
}
|
153 |
+
$store->delete();
|
154 |
+
|
155 |
+
}
|
156 |
+
catch (Magento_Core_Exception $e)
|
157 |
+
{
|
158 |
+
$this->_fault('data_invalid',$e->getMessage());
|
159 |
+
}
|
160 |
+
catch (Exception $e)
|
161 |
+
{
|
162 |
+
$this->_fault('data_invalid',$e->getMessage());
|
163 |
+
}
|
164 |
+
return true;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcore/Website.php
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Ffcore_Website extends Mage_Catalog_Model_Api_Resource
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Return the list of website ids which match the filters
|
14 |
+
*
|
15 |
+
* @param array $filters
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function search($filters)
|
19 |
+
{
|
20 |
+
|
21 |
+
$collection = Mage::getModel('core/website')->getCollection();
|
22 |
+
|
23 |
+
if (is_array($filters)) {
|
24 |
+
try {
|
25 |
+
foreach ($filters as $field => $value) {
|
26 |
+
$collection->addFieldToFilter($field, $value);
|
27 |
+
}
|
28 |
+
} catch (Mage_Core_Exception $e) {
|
29 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
return $collection->getAllIds();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function items($filters=null)
|
37 |
+
{
|
38 |
+
try
|
39 |
+
{
|
40 |
+
$collection = Mage::getModel('core/website')->getCollection();//->addAttributeToSelect('*');
|
41 |
+
}
|
42 |
+
catch (Mage_Core_Exception $e)
|
43 |
+
{
|
44 |
+
$this->_fault('store_not_exists');
|
45 |
+
}
|
46 |
+
|
47 |
+
if (is_array($filters)) {
|
48 |
+
try {
|
49 |
+
foreach ($filters as $field => $value) {
|
50 |
+
$collection->addFieldToFilter($field, $value);
|
51 |
+
}
|
52 |
+
} catch (Mage_Core_Exception $e) {
|
53 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
54 |
+
// If we are adding filter on non-existent attribute
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $customer) {
|
60 |
+
$result[] = $customer->toArray();
|
61 |
+
}
|
62 |
+
|
63 |
+
return $result;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function info($storeIds = null)
|
67 |
+
{
|
68 |
+
$stores = array();
|
69 |
+
|
70 |
+
if(is_array($storeIds))
|
71 |
+
{
|
72 |
+
foreach($storeIds as $storeId)
|
73 |
+
{
|
74 |
+
try
|
75 |
+
{
|
76 |
+
$stores[] = Mage::getModel('core/website')->load($storeId)->toArray();
|
77 |
+
}
|
78 |
+
catch (Mage_Core_Exception $e)
|
79 |
+
{
|
80 |
+
$this->_fault('store_not_exists');
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $stores;
|
84 |
+
}
|
85 |
+
elseif(is_numeric($storeIds))
|
86 |
+
{
|
87 |
+
try
|
88 |
+
{
|
89 |
+
return Mage::getModel('core/website')->load($storeIds)->toArray();
|
90 |
+
}
|
91 |
+
catch (Mage_Core_Exception $e)
|
92 |
+
{
|
93 |
+
$this->_fault('store_not_exists');
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
99 |
+
//This is a protected function used by items & info for fetching website information
|
100 |
+
|
101 |
+
public function create($websitedata)
|
102 |
+
{
|
103 |
+
try
|
104 |
+
{
|
105 |
+
$website = Mage::getModel('core/website')
|
106 |
+
->setData($websitedata)
|
107 |
+
->save();
|
108 |
+
|
109 |
+
}
|
110 |
+
catch (Magento_Core_Exception $e)
|
111 |
+
{
|
112 |
+
$this->_fault('data_invalid',$e->getMessage());
|
113 |
+
}
|
114 |
+
catch (Exception $e)
|
115 |
+
{
|
116 |
+
$this->_fault('data_invalid',$e->getMessage());
|
117 |
+
}
|
118 |
+
return $website->getId();
|
119 |
+
}
|
120 |
+
|
121 |
+
public function update($websiteid,$websitedata)
|
122 |
+
{
|
123 |
+
try
|
124 |
+
{
|
125 |
+
$website = Mage::getModel('core/website')
|
126 |
+
->load($websiteid);
|
127 |
+
if (!$website->getId())
|
128 |
+
{
|
129 |
+
$this->_fault('website_not_exists');
|
130 |
+
}
|
131 |
+
$website->addData($websitedata)->save();
|
132 |
+
}
|
133 |
+
catch (Magento_Core_Exception $e)
|
134 |
+
{
|
135 |
+
$this->_fault('data_invalid',$e->getMessage());
|
136 |
+
}
|
137 |
+
catch (Exception $e)
|
138 |
+
{
|
139 |
+
$this->_fault('data_invalid',$e->getMessage());
|
140 |
+
}
|
141 |
+
return true;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function delete($websiteid)
|
145 |
+
{
|
146 |
+
try
|
147 |
+
{
|
148 |
+
$website = Mage::getModel('core/website')
|
149 |
+
->load($websiteid);
|
150 |
+
if (!$website->getId())
|
151 |
+
{
|
152 |
+
$this->_fault('website_not_exists');
|
153 |
+
}
|
154 |
+
$website->delete();
|
155 |
+
|
156 |
+
}
|
157 |
+
catch (Magento_Core_Exception $e)
|
158 |
+
{
|
159 |
+
$this->_fault('data_invalid',$e->getMessage());
|
160 |
+
}
|
161 |
+
catch (Exception $e)
|
162 |
+
{
|
163 |
+
$this->_fault('data_invalid',$e->getMessage());
|
164 |
+
}
|
165 |
+
return true;
|
166 |
+
}
|
167 |
+
|
168 |
+
public function tree()
|
169 |
+
{
|
170 |
+
$tree = array();
|
171 |
+
|
172 |
+
$websites = $this->websites();
|
173 |
+
|
174 |
+
foreach($websites as $website)
|
175 |
+
{
|
176 |
+
$groups = $this->groups($website['group_ids']);
|
177 |
+
$tree[$website['code']] = $website;
|
178 |
+
foreach($groups as $group)
|
179 |
+
{
|
180 |
+
$stores = $this->stores($group["store_ids"]);
|
181 |
+
|
182 |
+
$tree[$website['code']]['groups']['group_'.$group['group_id']] = $group;
|
183 |
+
|
184 |
+
foreach($stores as $store)
|
185 |
+
{
|
186 |
+
$tree[$website['code']]['groups']['group_'.$group['group_id']]['stores'][$store['code']] = $store;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
return $tree;
|
192 |
+
}
|
193 |
+
|
194 |
+
}
|
195 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Address.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Customer
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Customer address api
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Customer
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Fulfil_Erpconnector_Model_Ffcustomer_Address extends Mage_Customer_Model_Api_Resource
|
35 |
+
{
|
36 |
+
protected $_mapAttributes = array(
|
37 |
+
'customer_id' => 'entity_id'
|
38 |
+
);
|
39 |
+
|
40 |
+
public function __construct()
|
41 |
+
{
|
42 |
+
$this->_ignoredAttributeCodes[] = 'parent_id';
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrive customer addresses list
|
47 |
+
*
|
48 |
+
* @param int $customerId
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function items($customerId)
|
52 |
+
{
|
53 |
+
$customer = Mage::getModel('customer/customer')
|
54 |
+
->load($customerId);
|
55 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
56 |
+
|
57 |
+
if (!$customer->getId()) {
|
58 |
+
$this->_fault('customer_not_exists');
|
59 |
+
}
|
60 |
+
|
61 |
+
$result = array();
|
62 |
+
foreach ($customer->getAddresses() as $address) {
|
63 |
+
$data = $address->toArray();
|
64 |
+
$data['default_billing'] = $customer->getDefaultBilling() == $address->getId();
|
65 |
+
$data['default_shipping'] = $customer->getDefaultShipping() == $address->getId();
|
66 |
+
$result[] = $data;
|
67 |
+
/*$data = $address->toArray();
|
68 |
+
$row = array();
|
69 |
+
|
70 |
+
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
|
71 |
+
$row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null;
|
72 |
+
}
|
73 |
+
|
74 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
|
75 |
+
if (isset($data[$attributeCode])) {
|
76 |
+
$row[$attributeCode] = $data[$attributeCode];
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
$row['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId();
|
81 |
+
$row['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId();
|
82 |
+
|
83 |
+
$result[] = $row;*/
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
return $result;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Create new address for customer
|
92 |
+
*
|
93 |
+
* @param int $customerId
|
94 |
+
* @param array $addressData
|
95 |
+
* @return int
|
96 |
+
*/
|
97 |
+
public function create($customerId, $addressData)
|
98 |
+
{
|
99 |
+
$customer = Mage::getModel('customer/customer')
|
100 |
+
->load($customerId);
|
101 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
102 |
+
|
103 |
+
if (!$customer->getId()) {
|
104 |
+
$this->_fault('customer_not_exists');
|
105 |
+
}
|
106 |
+
|
107 |
+
$address = Mage::getModel('customer/address');
|
108 |
+
|
109 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) {
|
110 |
+
if (isset($addressData[$attributeCode])) {
|
111 |
+
$address->setData($attributeCode, $addressData[$attributeCode]);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
if (isset($addressData['is_default_billing'])) {
|
116 |
+
$address->setIsDefaultBilling($addressData['is_default_billing']);
|
117 |
+
}
|
118 |
+
|
119 |
+
if (isset($addressData['is_default_shipping'])) {
|
120 |
+
$address->setIsDefaultShipping($addressData['is_default_shipping']);
|
121 |
+
}
|
122 |
+
|
123 |
+
$address->setCustomerId($customer->getId());
|
124 |
+
|
125 |
+
$valid = $address->validate();
|
126 |
+
|
127 |
+
if (is_array($valid)) {
|
128 |
+
$this->_fault('data_invalid', implode("\n", $valid));
|
129 |
+
}
|
130 |
+
|
131 |
+
try {
|
132 |
+
$address->save();
|
133 |
+
} catch (Mage_Core_Exception $e) {
|
134 |
+
$this->_fault('data_invalid', $e->getMessage());
|
135 |
+
}
|
136 |
+
|
137 |
+
return $address->getId();
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Retrieve address data
|
142 |
+
*
|
143 |
+
* @param int $addressId
|
144 |
+
* @return array
|
145 |
+
*/
|
146 |
+
public function info($addressId)
|
147 |
+
{
|
148 |
+
$address = Mage::getModel('customer/address')
|
149 |
+
->load($addressId);
|
150 |
+
|
151 |
+
if (!$address->getId()) {
|
152 |
+
$this->_fault('not_exists');
|
153 |
+
}
|
154 |
+
|
155 |
+
$result = array();
|
156 |
+
|
157 |
+
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
|
158 |
+
$result[$attributeAlias] = $address->getData($attributeCode);
|
159 |
+
}
|
160 |
+
|
161 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
|
162 |
+
$result[$attributeCode] = $address->getData($attributeCode);
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
if ($customer = $address->getCustomer()) {
|
167 |
+
$result['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId();
|
168 |
+
$result['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId();
|
169 |
+
}
|
170 |
+
|
171 |
+
return $result;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Update address data
|
176 |
+
*
|
177 |
+
* @param int $addressId
|
178 |
+
* @param array $addressData
|
179 |
+
* @return boolean
|
180 |
+
*/
|
181 |
+
public function update($addressId, $addressData)
|
182 |
+
{
|
183 |
+
$address = Mage::getModel('customer/address')
|
184 |
+
->load($addressId);
|
185 |
+
|
186 |
+
if (!$address->getId()) {
|
187 |
+
$this->_fault('not_exists');
|
188 |
+
}
|
189 |
+
|
190 |
+
foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) {
|
191 |
+
if (isset($addressData[$attributeCode])) {
|
192 |
+
$address->setData($attributeCode, $addressData[$attributeCode]);
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
if (isset($addressData['is_default_billing'])) {
|
197 |
+
$address->setIsDefaultBilling($addressData['is_default_billing']);
|
198 |
+
}
|
199 |
+
|
200 |
+
if (isset($addressData['is_default_shipping'])) {
|
201 |
+
$address->setIsDefaultShipping($addressData['is_default_shipping']);
|
202 |
+
}
|
203 |
+
|
204 |
+
$valid = $address->validate();
|
205 |
+
if (is_array($valid)) {
|
206 |
+
$this->_fault('data_invalid', implode("\n", $valid));
|
207 |
+
}
|
208 |
+
|
209 |
+
try {
|
210 |
+
$address->save();
|
211 |
+
} catch (Mage_Core_Exception $e) {
|
212 |
+
$this->_fault('data_invalid', $e->getMessage());
|
213 |
+
}
|
214 |
+
|
215 |
+
return true;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Delete address
|
220 |
+
*
|
221 |
+
* @param int $addressId
|
222 |
+
* @return boolean
|
223 |
+
*/
|
224 |
+
public function delete($addressId)
|
225 |
+
{
|
226 |
+
$address = Mage::getModel('customer/address')
|
227 |
+
->load($addressId);
|
228 |
+
|
229 |
+
if (!$address->getId()) {
|
230 |
+
$this->_fault('not_exists');
|
231 |
+
}
|
232 |
+
|
233 |
+
try {
|
234 |
+
$address->delete();
|
235 |
+
} catch (Mage_Core_Exception $e) {
|
236 |
+
$this->_fault('not_deleted', $e->getMessage());
|
237 |
+
}
|
238 |
+
|
239 |
+
return true;
|
240 |
+
}
|
241 |
+
} // Class Mage_Customer_Model_Address_Api End
|
app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Customer.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Ffcustomer_Customer extends Mage_Catalog_Model_Api_Resource
|
10 |
+
{
|
11 |
+
|
12 |
+
protected $_mapFilters = array(
|
13 |
+
'customer_id' => 'entity_id'
|
14 |
+
);
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Return the list of partner ids which match the filters
|
18 |
+
*
|
19 |
+
* @param array $filters
|
20 |
+
* @return array
|
21 |
+
*/
|
22 |
+
public function search($filters)
|
23 |
+
{
|
24 |
+
|
25 |
+
$collection = Mage::getModel('customer/customer')->getCollection()
|
26 |
+
->addAttributeToSelect('*');
|
27 |
+
|
28 |
+
if (is_array($filters)) {
|
29 |
+
try {
|
30 |
+
foreach ($filters as $field => $value) {
|
31 |
+
if (isset($this->_mapFilters[$field])) {
|
32 |
+
$field = $this->_mapFilters[$field];
|
33 |
+
}
|
34 |
+
|
35 |
+
$collection->addFieldToFilter($field, $value);
|
36 |
+
}
|
37 |
+
} catch (Mage_Core_Exception $e) {
|
38 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
$result = array();
|
43 |
+
|
44 |
+
foreach ($collection as $product) {
|
45 |
+
$result[] = $product->getId();
|
46 |
+
}
|
47 |
+
|
48 |
+
return $result;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function items($filters=null)
|
52 |
+
{
|
53 |
+
try
|
54 |
+
{
|
55 |
+
$collection = Mage::getModel('customer/customer')->getCollection();//->addAttributeToSelect('*');
|
56 |
+
}
|
57 |
+
catch (Mage_Core_Exception $e)
|
58 |
+
{
|
59 |
+
$this->_fault('customer_not_exists');
|
60 |
+
}
|
61 |
+
|
62 |
+
if (is_array($filters)) {
|
63 |
+
try {
|
64 |
+
foreach ($filters as $field => $value) {
|
65 |
+
$collection->addFieldToFilter($field, $value);
|
66 |
+
}
|
67 |
+
} catch (Mage_Core_Exception $e) {
|
68 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
69 |
+
// If we are adding filter on non-existent attribute
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
$result = array();
|
74 |
+
foreach ($collection as $customer) {
|
75 |
+
$result[] = $customer->toArray();
|
76 |
+
}
|
77 |
+
|
78 |
+
return $result;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function info($groupIds = null)
|
82 |
+
{
|
83 |
+
$groups = array();
|
84 |
+
|
85 |
+
if(is_array($groupIds))
|
86 |
+
{
|
87 |
+
foreach($groupIds as $groupId)
|
88 |
+
{
|
89 |
+
try
|
90 |
+
{
|
91 |
+
$groups[] = Mage::getModel('customer')->load($groupId)->toArray();
|
92 |
+
}
|
93 |
+
catch (Mage_Core_Exception $e)
|
94 |
+
{
|
95 |
+
$this->_fault('customer_not_exists');
|
96 |
+
}
|
97 |
+
}
|
98 |
+
return $groups;
|
99 |
+
}
|
100 |
+
elseif(is_numeric($groupIds))
|
101 |
+
{
|
102 |
+
try
|
103 |
+
{
|
104 |
+
return Mage::getModel('customer')->load($groupIds)->toArray();
|
105 |
+
}
|
106 |
+
catch (Mage_Core_Exception $e)
|
107 |
+
{
|
108 |
+
$this->_fault('customer_not_exists');
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
public function create($groupdata)
|
116 |
+
{
|
117 |
+
try
|
118 |
+
{
|
119 |
+
$group = Mage::getModel('customer')
|
120 |
+
->setData($groupdata)
|
121 |
+
->save();
|
122 |
+
|
123 |
+
}
|
124 |
+
catch (Magento_Core_Exception $e)
|
125 |
+
{
|
126 |
+
$this->_fault('data_invalid',$e->getMessage());
|
127 |
+
}
|
128 |
+
catch (Exception $e)
|
129 |
+
{
|
130 |
+
$this->_fault('data_invalid',$e->getMessage());
|
131 |
+
}
|
132 |
+
return $group->getId();
|
133 |
+
}
|
134 |
+
|
135 |
+
public function update($groupid,$groupdata)
|
136 |
+
{
|
137 |
+
try
|
138 |
+
{
|
139 |
+
$group = Mage::getModel('customer')
|
140 |
+
->load($groupid);
|
141 |
+
if (!$group->getId())
|
142 |
+
{
|
143 |
+
$this->_fault('customer_not_exists');
|
144 |
+
}
|
145 |
+
$group->addData($groupdata)->save();
|
146 |
+
}
|
147 |
+
catch (Magento_Core_Exception $e)
|
148 |
+
{
|
149 |
+
$this->_fault('data_invalid',$e->getMessage());
|
150 |
+
}
|
151 |
+
catch (Exception $e)
|
152 |
+
{
|
153 |
+
$this->_fault('data_invalid',$e->getMessage());
|
154 |
+
}
|
155 |
+
return true;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function delete($groupid)
|
159 |
+
{
|
160 |
+
try
|
161 |
+
{
|
162 |
+
$group = Mage::getModel('customer')
|
163 |
+
->load($groupid);
|
164 |
+
if (!$group->getId())
|
165 |
+
{
|
166 |
+
$this->_fault('customer_not_exists');
|
167 |
+
}
|
168 |
+
$group->delete();
|
169 |
+
|
170 |
+
}
|
171 |
+
catch (Magento_Core_Exception $e)
|
172 |
+
{
|
173 |
+
$this->_fault('data_invalid',$e->getMessage());
|
174 |
+
}
|
175 |
+
catch (Exception $e)
|
176 |
+
{
|
177 |
+
$this->_fault('data_invalid',$e->getMessage());
|
178 |
+
}
|
179 |
+
return true;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Group.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Sharoon Thomas
|
5 |
+
* Inspired from Dieter's Magento Extender
|
6 |
+
* @copyright 2009
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Ffcustomer_Group extends Mage_Catalog_Model_Api_Resource
|
10 |
+
{
|
11 |
+
public function items($filters=null)
|
12 |
+
{
|
13 |
+
try
|
14 |
+
{
|
15 |
+
$collection = Mage::getModel('customer/group')->getCollection();//->addAttributeToSelect('*');
|
16 |
+
}
|
17 |
+
catch (Mage_Core_Exception $e)
|
18 |
+
{
|
19 |
+
$this->_fault('group_not_exists');
|
20 |
+
}
|
21 |
+
|
22 |
+
if (is_array($filters)) {
|
23 |
+
try {
|
24 |
+
foreach ($filters as $field => $value) {
|
25 |
+
$collection->addFieldToFilter($field, $value);
|
26 |
+
}
|
27 |
+
} catch (Mage_Core_Exception $e) {
|
28 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
29 |
+
// If we are adding filter on non-existent attribute
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
$result = array();
|
34 |
+
foreach ($collection as $customer) {
|
35 |
+
$result[] = $customer->toArray();
|
36 |
+
}
|
37 |
+
|
38 |
+
return $result;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function info($groupIds = null)
|
42 |
+
{
|
43 |
+
$groups = array();
|
44 |
+
|
45 |
+
if(is_array($groupIds))
|
46 |
+
{
|
47 |
+
foreach($groupIds as $groupId)
|
48 |
+
{
|
49 |
+
try
|
50 |
+
{
|
51 |
+
$groups[] = Mage::getModel('customer/group')->load($groupId)->toArray();
|
52 |
+
}
|
53 |
+
catch (Mage_Core_Exception $e)
|
54 |
+
{
|
55 |
+
$this->_fault('group_not_exists');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
return $groups;
|
59 |
+
}
|
60 |
+
elseif(is_numeric($groupIds))
|
61 |
+
{
|
62 |
+
try
|
63 |
+
{
|
64 |
+
return Mage::getModel('customer/group')->load($groupIds)->toArray();
|
65 |
+
}
|
66 |
+
catch (Mage_Core_Exception $e)
|
67 |
+
{
|
68 |
+
$this->_fault('group_not_exists');
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
public function create($groupdata)
|
76 |
+
{
|
77 |
+
try
|
78 |
+
{
|
79 |
+
$group = Mage::getModel('customer/group')
|
80 |
+
->setData($groupdata)
|
81 |
+
->save();
|
82 |
+
|
83 |
+
}
|
84 |
+
catch (Magento_Core_Exception $e)
|
85 |
+
{
|
86 |
+
$this->_fault('data_invalid',$e->getMessage());
|
87 |
+
}
|
88 |
+
catch (Exception $e)
|
89 |
+
{
|
90 |
+
$this->_fault('data_invalid',$e->getMessage());
|
91 |
+
}
|
92 |
+
return $group->getId();
|
93 |
+
}
|
94 |
+
|
95 |
+
public function update($groupid,$groupdata)
|
96 |
+
{
|
97 |
+
try
|
98 |
+
{
|
99 |
+
$group = Mage::getModel('customer/group')
|
100 |
+
->load($groupid);
|
101 |
+
if (!$group->getId())
|
102 |
+
{
|
103 |
+
$this->_fault('group_not_exists');
|
104 |
+
}
|
105 |
+
$group->addData($groupdata)->save();
|
106 |
+
}
|
107 |
+
catch (Magento_Core_Exception $e)
|
108 |
+
{
|
109 |
+
$this->_fault('data_invalid',$e->getMessage());
|
110 |
+
}
|
111 |
+
catch (Exception $e)
|
112 |
+
{
|
113 |
+
$this->_fault('data_invalid',$e->getMessage());
|
114 |
+
}
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function delete($groupid)
|
119 |
+
{
|
120 |
+
try
|
121 |
+
{
|
122 |
+
$group = Mage::getModel('customer/group')
|
123 |
+
->load($groupid);
|
124 |
+
if (!$group->getId())
|
125 |
+
{
|
126 |
+
$this->_fault('group_not_exists');
|
127 |
+
}
|
128 |
+
$group->delete();
|
129 |
+
|
130 |
+
}
|
131 |
+
catch (Magento_Core_Exception $e)
|
132 |
+
{
|
133 |
+
$this->_fault('data_invalid',$e->getMessage());
|
134 |
+
}
|
135 |
+
catch (Exception $e)
|
136 |
+
{
|
137 |
+
$this->_fault('data_invalid',$e->getMessage());
|
138 |
+
}
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
?>
|
app/code/community/Fulfil/Erpconnector/Model/Ffcustomer/Subscriber.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Customer
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Customer address api
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Customer
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Fulfil_Erpconnector_Model_Ffcustomer_Subscriber extends Mage_Customer_Model_Api_Resource
|
35 |
+
{
|
36 |
+
protected $_mapAttributes = array(
|
37 |
+
'customer_id' => 'entity_id'
|
38 |
+
);
|
39 |
+
|
40 |
+
public function __construct()
|
41 |
+
{
|
42 |
+
$this->_ignoredAttributeCodes[] = 'parent_id';
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrive subscriber list
|
47 |
+
*
|
48 |
+
* @param int $filters
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function items($filters=null)
|
52 |
+
{
|
53 |
+
$collection = Mage::getModel('customer/customer')->getCollection()
|
54 |
+
->addAttributeToSelect('*');
|
55 |
+
|
56 |
+
|
57 |
+
if (is_array($filters)) {
|
58 |
+
try {
|
59 |
+
foreach ($filters as $field => $value) {
|
60 |
+
$collection->addFieldToFilter($field, $value);
|
61 |
+
}
|
62 |
+
} catch (Mage_Core_Exception $e) {
|
63 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
64 |
+
// If we are adding filter on non-existent attribute
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
$result = array();
|
69 |
+
|
70 |
+
foreach ($collection as $customer) {
|
71 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']);
|
72 |
+
if($subscriber->getId())
|
73 |
+
$result[] = $subscriber->getId();
|
74 |
+
}
|
75 |
+
|
76 |
+
return $result;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Create new address for customer
|
81 |
+
*
|
82 |
+
* @param int $customerId
|
83 |
+
* @param array $email
|
84 |
+
* @return int
|
85 |
+
*/
|
86 |
+
public function create($customerId,$email)
|
87 |
+
{
|
88 |
+
if($customerId && $email):
|
89 |
+
$customer = Mage::getModel("newsletter/subscriber");
|
90 |
+
|
91 |
+
$customer->setCustomerId($customerId);
|
92 |
+
$customer->setEmail($email);
|
93 |
+
$customer->subscriber_status = "1";
|
94 |
+
|
95 |
+
$customer->save();
|
96 |
+
|
97 |
+
return $customer->getId();
|
98 |
+
else:
|
99 |
+
return False;
|
100 |
+
endif;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Retrieve subscriber data
|
105 |
+
*
|
106 |
+
* @param int $subscriberId
|
107 |
+
* @return array
|
108 |
+
*/
|
109 |
+
public function info($subscriberId)
|
110 |
+
{
|
111 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId);
|
112 |
+
|
113 |
+
if($subscriber->getId()):
|
114 |
+
$result[] = $subscriber->toArray();
|
115 |
+
endif;
|
116 |
+
|
117 |
+
return $result;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Update subscriber data (subscriber)
|
122 |
+
*
|
123 |
+
* @param $email
|
124 |
+
* @return boolean
|
125 |
+
*/
|
126 |
+
public function update($email)
|
127 |
+
{
|
128 |
+
if($email):
|
129 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
130 |
+
|
131 |
+
if($subscriber->getId()):
|
132 |
+
$customer = Mage::getModel("newsletter/subscriber")->load($subscriber->getId());
|
133 |
+
$customer->subscriber_status = "1";
|
134 |
+
$customer->save();
|
135 |
+
endif;
|
136 |
+
|
137 |
+
return $subscriber->getId();
|
138 |
+
else:
|
139 |
+
return False;
|
140 |
+
endif;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Delete subscriber (unsubscriber)
|
145 |
+
*
|
146 |
+
* @param $email
|
147 |
+
* @return boolean
|
148 |
+
*/
|
149 |
+
public function delete($email)
|
150 |
+
{
|
151 |
+
if($email):
|
152 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
153 |
+
|
154 |
+
if($subscriber->getId()):
|
155 |
+
Mage::getModel('newsletter/subscriber')->load($subscriber->getId())->unsubscribe();
|
156 |
+
endif;
|
157 |
+
|
158 |
+
return $subscriber->getId();
|
159 |
+
else:
|
160 |
+
return False;
|
161 |
+
endif;
|
162 |
+
}
|
163 |
+
} // Class Mage_Customer_Model_Address_Api End
|
app/code/community/Fulfil/Erpconnector/Model/Observer.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author Fulfil
|
5 |
+
* @package Fulfil_Erpconnector
|
6 |
+
*
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Fulfil_Erpconnector_Model_Observer extends Mage_Core_Model_Abstract {
|
10 |
+
|
11 |
+
/* Initialize attribtue 'imported' if version < 1.4.0.0 */
|
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 Fulfil_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, 'Fulfil_Connector.log');
|
20 |
+
}
|
21 |
+
$order->setImported(0)->save();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Fulfil/Erpconnector/Model/Sales/Order/Api.php
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Fulfil
|
6 |
+
* @package Fulfil_Erpconnector
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Fulfil_Erpconnector_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Return the list of products ids that match with the filter
|
14 |
+
* The filter imported is required
|
15 |
+
* @param array
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function search($data) {
|
19 |
+
|
20 |
+
$result = array();
|
21 |
+
if(isset($data['imported'])) {
|
22 |
+
|
23 |
+
$collection = Mage::getModel("sales/order")->getCollection()
|
24 |
+
->addAttributeToSelect('increment_id')
|
25 |
+
->addAttributeToSelect('entity_id')
|
26 |
+
->addAttributeToFilter('imported', array('eq' => $data['imported']));
|
27 |
+
if(isset($data['fields']) && is_array($data['fields'])) {
|
28 |
+
foreach($data['fields'] as $field) {
|
29 |
+
$collection->addAttributeToSelect($field);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
if(isset($data['limit'])) {
|
34 |
+
$collection->setPageSize($data['limit']);
|
35 |
+
$collection->setCurPage($data['page']);
|
36 |
+
$collection->setOrder('entity_id', 'ASC');
|
37 |
+
}
|
38 |
+
|
39 |
+
if(isset($data['filters']) && is_array($data['filters'])) {
|
40 |
+
$filters = $data['filters'];
|
41 |
+
foreach($filters as $field => $value) {
|
42 |
+
$collection->addAttributeToFilter($field, $value);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
$result['perPage'] = $collection->getPageSize();
|
46 |
+
$result['totalCount'] = $collection->getSize();
|
47 |
+
$result['page'] = $collection->getCurPage();
|
48 |
+
$result['hasNext'] = $collection->getLastPageNumber() > $collection->getCurPage();
|
49 |
+
$result['lastPage'] = intval($collection->getLastPageNumber());
|
50 |
+
$result['items'] = array();
|
51 |
+
|
52 |
+
foreach ($collection as $order) {
|
53 |
+
$res = array();
|
54 |
+
$res['increment_id'] = $order->getIncrementId();
|
55 |
+
$res['order_id'] = $order->getId();
|
56 |
+
if(isset($data['fields']) && is_array($data['fields'])) {
|
57 |
+
foreach($data['fields'] as $field) {
|
58 |
+
$res[$field] = $order[$field];
|
59 |
+
}
|
60 |
+
}
|
61 |
+
$result['items'][] = $res;
|
62 |
+
}
|
63 |
+
|
64 |
+
return $result;
|
65 |
+
}else{
|
66 |
+
$this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified");
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
*
|
73 |
+
* Retrieve orders data based on the value of the flag 'imported'
|
74 |
+
* @param array
|
75 |
+
* @return array
|
76 |
+
*/
|
77 |
+
public function retrieveOrders($data) {
|
78 |
+
|
79 |
+
$result = array();
|
80 |
+
if(isset($data['imported'])) {
|
81 |
+
|
82 |
+
$collection = Mage::getModel("sales/order")->getCollection()
|
83 |
+
->addAttributeToSelect('*')
|
84 |
+
->addAttributeToFilter('imported', array('eq' => $data['imported']));
|
85 |
+
|
86 |
+
/* addAddressFields() is called only if version >= 1400 */
|
87 |
+
if(str_replace('.','',Mage::getVersion()) >= 1400) {
|
88 |
+
$collection->addAddressFields();
|
89 |
+
}
|
90 |
+
|
91 |
+
if(isset($data['limit'])) {
|
92 |
+
$collection->setPageSize($data['limit']);
|
93 |
+
$collection->setOrder('entity_id', 'ASC');
|
94 |
+
}
|
95 |
+
|
96 |
+
if(isset($data['filters']) && is_array($data['filters'])) {
|
97 |
+
$filters = $data['filters'];
|
98 |
+
foreach($filters as $field => $value) {
|
99 |
+
$collection->addAttributeToFilter($field, $value);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
foreach ($collection as $order) {
|
104 |
+
$tmp = $this->_getAttributes($order, 'order');
|
105 |
+
|
106 |
+
/* if version < 1400, billing and shipping information are added manually to order data */
|
107 |
+
if(str_replace('.','',Mage::getVersion()) < 1400) {
|
108 |
+
$address_data = $this->_getAttributes($order->getShippingAddress(), 'order_address');
|
109 |
+
if(!empty($address_data)) {
|
110 |
+
$tmp['shipping_firstname'] = $address_data['firstname'];
|
111 |
+
$tmp['shipping_lastname'] = $address_data['lastname'];
|
112 |
+
}
|
113 |
+
|
114 |
+
$address_data = $this->_getAttributes($order->getBillingAddress(), 'order_address');
|
115 |
+
if(!empty($address_data)) {
|
116 |
+
$tmp['billing_firstname'] = $address_data['firstname'];
|
117 |
+
$tmp['billing_lastname'] = $address_data['lastname'];
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
$result[] = $tmp;
|
122 |
+
}
|
123 |
+
return $result;
|
124 |
+
}else{
|
125 |
+
$this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified");
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
public function setFlagForOrder($incrementId) {
|
130 |
+
$_order = $this->_initOrder($incrementId);
|
131 |
+
$_order->setImported(1);
|
132 |
+
try {
|
133 |
+
$_order->save();
|
134 |
+
return true;
|
135 |
+
} catch (Mage_Core_Exception $e) {
|
136 |
+
$this->_fault('data_invalid', $e->getMessage());
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/* Retrieve increment_id of the child order */
|
141 |
+
public function getOrderChild($incrementId) {
|
142 |
+
|
143 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
144 |
+
/**
|
145 |
+
* Check order existing
|
146 |
+
*/
|
147 |
+
if (!$order->getId()) {
|
148 |
+
$this->_fault('order_not_exists');
|
149 |
+
}
|
150 |
+
|
151 |
+
if($order->getRelationChildId()) {
|
152 |
+
return $order->getRelationChildRealId();
|
153 |
+
}else{
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/* Retrieve increment_id of the parent order */
|
159 |
+
public function getOrderParent($incrementId) {
|
160 |
+
|
161 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
162 |
+
/**
|
163 |
+
* Check order existing
|
164 |
+
*/
|
165 |
+
if (!$order->getId()) {
|
166 |
+
$this->_fault('order_not_exists');
|
167 |
+
}
|
168 |
+
|
169 |
+
if($order->getRelationParentId()) {
|
170 |
+
return $order->getRelationParentRealId();
|
171 |
+
}else{
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/* Retrieve order states */
|
177 |
+
public function getOrderStates() {
|
178 |
+
return Mage::getSingleton("sales/order_config")->getStates();
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/* Retrieve invoices increment ids of the order */
|
183 |
+
public function getInvoiceIds($incrementId) {
|
184 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
185 |
+
/**
|
186 |
+
* Check order existing
|
187 |
+
*/
|
188 |
+
if (!$order->getId()) {
|
189 |
+
$this->_fault('order_not_exists');
|
190 |
+
}
|
191 |
+
$res = array();
|
192 |
+
foreach($order->getInvoiceCollection() as $invoice){
|
193 |
+
array_push($res, $invoice->getIncrementId());
|
194 |
+
};
|
195 |
+
return $res;
|
196 |
+
}
|
197 |
+
|
198 |
+
/* Retrieve shipment increment ids of the order */
|
199 |
+
public function getShipmentIds($incrementId) {
|
200 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
201 |
+
/**
|
202 |
+
* Check order existing
|
203 |
+
*/
|
204 |
+
if (!$order->getId()) {
|
205 |
+
$this->_fault('order_not_exists');
|
206 |
+
}
|
207 |
+
$res = array();
|
208 |
+
foreach($order->getShipmentsCollection() as $shipping){
|
209 |
+
array_push($res, $shipping->getIncrementId());
|
210 |
+
};
|
211 |
+
return $res;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Return the list of Shipment Methods
|
216 |
+
* @return array
|
217 |
+
*/
|
218 |
+
public function get_all_shipping_methods()
|
219 |
+
{
|
220 |
+
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
|
221 |
+
|
222 |
+
$options = array();
|
223 |
+
foreach($methods as $_code => $_method)
|
224 |
+
{
|
225 |
+
if(!$_title = Mage::getStoreConfig("carriers/$_code/title"))
|
226 |
+
$_title = $_code;
|
227 |
+
|
228 |
+
$options[] = array('code' => $_code, 'label' => $_title);
|
229 |
+
}
|
230 |
+
return $options;
|
231 |
+
}
|
232 |
+
}
|
app/code/community/Fulfil/Erpconnector/controllers/Adminhtml/InitController.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Fulfil
|
6 |
+
* @package Fulfil_Erpconnector
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Fulfil_Erpconnector_Adminhtml_InitController extends Mage_Adminhtml_Controller_Action
|
11 |
+
{
|
12 |
+
protected $_imported = 'imported';
|
13 |
+
|
14 |
+
/* Initialize the Attribute 'Imported' for orders placed before installing Openlabs_OpenERPConnector Extension */
|
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 |
+
}
|
app/code/community/Fulfil/Erpconnector/controllers/ErpconnectorController.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fulfil_Erpconnector_ErpconnectorController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
|
5 |
+
public function indexAction(){
|
6 |
+
die('its working');
|
7 |
+
}
|
8 |
+
|
9 |
+
}
|
app/code/community/Fulfil/Erpconnector/etc/api.xml
ADDED
@@ -0,0 +1,638 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<ol_websites translate="title" module="core">
|
6 |
+
<title>Website Management</title>
|
7 |
+
<model>erpconnector/ffcore_website</model>
|
8 |
+
<acl>core/store</acl>
|
9 |
+
<methods>
|
10 |
+
<search translate="title" module="core">
|
11 |
+
<title>Return the list of website ids that match with the filter</title>
|
12 |
+
<method>search</method>
|
13 |
+
</search>
|
14 |
+
<list translate="title" module="core">
|
15 |
+
<title>Enumerate websites</title>
|
16 |
+
<method>items</method>
|
17 |
+
</list>
|
18 |
+
<create translate="title" module="core">
|
19 |
+
<title>Create Websites</title>
|
20 |
+
<!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
|
21 |
+
<method>create</method>
|
22 |
+
</create>
|
23 |
+
<info translate="title" module="core">
|
24 |
+
<title>Fetch detail of websites</title>
|
25 |
+
<method>info</method>
|
26 |
+
</info>
|
27 |
+
<update translate="title" module="core">
|
28 |
+
<title>Update websites info</title>
|
29 |
+
<method>update</method>
|
30 |
+
</update>
|
31 |
+
<delete translate="title" module="core">
|
32 |
+
<title>Delete websites</title>
|
33 |
+
<method>delete</method>
|
34 |
+
</delete>
|
35 |
+
</methods>
|
36 |
+
<faults module="core">
|
37 |
+
<website_not_exists>
|
38 |
+
<code>101</code>
|
39 |
+
<message>Requested website not found.</message>
|
40 |
+
</website_not_exists>
|
41 |
+
<data_invalid>
|
42 |
+
<code>102</code>
|
43 |
+
<message>Website creation failed due to invalid data.</message>
|
44 |
+
</data_invalid>
|
45 |
+
</faults>
|
46 |
+
</ol_websites>
|
47 |
+
<ol_groups translate="title" module="core">
|
48 |
+
<title>Groups Management</title>
|
49 |
+
<model>erpconnector/ffcore_groups</model>
|
50 |
+
<acl>core/store</acl>
|
51 |
+
<methods>
|
52 |
+
<search translate="title" module="core">
|
53 |
+
<title>Return the list of groups ids that match with the filter</title>
|
54 |
+
<method>search</method>
|
55 |
+
</search>
|
56 |
+
<list translate="title" module="core">
|
57 |
+
<title>Enumerate groups</title>
|
58 |
+
<method>items</method>
|
59 |
+
</list>
|
60 |
+
<create translate="title" module="core">
|
61 |
+
<title>Create groups</title>
|
62 |
+
<!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
|
63 |
+
<method>create</method>
|
64 |
+
</create>
|
65 |
+
<info translate="title" module="core">
|
66 |
+
<title>Fetch detail of groups</title>
|
67 |
+
<method>info</method>
|
68 |
+
</info>
|
69 |
+
<update translate="title" module="core">
|
70 |
+
<title>Update groups info</title>
|
71 |
+
<method>update</method>
|
72 |
+
</update>
|
73 |
+
<delete translate="title" module="core">
|
74 |
+
<title>Delete groups</title>
|
75 |
+
<method>delete</method>
|
76 |
+
</delete>
|
77 |
+
</methods>
|
78 |
+
<faults module="core">
|
79 |
+
<group_not_exists>
|
80 |
+
<code>101</code>
|
81 |
+
<message>Requested group not found.</message>
|
82 |
+
</group_not_exists>
|
83 |
+
<data_invalid>
|
84 |
+
<code>102</code>
|
85 |
+
<message>group creation failed due to invalid data.</message>
|
86 |
+
</data_invalid>
|
87 |
+
<filters_invalid>
|
88 |
+
<code>103</code>
|
89 |
+
<message>Invalid data fetch filter.</message>
|
90 |
+
</filters_invalid>
|
91 |
+
</faults>
|
92 |
+
</ol_groups>
|
93 |
+
<ol_storeviews translate="title" module="core">
|
94 |
+
<title>Stores Management</title>
|
95 |
+
<model>erpconnector/ffcore_storeviews</model>
|
96 |
+
<acl>core/store</acl>
|
97 |
+
<methods>
|
98 |
+
<search translate="title" module="core">
|
99 |
+
<title>Return the list of storeviews ids that match with the filter</title>
|
100 |
+
<method>search</method>
|
101 |
+
</search>
|
102 |
+
<list translate="title" module="core">
|
103 |
+
<title>Enumerate stores</title>
|
104 |
+
<method>items</method>
|
105 |
+
</list>
|
106 |
+
<create translate="title" module="core">
|
107 |
+
<title>Create stores</title>
|
108 |
+
<!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
|
109 |
+
<method>create</method>
|
110 |
+
</create>
|
111 |
+
<info translate="title" module="core">
|
112 |
+
<title>Fetch detail of stores</title>
|
113 |
+
<method>info</method>
|
114 |
+
</info>
|
115 |
+
<update translate="title" module="core">
|
116 |
+
<title>Update stores info</title>
|
117 |
+
<method>update</method>
|
118 |
+
</update>
|
119 |
+
<delete translate="title" module="core">
|
120 |
+
<title>Delete stores</title>
|
121 |
+
<method>delete</method>
|
122 |
+
</delete>
|
123 |
+
</methods>
|
124 |
+
<faults module="core">
|
125 |
+
<store_not_exists>
|
126 |
+
<code>101</code>
|
127 |
+
<message>Requested store not found.</message>
|
128 |
+
</store_not_exists>
|
129 |
+
<data_invalid>
|
130 |
+
<code>102</code>
|
131 |
+
<message>Store creation failed due to invalid data.</message>
|
132 |
+
</data_invalid>
|
133 |
+
<filters_invalid>
|
134 |
+
<code>103</code>
|
135 |
+
<message>Invalid data fetch filter.</message>
|
136 |
+
</filters_invalid>
|
137 |
+
</faults>
|
138 |
+
</ol_storeviews>
|
139 |
+
<ol_catalog_category_media translate="title" module="catalog">
|
140 |
+
<title>Product Images API</title>
|
141 |
+
<model>erpconnector/ffcatalog_categories</model>
|
142 |
+
<acl>catalog/category</acl>
|
143 |
+
<methods>
|
144 |
+
<list translate="title" module="catalog">
|
145 |
+
<title>Retrieve product image list</title>
|
146 |
+
<method>items</method>
|
147 |
+
</list>
|
148 |
+
<info translate="title" module="catalog">
|
149 |
+
<title>Retrieve product category image</title>
|
150 |
+
</info>
|
151 |
+
<types translate="title" module="catalog">
|
152 |
+
<title>Retrieve product category image types</title>
|
153 |
+
</types>
|
154 |
+
<create translate="title" module="catalog">
|
155 |
+
<title>Upload new product category image </title>
|
156 |
+
<acl>catalog/product/media/create</acl>
|
157 |
+
</create>
|
158 |
+
<update translate="title" module="catalog">
|
159 |
+
<title>Update product category image</title>
|
160 |
+
<acl>catalog/product/media/update</acl>
|
161 |
+
</update>
|
162 |
+
<remove translate="title" module="catalog">
|
163 |
+
<title>Remove product category image</title>
|
164 |
+
<acl>catalog/product/media/remove</acl>
|
165 |
+
</remove>
|
166 |
+
</methods>
|
167 |
+
<faults module="catalog">
|
168 |
+
<create_failure>
|
169 |
+
<code>100</code>
|
170 |
+
<message>Could not create file, check permissions.</message>
|
171 |
+
</create_failure>
|
172 |
+
<category_not_exists>
|
173 |
+
<code>101</code>
|
174 |
+
<message>Product not exists.</message>
|
175 |
+
</category_not_exists>
|
176 |
+
<data_invalid>
|
177 |
+
<code>102</code>
|
178 |
+
<message>Invalid data given. Details in error message.</message>
|
179 |
+
</data_invalid>
|
180 |
+
<not_exists>
|
181 |
+
<code>103</code>
|
182 |
+
<message>Requested image not exists in product images' gallery.</message>
|
183 |
+
</not_exists>
|
184 |
+
<not_created>
|
185 |
+
<code>104</code>
|
186 |
+
<message>Image creation failed. Details in error message.</message>
|
187 |
+
</not_created>
|
188 |
+
<not_updated>
|
189 |
+
<code>105</code>
|
190 |
+
<message>Image not updated. Details in error message.</message>
|
191 |
+
</not_updated>
|
192 |
+
<not_removed>
|
193 |
+
<code>106</code>
|
194 |
+
<message>Image not removed. Details in error message.</message>
|
195 |
+
</not_removed>
|
196 |
+
<not_media>
|
197 |
+
<code>107</code>
|
198 |
+
<message>Error in opening image file</message>
|
199 |
+
</not_media>
|
200 |
+
<filters_invalid>
|
201 |
+
<code>108</code>
|
202 |
+
<message>Invalid data fetch filter.</message>
|
203 |
+
</filters_invalid>
|
204 |
+
</faults>
|
205 |
+
</ol_catalog_category_media>
|
206 |
+
<ol_catalog_product_attribute translate="title" module="catalog">
|
207 |
+
<title>Product Images API</title>
|
208 |
+
<model>erpconnector/ffcatalog_product_attribute</model>
|
209 |
+
<acl>catalog/category</acl>
|
210 |
+
<methods>
|
211 |
+
<list translate="title" module="catalog">
|
212 |
+
<title>Retrieve attribute list</title>
|
213 |
+
<method>items</method>
|
214 |
+
</list>
|
215 |
+
<relations translate="title" module="catalog">
|
216 |
+
<title>Retrieve attribute sets attribute ids</title>
|
217 |
+
<method>relations</method>
|
218 |
+
</relations>
|
219 |
+
<info translate="title" module="catalog">
|
220 |
+
<title>Retrieve full attribute details</title>
|
221 |
+
<method>info</method>
|
222 |
+
</info>
|
223 |
+
<options translate="title" module="catalog">
|
224 |
+
<title>Retrieve options of attributes</title>
|
225 |
+
<method>options</method>
|
226 |
+
</options>
|
227 |
+
</methods>
|
228 |
+
<faults>
|
229 |
+
</faults>
|
230 |
+
</ol_catalog_product_attribute>
|
231 |
+
<ol_catalog_product_attribute_group translate="title" module="catalog">
|
232 |
+
<title>Product Images API</title>
|
233 |
+
<model>erpconnector/ffcatalog_product_attributegroup</model>
|
234 |
+
<acl>catalog/category</acl>
|
235 |
+
<methods>
|
236 |
+
<list translate="title" module="catalog">
|
237 |
+
<title>Retrieve attribute group list</title>
|
238 |
+
<method>items</method>
|
239 |
+
</list>
|
240 |
+
<info translate="title" module="catalog">
|
241 |
+
<title>Retrieve full attribute details</title>
|
242 |
+
<method>info</method>
|
243 |
+
</info>
|
244 |
+
</methods>
|
245 |
+
<faults>
|
246 |
+
</faults>
|
247 |
+
</ol_catalog_product_attribute_group>
|
248 |
+
<ol_customer_groups translate="title" module="core">
|
249 |
+
<title>Groups Management</title>
|
250 |
+
<model>erpconnector/ffcustomer_group</model>
|
251 |
+
<acl>customer/group</acl>
|
252 |
+
<methods>
|
253 |
+
<list translate="title" module="core">
|
254 |
+
<title>Enumerate groups</title>
|
255 |
+
<method>items</method>
|
256 |
+
</list>
|
257 |
+
<create translate="title" module="core">
|
258 |
+
<title>Create groups</title>
|
259 |
+
<method>create</method>
|
260 |
+
</create>
|
261 |
+
<info translate="title" module="core">
|
262 |
+
<title>Fetch detail of groups</title>
|
263 |
+
<method>info</method>
|
264 |
+
</info>
|
265 |
+
<update translate="title" module="core">
|
266 |
+
<title>Update groups info</title>
|
267 |
+
<method>update</method>
|
268 |
+
</update>
|
269 |
+
<delete translate="title" module="core">
|
270 |
+
<title>Delete groups</title>
|
271 |
+
<method>delete</method>
|
272 |
+
</delete>
|
273 |
+
</methods>
|
274 |
+
<faults module="core">
|
275 |
+
<group_not_exists>
|
276 |
+
<code>101</code>
|
277 |
+
<message>Requested group not found.</message>
|
278 |
+
</group_not_exists>
|
279 |
+
<data_invalid>
|
280 |
+
<code>102</code>
|
281 |
+
<message>group creation failed due to invalid data.</message>
|
282 |
+
</data_invalid>
|
283 |
+
<filters_invalid>
|
284 |
+
<code>103</code>
|
285 |
+
<message>Invalid data fetch filter.</message>
|
286 |
+
</filters_invalid>
|
287 |
+
</faults>
|
288 |
+
</ol_customer_groups>
|
289 |
+
<ol_customer_address translate="title" module="core">
|
290 |
+
<title>Address Management</title>
|
291 |
+
<model>erpconnector/ffcustomer_address</model>
|
292 |
+
<acl>customer/group</acl>
|
293 |
+
<methods>
|
294 |
+
<list translate="title" module="core">
|
295 |
+
<title>Enumerate groups</title>
|
296 |
+
<method>items</method>
|
297 |
+
</list>
|
298 |
+
<create translate="title" module="core">
|
299 |
+
<title>Create groups</title>
|
300 |
+
<method>create</method>
|
301 |
+
</create>
|
302 |
+
<info translate="title" module="core">
|
303 |
+
<title>Fetch detail of groups</title>
|
304 |
+
<method>info</method>
|
305 |
+
</info>
|
306 |
+
<update translate="title" module="core">
|
307 |
+
<title>Update groups info</title>
|
308 |
+
<method>update</method>
|
309 |
+
</update>
|
310 |
+
<delete translate="title" module="core">
|
311 |
+
<title>Delete groups</title>
|
312 |
+
<method>delete</method>
|
313 |
+
</delete>
|
314 |
+
</methods>
|
315 |
+
<faults module="core">
|
316 |
+
<customer_not_exists>
|
317 |
+
<code>101</code>
|
318 |
+
<message>Requested Customer not found.</message>
|
319 |
+
</customer_not_exists>
|
320 |
+
<data_invalid>
|
321 |
+
<code>102</code>
|
322 |
+
<message>group creation failed due to invalid data.</message>
|
323 |
+
</data_invalid>
|
324 |
+
<filters_invalid>
|
325 |
+
<code>103</code>
|
326 |
+
<message>Invalid data fetch filter.</message>
|
327 |
+
</filters_invalid>
|
328 |
+
</faults>
|
329 |
+
</ol_customer_address>
|
330 |
+
<ol_customer_subscriber translate="title" module="core">
|
331 |
+
<title>Subscriber Management</title>
|
332 |
+
<model>erpconnector/ffcustomer_subscriber</model>
|
333 |
+
<acl>customer/group</acl>
|
334 |
+
<methods>
|
335 |
+
<list translate="title" module="core">
|
336 |
+
<title>Enumerate subscriber</title>
|
337 |
+
<method>items</method>
|
338 |
+
</list>
|
339 |
+
<create translate="title" module="core">
|
340 |
+
<title>Create subscriber</title>
|
341 |
+
<method>create</method>
|
342 |
+
</create>
|
343 |
+
<info translate="title" module="core">
|
344 |
+
<title>Fetch detail of subscriber</title>
|
345 |
+
<method>info</method>
|
346 |
+
</info>
|
347 |
+
<update translate="title" module="core">
|
348 |
+
<title>Update subscriber info</title>
|
349 |
+
<method>update</method>
|
350 |
+
</update>
|
351 |
+
<delete translate="title" module="core">
|
352 |
+
<title>Delete subscriber</title>
|
353 |
+
<method>delete</method>
|
354 |
+
</delete>
|
355 |
+
</methods>
|
356 |
+
<faults module="core">
|
357 |
+
<customer_not_exists>
|
358 |
+
<code>101</code>
|
359 |
+
<message>Requested Customer not found.</message>
|
360 |
+
</customer_not_exists>
|
361 |
+
<data_invalid>
|
362 |
+
<code>102</code>
|
363 |
+
<message>group creation failed due to invalid data.</message>
|
364 |
+
</data_invalid>
|
365 |
+
<filters_invalid>
|
366 |
+
<code>103</code>
|
367 |
+
<message>Invalid data fetch filter.</message>
|
368 |
+
</filters_invalid>
|
369 |
+
</faults>
|
370 |
+
</ol_customer_subscriber>
|
371 |
+
<ol_customer translate="title" module="core">
|
372 |
+
<title>Customers Management</title>
|
373 |
+
<model>erpconnector/ffcustomer_customer</model>
|
374 |
+
<acl>customer/group</acl>
|
375 |
+
<methods>
|
376 |
+
<search translate="title" module="core">
|
377 |
+
<title>Return the list of customer ids that match with the filter</title>
|
378 |
+
<method>search</method>
|
379 |
+
</search>
|
380 |
+
<list translate="title" module="core">
|
381 |
+
<title>Enumerate Customers</title>
|
382 |
+
<method>items</method>
|
383 |
+
</list>
|
384 |
+
<create translate="title" module="core">
|
385 |
+
<title>Create Customers</title>
|
386 |
+
<method>create</method>
|
387 |
+
</create>
|
388 |
+
<info translate="title" module="core">
|
389 |
+
<title>Fetch detail of customers</title>
|
390 |
+
<method>info</method>
|
391 |
+
</info>
|
392 |
+
<update translate="title" module="core">
|
393 |
+
<title>Update customers info</title>
|
394 |
+
<method>update</method>
|
395 |
+
</update>
|
396 |
+
<delete translate="title" module="core">
|
397 |
+
<title>Delete customers</title>
|
398 |
+
<method>delete</method>
|
399 |
+
</delete>
|
400 |
+
</methods>
|
401 |
+
<faults module="core">
|
402 |
+
<customer_not_exists>
|
403 |
+
<code>101</code>
|
404 |
+
<message>Requested customer not found.</message>
|
405 |
+
</customer_not_exists>
|
406 |
+
<data_invalid>
|
407 |
+
<code>102</code>
|
408 |
+
<message>Customer creation failed due to invalid data.</message>
|
409 |
+
</data_invalid>
|
410 |
+
<filters_invalid>
|
411 |
+
<code>103</code>
|
412 |
+
<message>Invalid data fetch filter.</message>
|
413 |
+
</filters_invalid>
|
414 |
+
</faults>
|
415 |
+
</ol_customer>
|
416 |
+
<ol_catalog_product_tierprice translate="title" module="catalog">
|
417 |
+
<title>Product Tier Price API</title>
|
418 |
+
<model>erpconnector/ffcatalog_product_tierprice</model>
|
419 |
+
<acl>catalog/category</acl>
|
420 |
+
<methods>
|
421 |
+
<list translate="title" module="catalog">
|
422 |
+
<title>Retrieve attribute list</title>
|
423 |
+
<method>items</method>
|
424 |
+
</list>
|
425 |
+
<items2 translate="title" module="catalog">
|
426 |
+
<title>Retrieve attribute list</title>
|
427 |
+
<method>items2</method>
|
428 |
+
</items2>
|
429 |
+
</methods>
|
430 |
+
<faults>
|
431 |
+
<product_not_exists>
|
432 |
+
<code>101</code>
|
433 |
+
<message>Requested product not found.</message>
|
434 |
+
</product_not_exists>
|
435 |
+
<filters_invalid>
|
436 |
+
<code>103</code>
|
437 |
+
<message>Invalid data fetch filter.</message>
|
438 |
+
</filters_invalid>
|
439 |
+
</faults>
|
440 |
+
</ol_catalog_product_tierprice>
|
441 |
+
<ol_catalog_product translate="title" module="core">
|
442 |
+
<title>Address Management</title>
|
443 |
+
<model>erpconnector/ffcatalog_products</model>
|
444 |
+
<acl>catalog/product</acl>
|
445 |
+
<methods>
|
446 |
+
<search translate="title" module="core">
|
447 |
+
<title>Return the list of products ids that match with the filter</title>
|
448 |
+
<method>search</method>
|
449 |
+
</search>
|
450 |
+
<list translate="title" module="core">
|
451 |
+
<title>Enumerate Products</title>
|
452 |
+
<method>items</method>
|
453 |
+
</list>
|
454 |
+
<create translate="title" module="core">
|
455 |
+
<title>Create Products</title>
|
456 |
+
<method>create</method>
|
457 |
+
</create>
|
458 |
+
<biglist translate="title" module="core">
|
459 |
+
<title>Fetch detail of products</title>
|
460 |
+
<method>biglist</method>
|
461 |
+
</biglist>
|
462 |
+
<update translate="title" module="core">
|
463 |
+
<title>Update groups info</title>
|
464 |
+
<method>update</method>
|
465 |
+
</update>
|
466 |
+
<delete translate="title" module="core">
|
467 |
+
<title>Delete groups</title>
|
468 |
+
<method>delete</method>
|
469 |
+
</delete>
|
470 |
+
</methods>
|
471 |
+
<faults module="core">
|
472 |
+
<customer_not_exists>
|
473 |
+
<code>101</code>
|
474 |
+
<message>Requested Customer not found.</message>
|
475 |
+
</customer_not_exists>
|
476 |
+
<data_invalid>
|
477 |
+
<code>102</code>
|
478 |
+
<message>group creation failed due to invalid data.</message>
|
479 |
+
</data_invalid>
|
480 |
+
<filters_invalid>
|
481 |
+
<code>103</code>
|
482 |
+
<message>Invalid data fetch filter.</message>
|
483 |
+
</filters_invalid>
|
484 |
+
</faults>
|
485 |
+
</ol_catalog_product>
|
486 |
+
<ol_catalog_product_attributeset translate="title" module="core">
|
487 |
+
<title>Attribute Set Management</title>
|
488 |
+
<model>erpconnector/ffcatalog_product_attributeset</model>
|
489 |
+
<acl>catalog/product</acl>
|
490 |
+
<methods>
|
491 |
+
<list translate="title" module="core">
|
492 |
+
<title>Enumerate Attribute sets</title>
|
493 |
+
<method>items</method>
|
494 |
+
</list>
|
495 |
+
</methods>
|
496 |
+
<faults module="core">
|
497 |
+
<customer_not_exists>
|
498 |
+
<code>101</code>
|
499 |
+
<message>Requested Customer not found.</message>
|
500 |
+
</customer_not_exists>
|
501 |
+
<data_invalid>
|
502 |
+
<code>102</code>
|
503 |
+
<message>group creation failed due to invalid data.</message>
|
504 |
+
</data_invalid>
|
505 |
+
<filters_invalid>
|
506 |
+
<code>103</code>
|
507 |
+
<message>Invalid data fetch filter.</message>
|
508 |
+
</filters_invalid>
|
509 |
+
</faults>
|
510 |
+
</ol_catalog_product_attributeset>
|
511 |
+
<ol_catalog_product_link>
|
512 |
+
<title>Product Link</title>
|
513 |
+
<model>erpconnector/ffcatalog_product_link</model>
|
514 |
+
<acl>catalog/product</acl>
|
515 |
+
<methods>
|
516 |
+
<list translate="title" module="core">
|
517 |
+
<title>Enumerate configurable Products</title>
|
518 |
+
<method>items</method>
|
519 |
+
</list>
|
520 |
+
<assign translate="title" module="catalog">
|
521 |
+
<title>Assign simple product in configurable product</title>
|
522 |
+
</assign>
|
523 |
+
<remove translate="title" module="catalog">
|
524 |
+
<title>Remove simple products in configurable product</title>
|
525 |
+
</remove>
|
526 |
+
<listSuperAttributes translate="title" module="catalog">
|
527 |
+
<title>Get configurable attribute values for a configurable product</title>
|
528 |
+
</listSuperAttributes>
|
529 |
+
<createSuperAttribute translate="title" module="catalog">
|
530 |
+
<title>Create configurable attribute for a configurable product</title>
|
531 |
+
</createSuperAttribute>
|
532 |
+
<removeSuperAttribute translate="title" module="catalog">
|
533 |
+
<title>Remove super attribute</title>
|
534 |
+
</removeSuperAttribute>
|
535 |
+
<setSuperAttributeValues translate="title" module="catalog">
|
536 |
+
<title>Set configurable attribute values for super attribute</title>
|
537 |
+
</setSuperAttributeValues>
|
538 |
+
</methods>
|
539 |
+
</ol_catalog_product_link>
|
540 |
+
<sales_order translate="title" module="Fulfil_Erpconnector">
|
541 |
+
<model>sales/order_api</model>
|
542 |
+
<title>Custom Sales Orders API</title>
|
543 |
+
<methods>
|
544 |
+
<search translate="title" module="Fulfil_Erpconnector">
|
545 |
+
<title>Return the list of products ids that match with the filter</title>
|
546 |
+
<method>search</method>
|
547 |
+
</search>
|
548 |
+
<retrieve translate="title" module="Fulfil_Erpconnector">
|
549 |
+
<title>Retrieve list of orders by filters, nb max, etc...</title>
|
550 |
+
<method>retrieveOrders</method>
|
551 |
+
</retrieve>
|
552 |
+
<done translate="title" module="Fulfil_Erpconnector">
|
553 |
+
<title>Set Flag to TRUE for imported orders</title>
|
554 |
+
<method>setFlagForOrder</method>
|
555 |
+
</done>
|
556 |
+
<get_child translate="title" module="Fulfil_Erpconnector">
|
557 |
+
<title>get The Child of The Order Edited</title>
|
558 |
+
<method>getOrderChild</method>
|
559 |
+
</get_child>
|
560 |
+
<get_parent translate="title" module="Fulfil_Erpconnector">
|
561 |
+
<title>get The Parent of the order annulated</title>
|
562 |
+
<method>getOrderParent</method>
|
563 |
+
</get_parent>
|
564 |
+
<get_invoice_ids translate="title" module="Fulfil_Erpconnector">
|
565 |
+
<title>get The Invoices Increment ids of the order</title>
|
566 |
+
<method>getInvoiceIds</method>
|
567 |
+
</get_invoice_ids>
|
568 |
+
<get_shipment_ids translate="title" module="Fulfil_Erpconnector">
|
569 |
+
<title>get The Shipment Increment ids of the order</title>
|
570 |
+
<method>getShipmentIds</method>
|
571 |
+
</get_shipment_ids>
|
572 |
+
<get_order_states translate="title" module="Fulfil_Erpconnector">
|
573 |
+
<title>Fetch all the available states for an order</title>
|
574 |
+
<method>getOrderStates</method>
|
575 |
+
</get_order_states>
|
576 |
+
<shipping_methods translate="title" module="Fulfil_Erpconnector">
|
577 |
+
<title>Fetch all the available Shipment Methods</title>
|
578 |
+
<method>get_all_shipping_methods</method>
|
579 |
+
</shipping_methods>
|
580 |
+
</methods>
|
581 |
+
</sales_order>
|
582 |
+
<catalog_product translate="title" module="catalog">
|
583 |
+
<title>Product API</title>
|
584 |
+
<model>catalog/product_api</model>
|
585 |
+
<acl>catalog/product</acl>
|
586 |
+
<methods>
|
587 |
+
<create_bundle translate="title" module="Fulfil_Erpconnector">
|
588 |
+
<title>Create Bundle Products with Custom Options and Bundle Items</title>
|
589 |
+
<method>createBundleProducts</method>
|
590 |
+
</create_bundle>
|
591 |
+
</methods>
|
592 |
+
</catalog_product>
|
593 |
+
<ferp_catalog_category translate="title" module="Fulfil_Erpconnector">
|
594 |
+
<title>Product Category API</title>
|
595 |
+
<model>erpconnector/ferpcatalog_category_api</model>
|
596 |
+
<acl>catalog/category/move</acl>
|
597 |
+
<methods>
|
598 |
+
<search translate="title" module="core">
|
599 |
+
<title>Return the list of product category ids that match with the filter</title>
|
600 |
+
<method>search</method>
|
601 |
+
</search>
|
602 |
+
<move translate="title" module="Fulfil_Erpconnector">
|
603 |
+
<title>Move category in tree</title>
|
604 |
+
<method>move</method>
|
605 |
+
</move>
|
606 |
+
</methods>
|
607 |
+
</ferp_catalog_category>
|
608 |
+
|
609 |
+
<ferp_cataloginventory_stock_item translate="title" module="Fulfil_Erpconnector">
|
610 |
+
<model>erpconnector/ferpstock_item_api</model>
|
611 |
+
<title>Inventory API</title>
|
612 |
+
<acl>cataloginventory</acl>
|
613 |
+
<methods>
|
614 |
+
<update translate="title" module="Fulfil_Erpconnector">
|
615 |
+
<title>Update product stock data</title>
|
616 |
+
<acl>cataloginventory/update</acl>
|
617 |
+
<method>update</method>
|
618 |
+
</update>
|
619 |
+
<massive_update translate="title" module="Fulfil_Erpconnector">
|
620 |
+
<title>Massive Update product stock data</title>
|
621 |
+
<acl>cataloginventory/update</acl>
|
622 |
+
<method>massive_update</method>
|
623 |
+
</massive_update>
|
624 |
+
</methods>
|
625 |
+
<faults module="cataloginventory">
|
626 |
+
<product_not_exists>
|
627 |
+
<code>101</code>
|
628 |
+
<message>Product not exists.</message>
|
629 |
+
</product_not_exists>
|
630 |
+
<not_updated>
|
631 |
+
<code>102</code>
|
632 |
+
<message>Product inventory not updated. Details in error message.</message>
|
633 |
+
</not_updated>
|
634 |
+
</faults>
|
635 |
+
</ferp_cataloginventory_stock_item>
|
636 |
+
</resources>
|
637 |
+
</api>
|
638 |
+
</config>
|
app/code/community/Fulfil/Erpconnector/etc/config.xml
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Fulfil_Erpconnector>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Fulfil_Erpconnector>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<erpconnector>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Fulfil_Erpconnector</module>
|
14 |
+
<frontName>erpconnector</frontName>
|
15 |
+
</args>
|
16 |
+
</erpconnector>
|
17 |
+
</routers>
|
18 |
+
</frontend>
|
19 |
+
<global>
|
20 |
+
<models>
|
21 |
+
<erpconnector>
|
22 |
+
<class>Fulfil_Erpconnector_Model</class>
|
23 |
+
</erpconnector>
|
24 |
+
<sales>
|
25 |
+
<rewrite>
|
26 |
+
<order_api>Fulfil_Erpconnector_Model_Sales_Order_Api</order_api>
|
27 |
+
</rewrite>
|
28 |
+
</sales>
|
29 |
+
<catalog>
|
30 |
+
<rewrite>
|
31 |
+
<product_api>Fulfil_Erpconnector_Model_Catalog_Product_Api</product_api>
|
32 |
+
</rewrite>
|
33 |
+
</catalog>
|
34 |
+
</models>
|
35 |
+
<resources>
|
36 |
+
<erpconnector_setup>
|
37 |
+
<setup>
|
38 |
+
<module>Fulfil_Erpconnector</module>
|
39 |
+
</setup>
|
40 |
+
<connection>
|
41 |
+
<use>core_setup</use>
|
42 |
+
</connection>
|
43 |
+
</erpconnector_setup>
|
44 |
+
<erpconnector_write>
|
45 |
+
<connection>
|
46 |
+
<use>core_write</use>
|
47 |
+
</connection>
|
48 |
+
</erpconnector_write>
|
49 |
+
<erpconnector_read>
|
50 |
+
<connection>
|
51 |
+
<use>core_read</use>
|
52 |
+
</connection>
|
53 |
+
</erpconnector_read>
|
54 |
+
</resources>
|
55 |
+
<blocks>
|
56 |
+
<erpconnector>
|
57 |
+
<class>Fulfil_Erpconnector_Block</class>
|
58 |
+
</erpconnector>
|
59 |
+
</blocks>
|
60 |
+
<helpers>
|
61 |
+
<erpconnector>
|
62 |
+
<class>Fulfil_Erpconnector_Helper</class>
|
63 |
+
</erpconnector>
|
64 |
+
</helpers>
|
65 |
+
<events>
|
66 |
+
<sales_order_place_after>
|
67 |
+
<observers>
|
68 |
+
<init_imported_after_place_order>
|
69 |
+
<type>singleton</type>
|
70 |
+
<class>erpconnector/observer</class>
|
71 |
+
<method>initImported</method>
|
72 |
+
</init_imported_after_place_order>
|
73 |
+
</observers>
|
74 |
+
</sales_order_place_after>
|
75 |
+
</events>
|
76 |
+
</global>
|
77 |
+
<admin>
|
78 |
+
<routers>
|
79 |
+
<erpconnector>
|
80 |
+
<use>admin</use>
|
81 |
+
<args>
|
82 |
+
<module>Fulfil_Erpconnector</module>
|
83 |
+
<frontName>connector</frontName>
|
84 |
+
</args>
|
85 |
+
</erpconnector>
|
86 |
+
</routers>
|
87 |
+
</admin>
|
88 |
+
</config>
|
app/code/community/Fulfil/Erpconnector/sql/erpconnector_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author Fulfil
|
5 |
+
* @package Fulfil_Erpconnector
|
6 |
+
*
|
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 |
+
|
53 |
+
/* End */
|
54 |
+
$installer->endSetup();
|
app/etc/modules/Fulfil_Erpconnector.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
##############################################################################
|
5 |
+
#
|
6 |
+
# OpenERP, Open Source Management Solution
|
7 |
+
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
8 |
+
# Sharoon Thomas
|
9 |
+
#
|
10 |
+
# This program is free software: you can redistribute it and/or modify
|
11 |
+
# it under the terms of the GNU General Public License as published by
|
12 |
+
# the Free Software Foundation, either version 3 of the License, or
|
13 |
+
# (at your option) any later version.
|
14 |
+
#
|
15 |
+
# This program is distributed in the hope that it will be useful,
|
16 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
# GNU General Public License for more details.
|
19 |
+
#
|
20 |
+
# You should have received a copy of the GNU General Public License
|
21 |
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
#
|
23 |
+
##############################################################################
|
24 |
+
# * @category Community
|
25 |
+
# * @package
|
26 |
+
# * @copyright Copyright (c) 2009 Sharoon Thomas, openlabs.co.in
|
27 |
+
# * @license GPL-3
|
28 |
+
# */
|
29 |
+
-->
|
30 |
+
<config>
|
31 |
+
<modules>
|
32 |
+
<Fulfil_Erpconnector>
|
33 |
+
<codePool>community</codePool>
|
34 |
+
<active>true</active>
|
35 |
+
<depends>
|
36 |
+
<Mage_Api />
|
37 |
+
<Mage_Catalog />
|
38 |
+
</depends>
|
39 |
+
</Fulfil_Erpconnector>
|
40 |
+
</modules>
|
41 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Fulfil-io</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Magento core API extension for Fulfil.io ERP.</summary>
|
10 |
+
<description>This magento extension, provides additional API methods for use by Fulfil.io ERP.</description>
|
11 |
+
<notes>This is initial version of Fulfil.io ERP connector.</notes>
|
12 |
+
<authors><author><name>Tarun Bhardwaj</name><user>tarunbhardwaj</user><email>tarun.bhardwaj@fulfil.io</email></author></authors>
|
13 |
+
<date>2016-05-31</date>
|
14 |
+
<time>14:06:34</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Fulfil"><dir name="Erpconnector"><dir name="Helper"><file name="Data.php" hash="0ecb959b8f9d10249913353870e3d162"/></dir><dir name="Model"><dir name="Catalog"><dir name="Product"><file name="Api.php" hash="fee522a38ba48c39907e6a7d8ae166c6"/></dir></dir><dir name="Ferpcatalog"><dir name="Category"><file name="Api.php" hash="04713df7bac18e5674561e21ce2a9f10"/></dir></dir><dir name="Ferpstock"><dir name="Item"><file name="Api.php" hash="dd0c35194a50b6e493f6b50e5bdadc19"/></dir></dir><dir name="Ffcatalog"><file name="Categories.php" hash="2e2dfbca0e1575cc461d799ec499915e"/><dir name="Product"><file name="Attribute.php" hash="ccdceab23101943c9edc7c4f7e549f53"/><file name="Attributegroup.php" hash="1f83896738b14e401985153bb9866393"/><file name="Attributeset.php" hash="a4204074a269e818237f725dfb3db93b"/><file name="Link.php" hash="107d5d5333cb02ca6e63408fe15988df"/><file name="Tierprice.php" hash="4860b6d0f98122a8331edf0edb7bb5d7"/></dir><file name="Products.php" hash="3027252078207d40fb0deea59865caa7"/></dir><dir name="Ffcore"><file name="Groups.php" hash="bdccdafc1a789a466a38ef4f54d66737"/><file name="Storeviews.php" hash="46fc81aa8d91976a1754603164fd87bb"/><file name="Website.php" hash="79ce162389db8ad9f36a32b49d57aa6c"/></dir><dir name="Ffcustomer"><file name="Address.php" hash="60be39e9b011d8989b7abd3d8dfacc4c"/><file name="Customer.php" hash="5aef2014de44c518a5e413668db1724b"/><file name="Group.php" hash="75885710d447ce9f52aa38f5fd210500"/><file name="Subscriber.php" hash="ace8c4f942e757e4332ce70b4c43b9de"/></dir><file name="Observer.php" hash="4e747cc300c0d8dc63c514808fc78eb4"/><dir name="Sales"><dir name="Order"><file name="Api.php" hash="f40abe6bbccb550e99af33700764ae00"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="InitController.php" hash="13384f1d603b9eadaf3a9a6e645a8040"/></dir><file name="ErpconnectorController.php" hash="57de05b026ca0329680abb448fd99aaa"/></dir><dir name="etc"><file name="api.xml" hash="5b933844cbdcf2b15a3724dcebb008bf"/><file name="config.xml" hash="fe5d38573ed2d2265cab1e244b9419a3"/></dir><dir name="sql"><dir name="erpconnector_setup"><file name="mysql4-install-0.0.1.php" hash="140ad2cca875d79b0b30159b012f203c"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fulfil_Erpconnector.xml" hash="83e0805fcc7f6bc52806c01a9cdcf1ff"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|