Version Notes
1.1.0
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | GoDataFeed |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.10 to 1.1.0
- app/code/local/GoDataFeed/Services/Model/Api/Resource/Checkout.php +208 -0
- app/code/local/GoDataFeed/Services/Model/Api/Resource/Checkout/Product.php +134 -0
- app/code/local/GoDataFeed/Services/Model/Api/Resource/Customer.php +184 -0
- app/code/local/GoDataFeed/Services/Model/Cart/Api.php +107 -0
- app/code/local/GoDataFeed/Services/Model/Cart/Customer/Api.php +213 -0
- app/code/local/GoDataFeed/Services/Model/Cart/Payment/Api.php +147 -0
- app/code/local/GoDataFeed/Services/Model/Cart/Product/Api.php +90 -0
- app/code/local/GoDataFeed/Services/Model/Catalog/Product/Api.php +56 -33
- app/code/local/GoDataFeed/Services/Model/Method/OrderSync.php +13 -0
- app/code/local/GoDataFeed/Services/Model/Order/Payment.php +14 -0
- app/code/local/GoDataFeed/Services/Model/Quote.php +15 -0
- app/code/local/GoDataFeed/Services/Model/Quote/Payment.php +52 -0
- app/code/local/GoDataFeed/Services/Model/Service/Quote.php +247 -0
- app/code/local/GoDataFeed/Services/Model/Version/Api.php +1 -1
- app/code/local/GoDataFeed/Services/etc/api.xml +237 -5
- app/code/local/GoDataFeed/Services/etc/config.xml +1 -2
- package.xml +5 -5
app/code/local/GoDataFeed/Services/Model/Api/Resource/Checkout.php
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Api_Resource)
|
| 3 |
+
// Modifications :
|
| 4 |
+
// - _getQuote
|
| 5 |
+
class GoDataFeed_Services_Model_Api_Resource_Checkout extends Mage_Api_Model_Resource_Abstract
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Attributes map array per entity type
|
| 9 |
+
*
|
| 10 |
+
* @var array
|
| 11 |
+
*/
|
| 12 |
+
protected $_attributesMap = array(
|
| 13 |
+
'global' => array(),
|
| 14 |
+
);
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Default ignored attribute codes per entity type
|
| 18 |
+
*
|
| 19 |
+
* @var array
|
| 20 |
+
*/
|
| 21 |
+
protected $_ignoredAttributeCodes = array(
|
| 22 |
+
'global' => array('entity_id', 'attribute_set_id', 'entity_type_id')
|
| 23 |
+
);
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Field name in session for saving store id
|
| 27 |
+
* @var string
|
| 28 |
+
*/
|
| 29 |
+
protected $_storeIdSessionField = 'store_id';
|
| 30 |
+
|
| 31 |
+
//
|
| 32 |
+
// /**
|
| 33 |
+
// * Check if quote already exist with provided quoteId for creating
|
| 34 |
+
// *
|
| 35 |
+
// * @param int $quoteId
|
| 36 |
+
// * @return bool
|
| 37 |
+
// */
|
| 38 |
+
// protected function _isQuoteExist($quoteId)
|
| 39 |
+
// {
|
| 40 |
+
// if (empty($quoteId)) {
|
| 41 |
+
// return false;
|
| 42 |
+
// }
|
| 43 |
+
//
|
| 44 |
+
// try {
|
| 45 |
+
// $quote = $this->_getQuote($quoteId);
|
| 46 |
+
// } catch (Mage_Api_Exception $e) {
|
| 47 |
+
// return false;
|
| 48 |
+
// }
|
| 49 |
+
//
|
| 50 |
+
// if (!is_null($quote->getId())) {
|
| 51 |
+
// $this->_fault('quote_already_exist');
|
| 52 |
+
// }
|
| 53 |
+
//
|
| 54 |
+
// return false;
|
| 55 |
+
// }
|
| 56 |
+
//
|
| 57 |
+
/**
|
| 58 |
+
* Retrieves store id from store code, if no store id specified,
|
| 59 |
+
* it use set session or admin store
|
| 60 |
+
*
|
| 61 |
+
* @param string|int $store
|
| 62 |
+
* @return int
|
| 63 |
+
*/
|
| 64 |
+
protected function _getStoreId($store = null)
|
| 65 |
+
{
|
| 66 |
+
if (is_null($store)) {
|
| 67 |
+
$store = ($this->_getSession()->hasData($this->_storeIdSessionField)
|
| 68 |
+
? $this->_getSession()->getData($this->_storeIdSessionField) : 0);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
try {
|
| 72 |
+
$storeId = Mage::app()->getStore($store)->getId();
|
| 73 |
+
|
| 74 |
+
} catch (Mage_Core_Model_Store_Exception $e) {
|
| 75 |
+
$this->_fault('store_not_exists');
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return $storeId;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// MAGENTO 1.6.2
|
| 82 |
+
// Modifications :
|
| 83 |
+
// - call to non existing (in Mage 1.4.0.1) loadByIdWithoutStore removed *1*
|
| 84 |
+
protected function _getQuote($quoteId, $store = null)
|
| 85 |
+
{
|
| 86 |
+
/** @var $quote Mage_Sales_Model_Quote */
|
| 87 |
+
$quote = Mage::getModel("sales/quote");
|
| 88 |
+
|
| 89 |
+
// *1*
|
| 90 |
+
// if (!(is_string($store) || is_integer($store))) {
|
| 91 |
+
// $quote->loadByIdWithoutStore($quoteId);
|
| 92 |
+
// } else {
|
| 93 |
+
$storeId = $this->_getStoreId($store);
|
| 94 |
+
|
| 95 |
+
$quote->setStoreId($storeId)
|
| 96 |
+
->load($quoteId);
|
| 97 |
+
// }
|
| 98 |
+
if (is_null($quote->getId())) {
|
| 99 |
+
$this->_fault('quote_not_exists');
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
return $quote;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
// /**
|
| 106 |
+
// * Get store identifier by quote identifier
|
| 107 |
+
// *
|
| 108 |
+
// * @param int $quoteId
|
| 109 |
+
// * @return int
|
| 110 |
+
// */
|
| 111 |
+
// protected function _getStoreIdFromQuote($quoteId)
|
| 112 |
+
// {
|
| 113 |
+
// /** @var $quote Mage_Sales_Model_Quote */
|
| 114 |
+
// $quote = Mage::getModel('sales/quote')
|
| 115 |
+
// ->loadByIdWithoutStore($quoteId);
|
| 116 |
+
//
|
| 117 |
+
// return $quote->getStoreId();
|
| 118 |
+
// }
|
| 119 |
+
//
|
| 120 |
+
// /**
|
| 121 |
+
// * Update attributes for entity
|
| 122 |
+
// *
|
| 123 |
+
// * @param array $data
|
| 124 |
+
// * @param Mage_Core_Model_Abstract $object
|
| 125 |
+
// * @param string $type
|
| 126 |
+
// * @param array|null $attributes
|
| 127 |
+
// * @return Mage_Checkout_Model_Api_Resource
|
| 128 |
+
// */
|
| 129 |
+
// protected function _updateAttributes($data, $object, $type, array $attributes = null)
|
| 130 |
+
// {
|
| 131 |
+
// foreach ($data as $attribute => $value) {
|
| 132 |
+
// if ($this->_isAllowedAttribute($attribute, $type, $attributes)) {
|
| 133 |
+
// $object->setData($attribute, $value);
|
| 134 |
+
// }
|
| 135 |
+
// }
|
| 136 |
+
//
|
| 137 |
+
// return $this;
|
| 138 |
+
// }
|
| 139 |
+
//
|
| 140 |
+
// /**
|
| 141 |
+
// * Retrieve entity attributes values
|
| 142 |
+
// *
|
| 143 |
+
// * @param Mage_Core_Model_Abstract $object
|
| 144 |
+
// * @param string $type
|
| 145 |
+
// * @param array $attributes
|
| 146 |
+
// * @return Mage_Checkout_Model_Api_Resource
|
| 147 |
+
// */
|
| 148 |
+
// protected function _getAttributes($object, $type, array $attributes = null)
|
| 149 |
+
// {
|
| 150 |
+
// $result = array();
|
| 151 |
+
//
|
| 152 |
+
// if (!is_object($object)) {
|
| 153 |
+
// return $result;
|
| 154 |
+
// }
|
| 155 |
+
//
|
| 156 |
+
// foreach ($object->getData() as $attribute => $value) {
|
| 157 |
+
// if (is_object($value)) {
|
| 158 |
+
// continue;
|
| 159 |
+
// }
|
| 160 |
+
//
|
| 161 |
+
// if ($this->_isAllowedAttribute($attribute, $type, $attributes)) {
|
| 162 |
+
// $result[$attribute] = $value;
|
| 163 |
+
// }
|
| 164 |
+
// }
|
| 165 |
+
//
|
| 166 |
+
// foreach ($this->_attributesMap['global'] as $alias => $attributeCode) {
|
| 167 |
+
// $result[$alias] = $object->getData($attributeCode);
|
| 168 |
+
// }
|
| 169 |
+
//
|
| 170 |
+
// if (isset($this->_attributesMap[$type])) {
|
| 171 |
+
// foreach ($this->_attributesMap[$type] as $alias => $attributeCode) {
|
| 172 |
+
// $result[$alias] = $object->getData($attributeCode);
|
| 173 |
+
// }
|
| 174 |
+
// }
|
| 175 |
+
//
|
| 176 |
+
// return $result;
|
| 177 |
+
// }
|
| 178 |
+
//
|
| 179 |
+
// /**
|
| 180 |
+
// * Check is attribute allowed to usage
|
| 181 |
+
// *
|
| 182 |
+
// * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
|
| 183 |
+
// * @param string $type
|
| 184 |
+
// * @param array $attributes
|
| 185 |
+
// * @return bool
|
| 186 |
+
// */
|
| 187 |
+
// protected function _isAllowedAttribute($attributeCode, $type, array $attributes = null)
|
| 188 |
+
// {
|
| 189 |
+
// if (!empty($attributes)
|
| 190 |
+
// && !(in_array($attributeCode, $attributes))
|
| 191 |
+
// ) {
|
| 192 |
+
// return false;
|
| 193 |
+
// }
|
| 194 |
+
//
|
| 195 |
+
// if (in_array($attributeCode, $this->_ignoredAttributeCodes['global'])) {
|
| 196 |
+
// return false;
|
| 197 |
+
// }
|
| 198 |
+
//
|
| 199 |
+
// if (isset($this->_ignoredAttributeCodes[$type])
|
| 200 |
+
// && in_array($attributeCode, $this->_ignoredAttributeCodes[$type])
|
| 201 |
+
// ) {
|
| 202 |
+
// return false;
|
| 203 |
+
// }
|
| 204 |
+
//
|
| 205 |
+
// return true;
|
| 206 |
+
// }
|
| 207 |
+
|
| 208 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Api/Resource/Checkout/Product.php
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Api_Resource_Product)
|
| 3 |
+
// Modifications :
|
| 4 |
+
// - extends
|
| 5 |
+
// - _getProduct
|
| 6 |
+
class GoDataFeed_Services_Model_Api_Resource_Checkout_Product extends GoDataFeed_Services_Model_Api_Resource_Checkout
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Default ignored attribute codes
|
| 10 |
+
*
|
| 11 |
+
* @var array
|
| 12 |
+
*/
|
| 13 |
+
protected $_ignoredAttributeCodes = array('entity_id', 'attribute_set_id', 'entity_type_id');
|
| 14 |
+
|
| 15 |
+
// MAGENTO 1.6.2
|
| 16 |
+
// Modifications :
|
| 17 |
+
// - code taken from Mage_Catalog_Helper_Product which lacks the getProduct method in 1.4
|
| 18 |
+
// - *1* bug fix when using SKU instead of productId
|
| 19 |
+
protected function _getProduct($productId, $store = null, $identifierType = null)
|
| 20 |
+
{
|
| 21 |
+
// $product = Mage::helper('catalog/product')->getProduct($productId,
|
| 22 |
+
// $this->_getStoreId($store),
|
| 23 |
+
// $identifierType
|
| 24 |
+
// );
|
| 25 |
+
// return $product;
|
| 26 |
+
|
| 27 |
+
$loadByIdOnFalse = false;
|
| 28 |
+
if ($identifierType == null) {
|
| 29 |
+
if (is_string($productId) && !preg_match("/^[+-]?[1-9][0-9]*$|^0$/", $productId)) {
|
| 30 |
+
$identifierType = 'sku';
|
| 31 |
+
$loadByIdOnFalse = true;
|
| 32 |
+
} else {
|
| 33 |
+
$identifierType = 'id';
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/** @var $product Mage_Catalog_Model_Product */
|
| 38 |
+
$product = Mage::getModel('catalog/product');
|
| 39 |
+
if ($store !== null) {
|
| 40 |
+
$product->setStoreId($store);
|
| 41 |
+
}
|
| 42 |
+
if ($identifierType == 'sku') {
|
| 43 |
+
$idBySku = $product->getIdBySku($productId);
|
| 44 |
+
if ($idBySku) {
|
| 45 |
+
$productId = $idBySku;
|
| 46 |
+
$loadByIdOnFalse = true; // *1* http://www.magentocommerce.com/boards/viewthread/245129
|
| 47 |
+
}
|
| 48 |
+
if ($loadByIdOnFalse) {
|
| 49 |
+
$identifierType = 'id';
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
if ($identifierType == 'id' && is_numeric($productId)) {
|
| 54 |
+
$productId = !is_float($productId) ? (int)$productId : 0;
|
| 55 |
+
$product->load($productId);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
return $product;
|
| 59 |
+
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Get request for product add to cart procedure
|
| 64 |
+
*
|
| 65 |
+
* @param mixed $requestInfo
|
| 66 |
+
* @return Varien_Object
|
| 67 |
+
*/
|
| 68 |
+
protected function _getProductRequest($requestInfo)
|
| 69 |
+
{
|
| 70 |
+
if ($requestInfo instanceof Varien_Object) {
|
| 71 |
+
$request = $requestInfo;
|
| 72 |
+
} elseif (is_numeric($requestInfo)) {
|
| 73 |
+
$request = new Varien_Object();
|
| 74 |
+
$request->setQty($requestInfo);
|
| 75 |
+
} else {
|
| 76 |
+
$request = new Varien_Object($requestInfo);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if (!$request->hasQty()) {
|
| 80 |
+
$request->setQty(1);
|
| 81 |
+
}
|
| 82 |
+
return $request;
|
| 83 |
+
}
|
| 84 |
+
//
|
| 85 |
+
// /**
|
| 86 |
+
// * Get QuoteItem by Product and request info
|
| 87 |
+
// *
|
| 88 |
+
// * @param Mage_Sales_Model_Quote $quote
|
| 89 |
+
// * @param Mage_Catalog_Model_Product $product
|
| 90 |
+
// * @param Varien_Object $requestInfo
|
| 91 |
+
// * @return Mage_Sales_Model_Quote_Item
|
| 92 |
+
// * @throw Mage_Core_Exception
|
| 93 |
+
// */
|
| 94 |
+
// protected function _getQuoteItemByProduct(Mage_Sales_Model_Quote $quote,
|
| 95 |
+
// Mage_Catalog_Model_Product $product,
|
| 96 |
+
// Varien_Object $requestInfo)
|
| 97 |
+
// {
|
| 98 |
+
// $cartCandidates = $product->getTypeInstance(true)
|
| 99 |
+
// ->prepareForCartAdvanced($requestInfo,
|
| 100 |
+
// $product,
|
| 101 |
+
// Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL
|
| 102 |
+
// );
|
| 103 |
+
//
|
| 104 |
+
// /**
|
| 105 |
+
// * Error message
|
| 106 |
+
// */
|
| 107 |
+
// if (is_string($cartCandidates)) {
|
| 108 |
+
// throw Mage::throwException($cartCandidates);
|
| 109 |
+
// }
|
| 110 |
+
//
|
| 111 |
+
// /**
|
| 112 |
+
// * If prepare process return one object
|
| 113 |
+
// */
|
| 114 |
+
// if (!is_array($cartCandidates)) {
|
| 115 |
+
// $cartCandidates = array($cartCandidates);
|
| 116 |
+
// }
|
| 117 |
+
//
|
| 118 |
+
// /** @var $item Mage_Sales_Model_Quote_Item */
|
| 119 |
+
// $item = null;
|
| 120 |
+
// foreach ($cartCandidates as $candidate) {
|
| 121 |
+
// if ($candidate->getParentProductId()) {
|
| 122 |
+
// continue;
|
| 123 |
+
// }
|
| 124 |
+
//
|
| 125 |
+
// $item = $quote->getItemByProduct($candidate);
|
| 126 |
+
// }
|
| 127 |
+
//
|
| 128 |
+
// if (is_null($item)) {
|
| 129 |
+
// $item = Mage::getModel("sales/quote_item");
|
| 130 |
+
// }
|
| 131 |
+
//
|
| 132 |
+
// return $item;
|
| 133 |
+
// }
|
| 134 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Api/Resource/Customer.php
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Api_Resource_Customer)
|
| 3 |
+
// Modifications :
|
| 4 |
+
// - extends
|
| 5 |
+
// - _prepareGuestQuote : bug fix, mail not sent to guest customer
|
| 6 |
+
class GoDataFeed_Services_Model_Api_Resource_Customer extends GoDataFeed_Services_Model_Api_Resource_Checkout
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* Customer address types
|
| 10 |
+
*/
|
| 11 |
+
const ADDRESS_BILLING = Mage_Sales_Model_Quote_Address::TYPE_BILLING;
|
| 12 |
+
const ADDRESS_SHIPPING = Mage_Sales_Model_Quote_Address::TYPE_SHIPPING;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Customer checkout types
|
| 16 |
+
*/
|
| 17 |
+
const MODE_CUSTOMER = Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
| 18 |
+
const MODE_REGISTER = Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
| 19 |
+
const MODE_GUEST = Mage_Checkout_Model_Type_Onepage::METHOD_GUEST;
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
*
|
| 24 |
+
*/
|
| 25 |
+
protected function _getCustomer($customerId)
|
| 26 |
+
{
|
| 27 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 28 |
+
$customer = Mage::getModel('customer/customer')
|
| 29 |
+
->load($customerId);
|
| 30 |
+
if (!$customer->getId()) {
|
| 31 |
+
$this->_fault('customer_not_exists');
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return $customer;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Get customer address by identifier
|
| 39 |
+
*
|
| 40 |
+
* @param int $addressId
|
| 41 |
+
* @return Mage_Customer_Model_Address
|
| 42 |
+
*/
|
| 43 |
+
protected function _getCustomerAddress($addressId)
|
| 44 |
+
{
|
| 45 |
+
$address = Mage::getModel('customer/address')->load((int)$addressId);
|
| 46 |
+
if (is_null($address->getId())) {
|
| 47 |
+
$this->_fault('invalid_address_id');
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
$address->explodeStreetAddress();
|
| 51 |
+
if ($address->getRegionId()) {
|
| 52 |
+
$address->setRegion($address->getRegionId());
|
| 53 |
+
}
|
| 54 |
+
return $address;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 59 |
+
* @return bool
|
| 60 |
+
*/
|
| 61 |
+
public function prepareCustomerForQuote(Mage_Sales_Model_Quote $quote)
|
| 62 |
+
{
|
| 63 |
+
$isNewCustomer = false;
|
| 64 |
+
switch ($quote->getCheckoutMethod()) {
|
| 65 |
+
case self::MODE_GUEST:
|
| 66 |
+
$this->_prepareGuestQuote($quote);
|
| 67 |
+
break;
|
| 68 |
+
case self::MODE_REGISTER:
|
| 69 |
+
$this->_prepareNewCustomerQuote($quote);
|
| 70 |
+
$isNewCustomer = true;
|
| 71 |
+
break;
|
| 72 |
+
default:
|
| 73 |
+
$this->_prepareCustomerQuote($quote);
|
| 74 |
+
break;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
return $isNewCustomer;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
// MAGENTO 1.6.2
|
| 82 |
+
// Modifications :
|
| 83 |
+
// - *1* -> http://www.magentocommerce.com/boards/viewthread/262680/#e9
|
| 84 |
+
protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
|
| 85 |
+
{
|
| 86 |
+
$quote->setCustomerId(null)
|
| 87 |
+
// ->setCustomerEmail($quote->getBillingAddress()->getEmail()) // *1*
|
| 88 |
+
->setCustomerEmail($quote->getCustomerEmail()) // *1*
|
| 89 |
+
->setCustomerIsGuest(true)
|
| 90 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
| 91 |
+
return $this;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Prepare quote for customer registration and customer order submit
|
| 96 |
+
*
|
| 97 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 98 |
+
* @return Mage_Checkout_Model_Api_Resource_Customer
|
| 99 |
+
*/
|
| 100 |
+
protected function _prepareNewCustomerQuote(Mage_Sales_Model_Quote $quote)
|
| 101 |
+
{
|
| 102 |
+
$billing = $quote->getBillingAddress();
|
| 103 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 104 |
+
|
| 105 |
+
//$customer = Mage::getModel('customer/customer');
|
| 106 |
+
$customer = $quote->getCustomer();
|
| 107 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
| 108 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 109 |
+
$customer->addAddress($customerBilling);
|
| 110 |
+
$billing->setCustomerAddress($customerBilling);
|
| 111 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 112 |
+
if ($shipping && !$shipping->getSameAsBilling()) {
|
| 113 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 114 |
+
$customer->addAddress($customerShipping);
|
| 115 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 116 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 117 |
+
} else {
|
| 118 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_quote', 'to_customer', $quote, $customer);
|
| 122 |
+
$customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
|
| 123 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
| 124 |
+
$quote->setCustomer($customer)
|
| 125 |
+
->setCustomerId(true);
|
| 126 |
+
|
| 127 |
+
return $this;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Prepare quote for customer order submit
|
| 132 |
+
*
|
| 133 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 134 |
+
* @return Mage_Checkout_Model_Api_Resource_Customer
|
| 135 |
+
*/
|
| 136 |
+
protected function _prepareCustomerQuote(Mage_Sales_Model_Quote $quote)
|
| 137 |
+
{
|
| 138 |
+
$billing = $quote->getBillingAddress();
|
| 139 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 140 |
+
|
| 141 |
+
$customer = $quote->getCustomer();
|
| 142 |
+
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
| 143 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 144 |
+
$customer->addAddress($customerBilling);
|
| 145 |
+
$billing->setCustomerAddress($customerBilling);
|
| 146 |
+
}
|
| 147 |
+
if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
|
| 148 |
+
|| (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
|
| 149 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 150 |
+
$customer->addAddress($customerShipping);
|
| 151 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
| 155 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 156 |
+
}
|
| 157 |
+
if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
| 158 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 159 |
+
} else if (isset($customerBilling) && !$customer->getDefaultShipping()) {
|
| 160 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 161 |
+
}
|
| 162 |
+
$quote->setCustomer($customer);
|
| 163 |
+
|
| 164 |
+
return $this;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Involve new customer to system
|
| 169 |
+
*
|
| 170 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 171 |
+
* @return Mage_Checkout_Model_Api_Resource_Customer
|
| 172 |
+
*/
|
| 173 |
+
public function involveNewCustomer(Mage_Sales_Model_Quote $quote)
|
| 174 |
+
{
|
| 175 |
+
$customer = $quote->getCustomer();
|
| 176 |
+
if ($customer->isConfirmationRequired()) {
|
| 177 |
+
$customer->sendNewAccountEmail('confirmation');
|
| 178 |
+
} else {
|
| 179 |
+
$customer->sendNewAccountEmail();
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
return $this;
|
| 183 |
+
}
|
| 184 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Cart/Api.php
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Cart_Api)
|
| 3 |
+
// Modifications :
|
| 4 |
+
// - Cart_Api not present in mage 1.4.0.1
|
| 5 |
+
// - extends
|
| 6 |
+
// - method name (customCreate, customCreateOrder)
|
| 7 |
+
class GoDataFeed_Services_Model_Cart_Api extends GoDataFeed_Services_Model_Api_Resource_Checkout
|
| 8 |
+
{
|
| 9 |
+
|
| 10 |
+
public function __construct()
|
| 11 |
+
{
|
| 12 |
+
$this->_storeIdSessionField = "cart_store_id";
|
| 13 |
+
$this->_attributesMap['quote'] = array('quote_id' => 'entity_id');
|
| 14 |
+
$this->_attributesMap['quote_customer'] = array('customer_id' => 'entity_id');
|
| 15 |
+
$this->_attributesMap['quote_address'] = array('address_id' => 'entity_id');
|
| 16 |
+
$this->_attributesMap['quote_payment'] = array('payment_id' => 'entity_id');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function customCreate($store = null)
|
| 20 |
+
{
|
| 21 |
+
$storeId = $this->_getStoreId($store);
|
| 22 |
+
|
| 23 |
+
try {
|
| 24 |
+
/*@var $quote Mage_Sales_Model_Quote*/
|
| 25 |
+
$quote = Mage::getModel('sales/quote');
|
| 26 |
+
$quote->setStoreId($storeId)
|
| 27 |
+
->setIsActive(false)
|
| 28 |
+
->setIsMultiShipping(false)
|
| 29 |
+
->save();
|
| 30 |
+
} catch (Mage_Core_Exception $e) {
|
| 31 |
+
$this->_fault('create_quote_fault', $e->getMessage());
|
| 32 |
+
}
|
| 33 |
+
return (int)$quote->getId();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
// MAGENTO 1.6.?
|
| 37 |
+
// Modifications :
|
| 38 |
+
// - lines modified (*1*), (*2*), (*3*), (*4*)
|
| 39 |
+
public function customCreateOrder($quoteId, $shippingFees, $shippingMethodDescription, $orderItems, $store = null, $agreements = null)
|
| 40 |
+
{
|
| 41 |
+
$requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
|
| 42 |
+
if (!empty($requiredAgreements)) {
|
| 43 |
+
$diff = array_diff($agreements, $requiredAgreements);
|
| 44 |
+
if (!empty($diff)) {
|
| 45 |
+
$this->_fault('required_agreements_are_not_all');
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
$quote = $this->_getQuote($quoteId, $store);
|
| 50 |
+
if ($quote->getIsMultiShipping()) {
|
| 51 |
+
$this->_fault('invalid_checkout_type');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// *3* : Mage_Checkout_Model_Api_Resource_Customer not available in Magento 1.4
|
| 55 |
+
// if ($quote->getCheckoutMethod() == Mage_Checkout_Model_Api_Resource_Customer::MODE_GUEST
|
| 56 |
+
// && !Mage::helper('checkout')->isAllowedGuestCheckout($quote, $quote->getStoreId())
|
| 57 |
+
if ($quote->getCheckoutMethod() == GoDataFeed_Services_Model_Api_Resource_Customer::MODE_GUEST
|
| 58 |
+
&& !Mage::helper('checkout')->isAllowedGuestCheckout($quote, $quote->getStoreId())
|
| 59 |
+
) {
|
| 60 |
+
$this->_fault('guest_checkout_is_not_enabled');
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/** @var $customerResource Mage_Checkout_Model_Api_Resource_Customer */
|
| 64 |
+
// *4* Mage_Checkout_Model_Api_Resource_Customer not available in Magento 1.4
|
| 65 |
+
$customerResource = new GoDataFeed_Services_Model_Api_Resource_Customer();
|
| 66 |
+
// $customerResource = Mage::getModel("checkout/api_resource_customer");
|
| 67 |
+
$isNewCustomer = $customerResource->prepareCustomerForQuote($quote);
|
| 68 |
+
|
| 69 |
+
try {
|
| 70 |
+
$quote->collectTotals();
|
| 71 |
+
|
| 72 |
+
/** @var $service Mage_Sales_Model_Service_Quote */
|
| 73 |
+
$service = new GoDataFeed_Services_Model_Service_Quote($quote); // *1* overriding Mage_Sales_Model_Service_Quote
|
| 74 |
+
$service->customSubmitAll($shippingFees, $shippingMethodDescription, $orderItems); // *2* method rename
|
| 75 |
+
|
| 76 |
+
if ($isNewCustomer) {
|
| 77 |
+
try {
|
| 78 |
+
$customerResource->involveNewCustomer($quote);
|
| 79 |
+
} catch (Exception $e) {
|
| 80 |
+
Mage::logException($e);
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
$order = $service->getOrder();
|
| 85 |
+
if ($order) {
|
| 86 |
+
|
| 87 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after',
|
| 88 |
+
array('order' => $order, 'quote' => $quote));
|
| 89 |
+
|
| 90 |
+
try {
|
| 91 |
+
$order->sendNewOrderEmail();
|
| 92 |
+
} catch (Exception $e) {
|
| 93 |
+
Mage::logException($e);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
Mage::dispatchEvent(
|
| 98 |
+
'checkout_submit_all_after',
|
| 99 |
+
array('order' => $order, 'quote' => $quote)
|
| 100 |
+
);
|
| 101 |
+
} catch (Mage_Core_Exception $e) {
|
| 102 |
+
$this->_fault('create_order_fault', $e->getMessage());
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
return $order->getIncrementId();
|
| 106 |
+
}
|
| 107 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Cart/Customer/Api.php
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Cart_Product_Api)
|
| 3 |
+
// Modifications :
|
| 4 |
+
// - Cart_Customer_Api not present in mage 1.4.0.1
|
| 5 |
+
// - extends
|
| 6 |
+
// - method name (customSet)
|
| 7 |
+
class GoDataFeed_Services_Model_Cart_Customer_Api extends GoDataFeed_Services_Model_Api_Resource_Customer
|
| 8 |
+
{
|
| 9 |
+
|
| 10 |
+
public function __construct()
|
| 11 |
+
{
|
| 12 |
+
$this->_storeIdSessionField = "cart_store_id";
|
| 13 |
+
|
| 14 |
+
$this->_attributesMap['quote'] = array('quote_id' => 'entity_id');
|
| 15 |
+
$this->_attributesMap['quote_customer'] = array('customer_id' => 'entity_id');
|
| 16 |
+
$this->_attributesMap['quote_address'] = array('address_id' => 'entity_id');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Set customer for shopping cart
|
| 21 |
+
*
|
| 22 |
+
* @param int $quoteId
|
| 23 |
+
* @param array|object $customerData
|
| 24 |
+
* @param int | string $store
|
| 25 |
+
* @return int
|
| 26 |
+
*/
|
| 27 |
+
public function customSet($quoteId, $customerData, $store = null)
|
| 28 |
+
{
|
| 29 |
+
$quote = $this->_getQuote($quoteId, $store);
|
| 30 |
+
|
| 31 |
+
$customerData = $this->_prepareCustomerData($customerData);
|
| 32 |
+
if (!isset($customerData['mode'])) {
|
| 33 |
+
$this->_fault('customer_mode_is_unknown');
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
switch($customerData['mode']) {
|
| 37 |
+
case self::MODE_CUSTOMER:
|
| 38 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 39 |
+
$customer = $this->_getCustomer($customerData['entity_id']);
|
| 40 |
+
$customer->setMode(self::MODE_CUSTOMER);
|
| 41 |
+
break;
|
| 42 |
+
|
| 43 |
+
case self::MODE_REGISTER:
|
| 44 |
+
case self::MODE_GUEST:
|
| 45 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 46 |
+
$customer = Mage::getModel('customer/customer')
|
| 47 |
+
->setData($customerData);
|
| 48 |
+
|
| 49 |
+
if ($customer->getMode() == self::MODE_GUEST) {
|
| 50 |
+
$password = $customer->generatePassword();
|
| 51 |
+
|
| 52 |
+
$customer
|
| 53 |
+
->setPassword($password)
|
| 54 |
+
->setConfirmation($password);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
$isCustomerValid = $customer->validate();
|
| 58 |
+
if ($isCustomerValid !== true && is_array($isCustomerValid)) {
|
| 59 |
+
$this->_fault('customer_data_invalid', implode(PHP_EOL, $isCustomerValid));
|
| 60 |
+
}
|
| 61 |
+
break;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
try {
|
| 65 |
+
$quote
|
| 66 |
+
->setCustomer($customer)
|
| 67 |
+
->setCheckoutMethod($customer->getMode())
|
| 68 |
+
->setPasswordHash($customer->encryptPassword($customer->getPassword()))
|
| 69 |
+
->save();
|
| 70 |
+
} catch (Mage_Core_Exception $e) {
|
| 71 |
+
$this->_fault('customer_not_set', $e->getMessage());
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
return true;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* @param int $quoteId
|
| 79 |
+
* @param array of array|object $customerAddressData
|
| 80 |
+
* @param int|string $store
|
| 81 |
+
* @return int
|
| 82 |
+
*/
|
| 83 |
+
public function customSetAddresses($quoteId, $customerAddressData, $store = null)
|
| 84 |
+
{
|
| 85 |
+
$quote = $this->_getQuote($quoteId, $store);
|
| 86 |
+
|
| 87 |
+
$customerAddressData = $this->_prepareCustomerAddressData($customerAddressData);
|
| 88 |
+
if (is_null($customerAddressData)) {
|
| 89 |
+
$this->_fault('customer_address_data_empty');
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
foreach ($customerAddressData as $addressItem) {
|
| 93 |
+
// switch($addressItem['mode']) {
|
| 94 |
+
// case self::ADDRESS_BILLING:
|
| 95 |
+
/** @var $address Mage_Sales_Model_Quote_Address */
|
| 96 |
+
$address = Mage::getModel("sales/quote_address");
|
| 97 |
+
// break;
|
| 98 |
+
// case self::ADDRESS_SHIPPING:
|
| 99 |
+
// /** @var $address Mage_Sales_Model_Quote_Address */
|
| 100 |
+
// $address = Mage::getModel("sales/quote_address");
|
| 101 |
+
// break;
|
| 102 |
+
// }
|
| 103 |
+
$addressMode = $addressItem['mode'];
|
| 104 |
+
unset($addressItem['mode']);
|
| 105 |
+
|
| 106 |
+
if (!empty($addressItem['entity_id'])) {
|
| 107 |
+
$customerAddress = $this->_getCustomerAddress($addressItem['entity_id']);
|
| 108 |
+
if ($customerAddress->getCustomerId() != $quote->getCustomerId()) {
|
| 109 |
+
$this->_fault('address_not_belong_customer');
|
| 110 |
+
}
|
| 111 |
+
$address->importCustomerAddress($customerAddress);
|
| 112 |
+
|
| 113 |
+
} else {
|
| 114 |
+
$address->setData($addressItem);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
$address->implodeStreetAddress();
|
| 118 |
+
|
| 119 |
+
if (($validateRes = $address->validate())!==true) {
|
| 120 |
+
$this->_fault('customer_address_invalid', implode(PHP_EOL, $validateRes));
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
switch($addressMode) {
|
| 124 |
+
case self::ADDRESS_BILLING:
|
| 125 |
+
$address->setEmail($quote->getCustomer()->getEmail());
|
| 126 |
+
|
| 127 |
+
if (!$quote->isVirtual()) {
|
| 128 |
+
$usingCase = isset($addressItem['use_for_shipping']) ? (int)$addressItem['use_for_shipping'] : 0;
|
| 129 |
+
switch($usingCase) {
|
| 130 |
+
case 0:
|
| 131 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 132 |
+
$shippingAddress->setSameAsBilling(0);
|
| 133 |
+
break;
|
| 134 |
+
case 1:
|
| 135 |
+
$billingAddress = clone $address;
|
| 136 |
+
$billingAddress->unsAddressId()->unsAddressType();
|
| 137 |
+
|
| 138 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 139 |
+
$shippingMethod = $shippingAddress->getShippingMethod();
|
| 140 |
+
$shippingAddress->addData($billingAddress->getData())
|
| 141 |
+
->setSameAsBilling(1)
|
| 142 |
+
->setShippingMethod($shippingMethod)
|
| 143 |
+
->setCollectShippingRates(true);
|
| 144 |
+
break;
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
$quote->setBillingAddress($address);
|
| 148 |
+
break;
|
| 149 |
+
|
| 150 |
+
case self::ADDRESS_SHIPPING:
|
| 151 |
+
$address->setCollectShippingRates(true)
|
| 152 |
+
->setSameAsBilling(0);
|
| 153 |
+
$quote->setShippingAddress($address);
|
| 154 |
+
break;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
try {
|
| 160 |
+
$quote
|
| 161 |
+
->collectTotals()
|
| 162 |
+
->save();
|
| 163 |
+
} catch (Exception $e) {
|
| 164 |
+
$this->_fault('address_is_not_set', $e->getMessage());
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
return true;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
/**
|
| 171 |
+
* Prepare customer entered data for implementing
|
| 172 |
+
*
|
| 173 |
+
* @param array $customerData
|
| 174 |
+
* @return array
|
| 175 |
+
*/
|
| 176 |
+
protected function _prepareCustomerData($data)
|
| 177 |
+
{
|
| 178 |
+
foreach ($this->_attributesMap['quote_customer'] as $attributeAlias=>$attributeCode) {
|
| 179 |
+
if(isset($data[$attributeAlias]))
|
| 180 |
+
{
|
| 181 |
+
$data[$attributeCode] = $data[$attributeAlias];
|
| 182 |
+
unset($data[$attributeAlias]);
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
return $data;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Prepare customer entered data for implementing
|
| 190 |
+
*
|
| 191 |
+
* @param array $data
|
| 192 |
+
* @return array
|
| 193 |
+
*/
|
| 194 |
+
protected function _prepareCustomerAddressData($data)
|
| 195 |
+
{
|
| 196 |
+
if (!is_array($data) || !is_array($data[0])) {
|
| 197 |
+
return null;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
$dataAddresses = array();
|
| 201 |
+
foreach($data as $addressItem) {
|
| 202 |
+
foreach ($this->_attributesMap['quote_address'] as $attributeAlias=>$attributeCode) {
|
| 203 |
+
if(isset($addressItem[$attributeAlias]))
|
| 204 |
+
{
|
| 205 |
+
$addressItem[$attributeCode] = $addressItem[$attributeAlias];
|
| 206 |
+
unset($addressItem[$attributeAlias]);
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
$dataAddresses[] = $addressItem;
|
| 210 |
+
}
|
| 211 |
+
return $dataAddresses;
|
| 212 |
+
}
|
| 213 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Cart/Payment/Api.php
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// DUPLICATED CODE FROM MAGENTO (Mage_Checkout_Model_Cart_Product_Api)
|
| 3 |
+
// CODE VERSION : 1.6.2
|
| 4 |
+
// Modifications :
|
| 5 |
+
// - Cart_Payment_Api not present in mage 1.4.0.1
|
| 6 |
+
// - extends
|
| 7 |
+
// - setCustomPaymentMethod
|
| 8 |
+
class GoDataFeed_Services_Model_Cart_Payment_Api extends GoDataFeed_Services_Model_Api_Resource_Checkout
|
| 9 |
+
{
|
| 10 |
+
|
| 11 |
+
protected function _preparePaymentData($data)
|
| 12 |
+
{
|
| 13 |
+
if (!(is_array($data) && is_null($data[0]))) {
|
| 14 |
+
return array();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
return $data;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* @param $method
|
| 22 |
+
* @param $quote
|
| 23 |
+
* @return bool
|
| 24 |
+
*/
|
| 25 |
+
protected function _canUsePaymentMethod($method, $quote)
|
| 26 |
+
{
|
| 27 |
+
if ( !($method->isGateway() || $method->canUseInternal()) ) {
|
| 28 |
+
return false;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
if (!$method->canUseForCountry($quote->getBillingAddress()->getCountry())) {
|
| 32 |
+
return false;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
if (!$method->canUseForCurrency(Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode())) {
|
| 36 |
+
return false;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Checking for min/max order total for assigned payment method
|
| 41 |
+
*/
|
| 42 |
+
$total = $quote->getBaseGrandTotal();
|
| 43 |
+
$minTotal = $method->getConfigData('min_order_total');
|
| 44 |
+
$maxTotal = $method->getConfigData('max_order_total');
|
| 45 |
+
|
| 46 |
+
if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
|
| 47 |
+
return false;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
return true;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
protected function _getPaymentMethodAvailableCcTypes($method)
|
| 54 |
+
{
|
| 55 |
+
$ccTypes = Mage::getSingleton('payment/config')->getCcTypes();
|
| 56 |
+
$methodCcTypes = explode(',',$method->getConfigData('cctypes'));
|
| 57 |
+
foreach ($ccTypes as $code=>$title) {
|
| 58 |
+
if (!in_array($code, $methodCcTypes)) {
|
| 59 |
+
unset($ccTypes[$code]);
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
if (empty($ccTypes)) {
|
| 63 |
+
return null;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
return $ccTypes;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Cart_Product_Api)
|
| 70 |
+
// Modifications :
|
| 71 |
+
// - method name
|
| 72 |
+
// - *1* commented code : override shipping method validation
|
| 73 |
+
// - *2* : overriding Quote_Payment object to disable payment method validation
|
| 74 |
+
// - *3* setting custom payment info
|
| 75 |
+
public function setCustomPaymentMethod($quoteId, $paymentData, $paymentMethod, $orderNumber, $store=null)
|
| 76 |
+
{
|
| 77 |
+
$quote = $this->_getQuote($quoteId, $store);
|
| 78 |
+
$store = $quote->getStoreId();
|
| 79 |
+
|
| 80 |
+
$paymentData = $this->_preparePaymentData($paymentData);
|
| 81 |
+
|
| 82 |
+
if (empty($paymentData)) {
|
| 83 |
+
$this->_fault("payment_method_empty");
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if ($quote->isVirtual()) {
|
| 87 |
+
// check if billing address is set
|
| 88 |
+
if (is_null($quote->getBillingAddress()->getId()) ) {
|
| 89 |
+
$this->_fault('billing_address_is_not_set');
|
| 90 |
+
}
|
| 91 |
+
$quote->getBillingAddress()->setPaymentMethod(isset($paymentData['method']) ? $paymentData['method'] : null);
|
| 92 |
+
} else {
|
| 93 |
+
// check if shipping address is set
|
| 94 |
+
if (is_null($quote->getShippingAddress()->getId()) ) {
|
| 95 |
+
$this->_fault('shipping_address_is_not_set');
|
| 96 |
+
}
|
| 97 |
+
$quote->getShippingAddress()->setPaymentMethod(isset($paymentData['method']) ? $paymentData['method'] : null);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
|
| 101 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
$total = $quote->getBaseSubtotal();
|
| 105 |
+
|
| 106 |
+
// *1*
|
| 107 |
+
// $methods = Mage::helper('payment')->getStoreMethods($store, $quote);
|
| 108 |
+
// foreach ($methods as $key=>$method) {
|
| 109 |
+
// if ($method->getCode() == $paymentData['method']) {
|
| 110 |
+
// /** @var $method Mage_Payment_Model_Method_Abstract */
|
| 111 |
+
// if (!($this->_canUsePaymentMethod($method, $quote)
|
| 112 |
+
// && ($total != 0
|
| 113 |
+
// || $method->getCode() == 'free'
|
| 114 |
+
// || ($quote->hasRecurringItems() && $method->canManageRecurringProfiles())))) {
|
| 115 |
+
// $this->_fault("method_not_allowed");
|
| 116 |
+
// }
|
| 117 |
+
// }
|
| 118 |
+
// }
|
| 119 |
+
// END OF *1*
|
| 120 |
+
|
| 121 |
+
try {
|
| 122 |
+
|
| 123 |
+
// *2* Mage_Sales_Model_Quote_Payment overrides
|
| 124 |
+
// $payment = $quote->getPayment();
|
| 125 |
+
$payment = new GoDataFeed_Services_Model_Quote_Payment();
|
| 126 |
+
$quote->addPayment($payment);
|
| 127 |
+
// END OF *2*
|
| 128 |
+
|
| 129 |
+
$payment->importData($paymentData);
|
| 130 |
+
|
| 131 |
+
// *3*
|
| 132 |
+
$paymentInfo = $payment->getMethodInstance()->getInfoInstance();
|
| 133 |
+
$paymentInfo->setCcOwner($quote->getBillingAddress()->getFirstname() . ' ' . $quote->getBillingAddress()->getLastname());
|
| 134 |
+
$paymentInfo->setCcType($paymentMethod);
|
| 135 |
+
$paymentInfo->setCcSsIssue($orderNumber);
|
| 136 |
+
// end of modifications *3*
|
| 137 |
+
|
| 138 |
+
$quote->setTotalsCollectedFlag(false)
|
| 139 |
+
->collectTotals()
|
| 140 |
+
->save();
|
| 141 |
+
} catch (Mage_Core_Exception $e) {
|
| 142 |
+
$this->_fault('payment_method_is_not_set', $e->getMessage());
|
| 143 |
+
}
|
| 144 |
+
return true;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Cart/Product/Api.php
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Cart_Product_Api)
|
| 3 |
+
// Modifications :
|
| 4 |
+
// - Cart_Product_Api not present in mage 1.4.0.1
|
| 5 |
+
// - extends
|
| 6 |
+
// - customAdd method name
|
| 7 |
+
class GoDataFeed_Services_Model_Cart_Product_Api extends GoDataFeed_Services_Model_Api_Resource_Checkout_Product
|
| 8 |
+
{
|
| 9 |
+
protected function _prepareProductsData($data)
|
| 10 |
+
{
|
| 11 |
+
if (!is_array($data)) {
|
| 12 |
+
return null;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
$_data = array();
|
| 16 |
+
if (is_array($data) && is_null($data[0])) {
|
| 17 |
+
$_data[] = $data;
|
| 18 |
+
} else {
|
| 19 |
+
$_data = $data;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
return $_data;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
// MAGENTO 1.6.2 (Mage_Checkout_Model_Cart_Product_Api)
|
| 26 |
+
// Modifications :
|
| 27 |
+
// - customAdd method name
|
| 28 |
+
// - *1* verifies that the product has been found
|
| 29 |
+
public function customAdd($quoteId, $productsData, $store=null)
|
| 30 |
+
{
|
| 31 |
+
$quote = $this->_getQuote($quoteId, $store);
|
| 32 |
+
if (empty($store)) {
|
| 33 |
+
$store = $quote->getStoreId();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$productsData = $this->_prepareProductsData($productsData);
|
| 37 |
+
if (empty($productsData)) {
|
| 38 |
+
$this->_fault('invalid_product_data');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$errors = array();
|
| 42 |
+
foreach ($productsData as $productItem) {
|
| 43 |
+
if (isset($productItem['product_id'])) {
|
| 44 |
+
$productByItem = $this->_getProduct($productItem['product_id'], $store, "id");
|
| 45 |
+
} else if (isset($productItem['sku'])) {
|
| 46 |
+
$productByItem = $this->_getProduct($productItem['sku'], $store, "sku");
|
| 47 |
+
} else {
|
| 48 |
+
$errors[] = Mage::helper('checkout')->__("One item of products do not have identifier or sku");
|
| 49 |
+
continue;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// *1*
|
| 53 |
+
if($productByItem->getId() == null) {
|
| 54 |
+
|
| 55 |
+
$errorMessage = "requested product could not be found. ";
|
| 56 |
+
if (isset($productItem['product_id'])) {
|
| 57 |
+
$errorMessage .= "product id = " . $productItem['product_id'] . ". ";
|
| 58 |
+
}
|
| 59 |
+
if (isset($productItem['sku'])) {
|
| 60 |
+
$errorMessage .= "product sku = " . $productItem['sku'] . ". ";
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
Mage::throwException($errorMessage);
|
| 64 |
+
}
|
| 65 |
+
// END OF *1*
|
| 66 |
+
|
| 67 |
+
$productRequest = $this->_getProductRequest($productItem);
|
| 68 |
+
try {
|
| 69 |
+
$result = $quote->addProduct($productByItem, $productRequest);
|
| 70 |
+
if (is_string($result)) {
|
| 71 |
+
Mage::throwException($result);
|
| 72 |
+
}
|
| 73 |
+
} catch (Mage_Core_Exception $e) {
|
| 74 |
+
$errors[] = $e->getMessage();
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
if (!empty($errors)) {
|
| 79 |
+
$this->_fault("add_product_fault", implode(PHP_EOL, $errors));
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
try {
|
| 83 |
+
$quote->collectTotals()->save();
|
| 84 |
+
} catch(Exception $e) {
|
| 85 |
+
$this->_fault("add_product_quote_save_fault", $e->getMessage());
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
return true;
|
| 89 |
+
}
|
| 90 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Catalog/Product/Api.php
CHANGED
|
@@ -19,7 +19,7 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 19 |
const CATEGORY_SEPARATOR = ' > ';
|
| 20 |
|
| 21 |
public function count($filters, $stockQuantityFilterAmount, $store, $responseField)
|
| 22 |
-
|
| 23 |
$filteredProductsCollection = $this->getProductsFilteredByStockQuantity(
|
| 24 |
$filters,
|
| 25 |
$stockQuantityFilterAmount,
|
|
@@ -39,7 +39,7 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 39 |
}
|
| 40 |
|
| 41 |
return array($responseField => $numberOfProducts);
|
| 42 |
-
|
| 43 |
|
| 44 |
public function extendedList(
|
| 45 |
$filters,
|
|
@@ -60,8 +60,9 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 60 |
$scrubAttributeSetName,
|
| 61 |
$scrubCustomAttribute,
|
| 62 |
$pageNumber,
|
| 63 |
-
$productsPerPage
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
if(empty($store)) {
|
| 67 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
|
@@ -80,24 +81,25 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 80 |
$absoluteUrlRequested = $absoluteUrlConfig[0];
|
| 81 |
$absoluteImageUrlRequested = $absoluteImageUrlConfig[0];
|
| 82 |
$filteredProductsCollection =
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
|
| 96 |
if(!empty($filteredProductsCollection)) {
|
| 97 |
|
| 98 |
foreach ($filteredProductsCollection as $productToRetrieve) {
|
| 99 |
|
| 100 |
$resultItem = array();
|
|
|
|
| 101 |
|
| 102 |
// STANDARD ATTRIBUTES
|
| 103 |
if(!empty($attributes) && is_array($attributes)) {
|
|
@@ -138,13 +140,13 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 138 |
// DESCRIPTION SCRUBBING
|
| 139 |
if(in_array(self::DESCRIPTION_FIELD, $attributes) && $scrubDescription) {
|
| 140 |
$resultItem[self::DESCRIPTION_FIELD] =
|
| 141 |
-
|
| 142 |
}
|
| 143 |
|
| 144 |
// SHORT DESCRIPTION SCRUBBING
|
| 145 |
if(in_array(self::SHORT_DESCRIPTION_FIELD, $attributes) && $scrubShortDescription) {
|
| 146 |
$resultItem[self::SHORT_DESCRIPTION_FIELD] =
|
| 147 |
-
|
| 148 |
}
|
| 149 |
|
| 150 |
// IS IN STOCK & QUANTITY ATTRIBUTES
|
|
@@ -226,6 +228,17 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 226 |
}
|
| 227 |
}
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
// ABSOLUTE URL & IMAGE
|
| 230 |
if($absoluteUrlRequested || $absoluteImageUrlRequested) {
|
| 231 |
|
|
@@ -237,10 +250,8 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 237 |
//If it's a simple product and it's NOT visible then we are getting the URL/ImageURL from the parent (configurable/grouped) product
|
| 238 |
if($productToRetrieve->getTypeId() == 'simple' && $productToRetrieve->getData(self::VISIBILITY_FIELD) == 1)
|
| 239 |
{
|
| 240 |
-
$productIdToRetrieve = $productToRetrieve->getId();
|
| 241 |
-
|
| 242 |
//Checking if the product is a child of a "configurable" product
|
| 243 |
-
$parentProductIds =
|
| 244 |
|
| 245 |
//Checking if the product is a child of a "grouped" product
|
| 246 |
if(sizeof($parentProductIds) < 1) {
|
|
@@ -276,12 +287,24 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 276 |
}
|
| 277 |
}
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
$resultItems[] = $resultItem;
|
| 280 |
}
|
| 281 |
}
|
| 282 |
|
| 283 |
return $resultItems;
|
| 284 |
-
|
| 285 |
|
| 286 |
private function getProductsFilteredByStockQuantity(
|
| 287 |
$filters,
|
|
@@ -298,17 +321,17 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 298 |
|
| 299 |
$filteredProductsCollection =
|
| 300 |
Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
|
| 313 |
if (is_array($filters)) {
|
| 314 |
try {
|
| 19 |
const CATEGORY_SEPARATOR = ' > ';
|
| 20 |
|
| 21 |
public function count($filters, $stockQuantityFilterAmount, $store, $responseField)
|
| 22 |
+
{
|
| 23 |
$filteredProductsCollection = $this->getProductsFilteredByStockQuantity(
|
| 24 |
$filters,
|
| 25 |
$stockQuantityFilterAmount,
|
| 39 |
}
|
| 40 |
|
| 41 |
return array($responseField => $numberOfProducts);
|
| 42 |
+
}
|
| 43 |
|
| 44 |
public function extendedList(
|
| 45 |
$filters,
|
| 60 |
$scrubAttributeSetName,
|
| 61 |
$scrubCustomAttribute,
|
| 62 |
$pageNumber,
|
| 63 |
+
$productsPerPage,
|
| 64 |
+
$parentSKUConfig)
|
| 65 |
+
{
|
| 66 |
|
| 67 |
if(empty($store)) {
|
| 68 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 81 |
$absoluteUrlRequested = $absoluteUrlConfig[0];
|
| 82 |
$absoluteImageUrlRequested = $absoluteImageUrlConfig[0];
|
| 83 |
$filteredProductsCollection =
|
| 84 |
+
$this->getProductsFilteredByStockQuantity(
|
| 85 |
+
$filters,
|
| 86 |
+
$stockQuantityFilterAmount,
|
| 87 |
+
$store,
|
| 88 |
+
$attributes,
|
| 89 |
+
$customAttributes,
|
| 90 |
+
$manufacturerNameRequested,
|
| 91 |
+
$absoluteUrlRequested,
|
| 92 |
+
$absoluteImageUrlRequested,
|
| 93 |
+
$pageNumber,
|
| 94 |
+
$productsPerPage
|
| 95 |
+
);
|
| 96 |
|
| 97 |
if(!empty($filteredProductsCollection)) {
|
| 98 |
|
| 99 |
foreach ($filteredProductsCollection as $productToRetrieve) {
|
| 100 |
|
| 101 |
$resultItem = array();
|
| 102 |
+
$productIdToRetrieve = $productToRetrieve->getId();
|
| 103 |
|
| 104 |
// STANDARD ATTRIBUTES
|
| 105 |
if(!empty($attributes) && is_array($attributes)) {
|
| 140 |
// DESCRIPTION SCRUBBING
|
| 141 |
if(in_array(self::DESCRIPTION_FIELD, $attributes) && $scrubDescription) {
|
| 142 |
$resultItem[self::DESCRIPTION_FIELD] =
|
| 143 |
+
$this->scrubData($resultItem[self::DESCRIPTION_FIELD]);
|
| 144 |
}
|
| 145 |
|
| 146 |
// SHORT DESCRIPTION SCRUBBING
|
| 147 |
if(in_array(self::SHORT_DESCRIPTION_FIELD, $attributes) && $scrubShortDescription) {
|
| 148 |
$resultItem[self::SHORT_DESCRIPTION_FIELD] =
|
| 149 |
+
$this->scrubData($resultItem[self::SHORT_DESCRIPTION_FIELD]);
|
| 150 |
}
|
| 151 |
|
| 152 |
// IS IN STOCK & QUANTITY ATTRIBUTES
|
| 228 |
}
|
| 229 |
}
|
| 230 |
|
| 231 |
+
// RETRIEVE CONFIGURABLE ITEMS PARENT IDS
|
| 232 |
+
// We need to retrieve parent ids if either of the following fields are requested :
|
| 233 |
+
// - absolute url
|
| 234 |
+
// - absolute image url
|
| 235 |
+
// - parent SKU
|
| 236 |
+
$parentSKURequested = $parentSKUConfig[0];
|
| 237 |
+
$configurableItemsParentIds = array();
|
| 238 |
+
if($absoluteUrlRequested || $absoluteImageUrlRequested || $parentSKURequested) {
|
| 239 |
+
$configurableItemsParentIds = Mage::getModel(self::CONFIGURABLE_PRODUCT_MODEL)->getParentIdsByChild($productIdToRetrieve);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
// ABSOLUTE URL & IMAGE
|
| 243 |
if($absoluteUrlRequested || $absoluteImageUrlRequested) {
|
| 244 |
|
| 250 |
//If it's a simple product and it's NOT visible then we are getting the URL/ImageURL from the parent (configurable/grouped) product
|
| 251 |
if($productToRetrieve->getTypeId() == 'simple' && $productToRetrieve->getData(self::VISIBILITY_FIELD) == 1)
|
| 252 |
{
|
|
|
|
|
|
|
| 253 |
//Checking if the product is a child of a "configurable" product
|
| 254 |
+
$parentProductIds = $configurableItemsParentIds;
|
| 255 |
|
| 256 |
//Checking if the product is a child of a "grouped" product
|
| 257 |
if(sizeof($parentProductIds) < 1) {
|
| 287 |
}
|
| 288 |
}
|
| 289 |
|
| 290 |
+
// CONFIGURABLE ITEMS PARENT SKU
|
| 291 |
+
if($parentSKURequested) {
|
| 292 |
+
|
| 293 |
+
$parentSKUS = array();
|
| 294 |
+
foreach ($configurableItemsParentIds as $parentId) {
|
| 295 |
+
$parentSKUS[] = Mage::getModel(self::CATALOG_PRODUCT_MODEL)->load($parentId)->getData('sku');
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
$responseField = $parentSKUConfig[1];
|
| 299 |
+
$resultItem[$responseField] = $parentSKUS;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
$resultItems[] = $resultItem;
|
| 303 |
}
|
| 304 |
}
|
| 305 |
|
| 306 |
return $resultItems;
|
| 307 |
+
}
|
| 308 |
|
| 309 |
private function getProductsFilteredByStockQuantity(
|
| 310 |
$filters,
|
| 321 |
|
| 322 |
$filteredProductsCollection =
|
| 323 |
Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
| 324 |
+
->getCollection()
|
| 325 |
+
->joinField(
|
| 326 |
+
'qty',
|
| 327 |
+
'cataloginventory/stock_item',
|
| 328 |
+
'qty',
|
| 329 |
+
'product_id=entity_id',
|
| 330 |
+
'{{table}}.stock_id=1',
|
| 331 |
+
'left'
|
| 332 |
+
)
|
| 333 |
+
->addAttributeToFilter('qty', array('gteq' => $stockQuantityFilterAmount))
|
| 334 |
+
->addStoreFilter($store);
|
| 335 |
|
| 336 |
if (is_array($filters)) {
|
| 337 |
try {
|
app/code/local/GoDataFeed/Services/Model/Method/OrderSync.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class GoDataFeed_Services_Model_Method_OrderSync extends Mage_Payment_Model_Method_Cc
|
| 3 |
+
{
|
| 4 |
+
public function validate() {
|
| 5 |
+
return true;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
public function getCode() {
|
| 9 |
+
return "OrderSync";
|
| 10 |
+
}
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
app/code/local/GoDataFeed/Services/Model/Order/Payment.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class GoDataFeed_Services_Model_Order_Payment extends Mage_Sales_Model_Order_Payment
|
| 3 |
+
{
|
| 4 |
+
// MAGENTO 1.6.2 (Mage_Sales_Model_Order_Payment)
|
| 5 |
+
// Modifications :
|
| 6 |
+
// - full overrides to allow the custom OrderSync payment method to be returned
|
| 7 |
+
public function getMethodInstance()
|
| 8 |
+
{
|
| 9 |
+
$orderSyncPaymentMethod = new GoDataFeed_Services_Model_Method_OrderSync();
|
| 10 |
+
$orderSyncPaymentMethod->setInfoInstance($this);
|
| 11 |
+
$this->setMethodInstance($orderSyncPaymentMethod);
|
| 12 |
+
return $orderSyncPaymentMethod;
|
| 13 |
+
}
|
| 14 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Quote.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
//
|
| 3 |
+
//class GoDataFeed_Services_Model_Quote extends Mage_Sales_Model_Quote
|
| 4 |
+
//{
|
| 5 |
+
// // DUPLICATED CODE FROM MAGENTO
|
| 6 |
+
// // CODE VERSION : 1.6.2
|
| 7 |
+
// // Modifications :
|
| 8 |
+
// // - none
|
| 9 |
+
// public function loadByIdWithoutStore($quoteId)
|
| 10 |
+
// {
|
| 11 |
+
// $this->_getResource()->loadByIdWithoutStore($this, $quoteId);
|
| 12 |
+
// $this->_afterLoad();
|
| 13 |
+
// return $this;
|
| 14 |
+
// }
|
| 15 |
+
//}
|
app/code/local/GoDataFeed/Services/Model/Quote/Payment.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class GoDataFeed_Services_Model_Quote_Payment extends Mage_Sales_Model_Quote_Payment
|
| 3 |
+
{
|
| 4 |
+
// MAGENTO 1.6.2 (Mage_Sales_Model_Quote_Payment)
|
| 5 |
+
// Modifications :
|
| 6 |
+
// - *1* commented code
|
| 7 |
+
public function importData(array $data)
|
| 8 |
+
{
|
| 9 |
+
$data = new Varien_Object($data);
|
| 10 |
+
Mage::dispatchEvent(
|
| 11 |
+
$this->_eventPrefix . '_import_data_before',
|
| 12 |
+
array(
|
| 13 |
+
$this->_eventObject => $this,
|
| 14 |
+
'input' => $data,
|
| 15 |
+
)
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
$this->setMethod($data->getMethod());
|
| 19 |
+
$method = $this->getMethodInstance();
|
| 20 |
+
$method->setStore($this->getQuote()->getStore());
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Payment avalability related with quote totals.
|
| 24 |
+
* We have recollect quote totals before checking
|
| 25 |
+
*/
|
| 26 |
+
$this->getQuote()->collectTotals();
|
| 27 |
+
|
| 28 |
+
// *1* COMMENTED VALIDATION CODE
|
| 29 |
+
// if (!$method->isAvailable($this->getQuote())) {
|
| 30 |
+
// Mage::throwException(Mage::helper('sales')->__('Requested Payment Method is not available'));
|
| 31 |
+
// }
|
| 32 |
+
// END OF *1*
|
| 33 |
+
|
| 34 |
+
$method->assignData($data);
|
| 35 |
+
/*
|
| 36 |
+
* validating the payment data
|
| 37 |
+
*/
|
| 38 |
+
$method->validate();
|
| 39 |
+
return $this;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// MAGENTO 1.6.2 (Mage_Sales_Model_Quote_Payment)
|
| 43 |
+
// Modifications :
|
| 44 |
+
// - full overrides to allow the custom OrderSync payment method to be returned
|
| 45 |
+
public function getMethodInstance()
|
| 46 |
+
{
|
| 47 |
+
$oderSyncPaymentMethod = new GoDataFeed_Services_Model_Method_OrderSync();
|
| 48 |
+
$oderSyncPaymentMethod->setInfoInstance($this);
|
| 49 |
+
$this->setMethodInstance($oderSyncPaymentMethod);
|
| 50 |
+
return $oderSyncPaymentMethod;
|
| 51 |
+
}
|
| 52 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Service/Quote.php
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class GoDataFeed_Services_Model_Service_Quote extends Mage_Sales_Model_Service_Quote
|
| 4 |
+
{
|
| 5 |
+
// MAGENTO 1.6.? (Mage_Sales_Model_Service_Quote)
|
| 6 |
+
// Modifications :
|
| 7 |
+
// - lines commented *1*
|
| 8 |
+
protected function _validate()
|
| 9 |
+
{
|
| 10 |
+
$helper = Mage::helper('sales');
|
| 11 |
+
if (!$this->getQuote()->isVirtual()) {
|
| 12 |
+
$address = $this->getQuote()->getShippingAddress();
|
| 13 |
+
$addressValidation = $address->validate();
|
| 14 |
+
if ($addressValidation !== true) {
|
| 15 |
+
Mage::throwException(
|
| 16 |
+
$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
|
| 17 |
+
);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// *1* **********************************************************************
|
| 21 |
+
// COMMENTED FROM ORIGINAL CODE TO AVOID VALIDATING THE SHIPPING METHOD
|
| 22 |
+
// $method = $address->getShippingMethod();
|
| 23 |
+
// $rate = $address->getShippingRateByCode($method);
|
| 24 |
+
// if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
|
| 25 |
+
// Mage::throwException($helper->__('Please specify a shipping method.'));
|
| 26 |
+
// }
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
$addressValidation = $this->getQuote()->getBillingAddress()->validate();
|
| 30 |
+
if ($addressValidation !== true) {
|
| 31 |
+
Mage::throwException(
|
| 32 |
+
$helper->__('Please check billing address information. %s', implode(' ', $addressValidation))
|
| 33 |
+
);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if (!($this->getQuote()->getPayment()->getMethod())) {
|
| 37 |
+
Mage::throwException($helper->__('Please select a valid payment method.'));
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
return $this;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// MAGENTO 1.6.? (Mage_Sales_Model_Service_Quote)
|
| 44 |
+
// Modifications :
|
| 45 |
+
// - method name renamed
|
| 46 |
+
// - *1* commented line
|
| 47 |
+
// - method name renamed *2*
|
| 48 |
+
public function customSubmitAll($shippingFees, $shippingMethodDescription, $orderItems)
|
| 49 |
+
{
|
| 50 |
+
// don't allow submitNominalItems() to inactivate quote
|
| 51 |
+
$shouldInactivateQuoteOld = $this->_shouldInactivateQuote;
|
| 52 |
+
$this->_shouldInactivateQuote = false;
|
| 53 |
+
try {
|
| 54 |
+
|
| 55 |
+
// *1*
|
| 56 |
+
// submitNominalItems is not available in 1.4 and seems to take care of features not available at that time
|
| 57 |
+
// $this->submitNominalItems();
|
| 58 |
+
$this->_validate();
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
$this->_shouldInactivateQuote = $shouldInactivateQuoteOld;
|
| 62 |
+
} catch (Exception $e) {
|
| 63 |
+
$this->_shouldInactivateQuote = $shouldInactivateQuoteOld;
|
| 64 |
+
throw $e;
|
| 65 |
+
}
|
| 66 |
+
// no need to submit the order if there are no normal items remained
|
| 67 |
+
if (!$this->_quote->getAllVisibleItems()) {
|
| 68 |
+
$this->_inactivateQuote();
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
// *2*
|
| 73 |
+
$this->customSubmitOrder($shippingFees, $shippingMethodDescription, $orderItems);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
// MAGENTO 1.6.? (Mage_Sales_Model_Service_Quote)
|
| 77 |
+
// Modifications :
|
| 78 |
+
// - method name renamed
|
| 79 |
+
// - lines added *1*
|
| 80 |
+
// - line commented *2* *3*
|
| 81 |
+
// - *5*
|
| 82 |
+
// - *4*
|
| 83 |
+
// - *6* new variable
|
| 84 |
+
public function customSubmitOrder($shippingFees, $shippingMethodDescription, $orderItems)
|
| 85 |
+
{
|
| 86 |
+
// *2*
|
| 87 |
+
// _deleteNominalItems is not available in 1.4 and seems to take care of features not available at that time
|
| 88 |
+
// $this->_deleteNominalItems(); // ORIGINAL LINE
|
| 89 |
+
$this->_validate();
|
| 90 |
+
$quote = $this->_quote;
|
| 91 |
+
$isVirtual = $quote->isVirtual();
|
| 92 |
+
|
| 93 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
| 94 |
+
if ($quote->getCustomerId()) {
|
| 95 |
+
$transaction->addObject($quote->getCustomer());
|
| 96 |
+
}
|
| 97 |
+
$transaction->addObject($quote);
|
| 98 |
+
|
| 99 |
+
$quote->reserveOrderId();
|
| 100 |
+
if ($isVirtual) {
|
| 101 |
+
$order = $this->_convertor->addressToOrder($quote->getBillingAddress());
|
| 102 |
+
} else {
|
| 103 |
+
$order = $this->_convertor->addressToOrder($quote->getShippingAddress());
|
| 104 |
+
}
|
| 105 |
+
$order->setBillingAddress($this->_convertor->addressToOrderAddress($quote->getBillingAddress()));
|
| 106 |
+
if ($quote->getBillingAddress()->getCustomerAddress()) {
|
| 107 |
+
$order->getBillingAddress()->setCustomerAddress($quote->getBillingAddress()->getCustomerAddress());
|
| 108 |
+
}
|
| 109 |
+
if (!$isVirtual) {
|
| 110 |
+
$order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress()));
|
| 111 |
+
if ($quote->getShippingAddress()->getCustomerAddress()) {
|
| 112 |
+
$order->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
// *4*
|
| 117 |
+
// overrides Mage_Sales_Model_Order_Payment with GoDataFeed_Services_Model_Order_Payment
|
| 118 |
+
// allows to return the custom payment method GoDataFeed_Services_Model_Method_OrderSync
|
| 119 |
+
// which disables validation
|
| 120 |
+
// $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment())); // ORIGINAL LINE
|
| 121 |
+
$orderPayment = $this->_convertor->paymentToOrderPayment($quote->getPayment());
|
| 122 |
+
$customOrderPayment = new GoDataFeed_Services_Model_Order_Payment();
|
| 123 |
+
$customOrderPayment->setData($orderPayment->getData());
|
| 124 |
+
|
| 125 |
+
// code taken from order->addPayment()
|
| 126 |
+
// modified here to allow GoDataFeed_Services_Model_Order_Payment classes (**) to be added to the order payment collection
|
| 127 |
+
$customOrderPayment->setOrder($order)->setParentId($order->getId());
|
| 128 |
+
if (!$customOrderPayment->getId()) {
|
| 129 |
+
$paymentsCollection = $order->getPaymentsCollection();
|
| 130 |
+
$paymentsCollection->setItemObjectClass("GoDataFeed_Services_Model_Order_Payment"); // (**)
|
| 131 |
+
$paymentsCollection->addItem($customOrderPayment);
|
| 132 |
+
}
|
| 133 |
+
// end of modification *4*
|
| 134 |
+
|
| 135 |
+
foreach ($this->_orderData as $key => $value) {
|
| 136 |
+
$order->setData($key, $value);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
$overridedSubtotal = 0; // *6*
|
| 140 |
+
|
| 141 |
+
foreach ($quote->getAllItems() as $item) {
|
| 142 |
+
$orderItem = $this->_convertor->itemToOrderItem($item);
|
| 143 |
+
if ($item->getParentItem()) {
|
| 144 |
+
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
// *5* *****************************************************
|
| 148 |
+
// CODE ADDED TO MANAGE CUSTOM PRODUCT PRICES
|
| 149 |
+
foreach($orderItems as $overridedOrderItem) {
|
| 150 |
+
|
| 151 |
+
$itemSku = $item->getSku();
|
| 152 |
+
if($overridedOrderItem['sku'] == $itemSku) {
|
| 153 |
+
|
| 154 |
+
$originalPrice = $item->getOriginalPrice();
|
| 155 |
+
$orderItem->setOriginalPrice($originalPrice);
|
| 156 |
+
$orderItem->setBaseOriginalPrice($overridedOrderItem);
|
| 157 |
+
|
| 158 |
+
$overridedPrice = $overridedOrderItem['price'];
|
| 159 |
+
$overridedRowTotal = $overridedPrice * $overridedOrderItem['qty'];
|
| 160 |
+
$overridedSubtotal += $overridedRowTotal;
|
| 161 |
+
|
| 162 |
+
$orderItem->setPrice($overridedPrice);
|
| 163 |
+
$orderItem->setBasePrice($overridedPrice);
|
| 164 |
+
|
| 165 |
+
$orderItem->setRowTotal($overridedRowTotal);
|
| 166 |
+
$orderItem->setBaseRowTotal($overridedRowTotal);
|
| 167 |
+
|
| 168 |
+
break;
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
// END OF *5*
|
| 172 |
+
// *******************************************************
|
| 173 |
+
|
| 174 |
+
$order->addItem($orderItem);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
// *1* *****************************************************
|
| 178 |
+
// CODE ADDED TO MANAGE CUSTOM SHIPPING/PRODUCT COSTS
|
| 179 |
+
$order->setShippingMethod('flatrate'); // Needed for Magento 1.6 otherwise the shipment page breaks
|
| 180 |
+
$total = $overridedSubtotal + $shippingFees;
|
| 181 |
+
$order->setBaseShippingAmount($shippingFees);
|
| 182 |
+
$order->setShippingAmount($shippingFees);
|
| 183 |
+
$order->setBaseShippingInclTax($shippingFees);
|
| 184 |
+
$order->setShippingInclTax($shippingFees);
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
$order->setBaseGrandTotal($total);
|
| 188 |
+
$order->setGrandTotal($total);
|
| 189 |
+
|
| 190 |
+
$order->setBaseSubtotal($overridedSubtotal);
|
| 191 |
+
$order->setSubtotal($overridedSubtotal);
|
| 192 |
+
$order->setBaseSubtotalInclTax($overridedSubtotal);
|
| 193 |
+
$order->setSubtotalInclTax($overridedSubtotal);
|
| 194 |
+
|
| 195 |
+
$order->setBaseTotalDue($total);
|
| 196 |
+
$order->setTotalDue($total);
|
| 197 |
+
|
| 198 |
+
$order->setShippingDescription($shippingMethodDescription);
|
| 199 |
+
// END OF *1*
|
| 200 |
+
// *******************************************************
|
| 201 |
+
|
| 202 |
+
$order->setQuote($quote);
|
| 203 |
+
|
| 204 |
+
$transaction->addObject($order);
|
| 205 |
+
$transaction->addCommitCallback(array($order, 'place'));
|
| 206 |
+
$transaction->addCommitCallback(array($order, 'save'));
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* We can use configuration data for declare new order status
|
| 210 |
+
*/
|
| 211 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order', array('order' => $order, 'quote' => $quote));
|
| 212 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_before', array('order' => $order, 'quote' => $quote));
|
| 213 |
+
try {
|
| 214 |
+
$transaction->save();
|
| 215 |
+
// $this->_inactivateQuote(); *3* Not available in magento 1.4
|
| 216 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order' => $order, 'quote' => $quote));
|
| 217 |
+
} catch (Exception $e) {
|
| 218 |
+
|
| 219 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
| 220 |
+
// reset customer ID's on exception, because customer not saved
|
| 221 |
+
$quote->getCustomer()->setId(null);
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
//reset order ID's on exception, because order not saved
|
| 225 |
+
$order->setId(null);
|
| 226 |
+
/** @var $item Mage_Sales_Model_Order_Item */
|
| 227 |
+
foreach ($order->getItemsCollection() as $item) {
|
| 228 |
+
$item->setOrderId(null);
|
| 229 |
+
$item->setItemId(null);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_failure', array('order' => $order, 'quote' => $quote));
|
| 233 |
+
throw $e;
|
| 234 |
+
}
|
| 235 |
+
Mage::dispatchEvent('sales_model_service_quote_submit_after', array('order' => $order, 'quote' => $quote));
|
| 236 |
+
$this->_order = $order;
|
| 237 |
+
return $order;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
// MAGENTO 1.6.? (Mage_Sales_Model_Service_Quote)
|
| 241 |
+
// Modifications :
|
| 242 |
+
// - none
|
| 243 |
+
public function getOrder()
|
| 244 |
+
{
|
| 245 |
+
return $this->_order;
|
| 246 |
+
}
|
| 247 |
+
}
|
app/code/local/GoDataFeed/Services/Model/Version/Api.php
CHANGED
|
@@ -4,6 +4,6 @@ class GoDataFeed_Services_Model_Version_Api
|
|
| 4 |
{
|
| 5 |
public function version()
|
| 6 |
{
|
| 7 |
-
return "1.0
|
| 8 |
}
|
| 9 |
}
|
| 4 |
{
|
| 5 |
public function version()
|
| 6 |
{
|
| 7 |
+
return "1.1.0"; // THIS ABSOLUTELY NEEDS TO BE IN SYNC WITH CONFIG.XML
|
| 8 |
}
|
| 9 |
}
|
app/code/local/GoDataFeed/Services/etc/api.xml
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
<api>
|
| 4 |
-
|
| 5 |
<resources>
|
| 6 |
|
| 7 |
<godatafeed_services translate="title" module="services">
|
|
@@ -31,10 +30,243 @@
|
|
| 31 |
</product_extendedList>
|
| 32 |
</methods>
|
| 33 |
</godatafeed_services_catalog_product>
|
| 34 |
-
</resources>
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
</api>
|
| 40 |
</config>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
<api>
|
|
|
|
| 4 |
<resources>
|
| 5 |
|
| 6 |
<godatafeed_services translate="title" module="services">
|
| 30 |
</product_extendedList>
|
| 31 |
</methods>
|
| 32 |
</godatafeed_services_catalog_product>
|
|
|
|
| 33 |
|
| 34 |
+
<godatafeed_services_cart_payment translate="title" module="services">
|
| 35 |
+
<model>services/cart_payment_api</model>
|
| 36 |
+
<title>Payment method information</title>
|
| 37 |
+
<acl>cart/payment</acl>
|
| 38 |
+
<methods>
|
| 39 |
+
<payment_custom_method translate="title" module="services">
|
| 40 |
+
<title>Set payment method</title>
|
| 41 |
+
<method>setCustomPaymentMethod</method>
|
| 42 |
+
<acl>cart/payment/method</acl>
|
| 43 |
+
</payment_custom_method>
|
| 44 |
+
</methods>
|
| 45 |
+
<faults module="services">
|
| 46 |
+
<store_not_exists>
|
| 47 |
+
<code>1001</code>
|
| 48 |
+
<message>Can not make operation because store is not exists</message>
|
| 49 |
+
</store_not_exists>
|
| 50 |
+
<quote_not_exists>
|
| 51 |
+
<code>1002</code>
|
| 52 |
+
<message>Can not make operation because quote is not exists</message>
|
| 53 |
+
</quote_not_exists>
|
| 54 |
+
<payment_method_empty>
|
| 55 |
+
<code>1071</code>
|
| 56 |
+
<message>Payment method data is empty.</message>
|
| 57 |
+
</payment_method_empty>
|
| 58 |
+
<billing_address_is_not_set>
|
| 59 |
+
<code>1072</code>
|
| 60 |
+
<message>Customer's billing address is not set. Required for payment method data.</message>
|
| 61 |
+
</billing_address_is_not_set>
|
| 62 |
+
<shipping_address_is_not_set>
|
| 63 |
+
<code>1073</code>
|
| 64 |
+
<message>Customer's shipping address is not set. Required for payment method data.</message>
|
| 65 |
+
</shipping_address_is_not_set>
|
| 66 |
+
<method_not_allowed>
|
| 67 |
+
<code>1074</code>
|
| 68 |
+
<message>Payment method is not allowed</message>
|
| 69 |
+
</method_not_allowed>
|
| 70 |
+
<payment_method_is_not_set>
|
| 71 |
+
<code>1075</code>
|
| 72 |
+
<message>Payment method is not set.</message>
|
| 73 |
+
</payment_method_is_not_set>
|
| 74 |
+
</faults>
|
| 75 |
+
</godatafeed_services_cart_payment>
|
| 76 |
+
|
| 77 |
+
<godatafeed_services_cart translate="title" module="services">
|
| 78 |
+
<model>services/cart_api</model>
|
| 79 |
+
<title>GoDataFeed OrderSync API - Cart</title>
|
| 80 |
+
<acl>cart</acl>
|
| 81 |
+
<methods>
|
| 82 |
+
<cart_custom_create translate="title" module="services">
|
| 83 |
+
<title>Create shopping cart</title>
|
| 84 |
+
<method>customCreate</method>
|
| 85 |
+
<acl>cart/create</acl>
|
| 86 |
+
</cart_custom_create>
|
| 87 |
+
<cart_custom_create_order translate="title" module="services">
|
| 88 |
+
<title>Create order</title>
|
| 89 |
+
<method>customCreateOrder</method>
|
| 90 |
+
<acl>cart/create</acl>
|
| 91 |
+
</cart_custom_create_order>
|
| 92 |
+
</methods>
|
| 93 |
+
<faults module="services">
|
| 94 |
+
<store_not_exists>
|
| 95 |
+
<code>1001</code>
|
| 96 |
+
<message>Can not make operation because store is not exists</message>
|
| 97 |
+
</store_not_exists>
|
| 98 |
+
<quote_not_exists>
|
| 99 |
+
<code>1002</code>
|
| 100 |
+
<message>Can not make operation because quote is not exists</message>
|
| 101 |
+
</quote_not_exists>
|
| 102 |
+
<quote_create_fault>
|
| 103 |
+
<code>1003</code>
|
| 104 |
+
<message>Can not create a quote.</message>
|
| 105 |
+
</quote_create_fault>
|
| 106 |
+
<quote_already_exists>
|
| 107 |
+
<code>1004</code>
|
| 108 |
+
<message>Can not create a quote because quote with such identifier is already exists</message>
|
| 109 |
+
</quote_already_exists>
|
| 110 |
+
<required_agreements_are_not_all>
|
| 111 |
+
<code>1005</code>
|
| 112 |
+
<message>You did not set all required agreements</message>
|
| 113 |
+
</required_agreements_are_not_all>
|
| 114 |
+
<invalid_checkout_type>
|
| 115 |
+
<code>1006</code>
|
| 116 |
+
<message>The checkout type is not valid. Select single checkout type.</message>
|
| 117 |
+
</invalid_checkout_type>
|
| 118 |
+
<guest_checkout_is_not_enabled>
|
| 119 |
+
<code>1007</code>
|
| 120 |
+
<message>Checkout is not available for guest</message>
|
| 121 |
+
</guest_checkout_is_not_enabled>
|
| 122 |
+
<create_order_fault>
|
| 123 |
+
<code>1008</code>
|
| 124 |
+
<message>Can not create an order.</message>
|
| 125 |
+
</create_order_fault>
|
| 126 |
+
</faults>
|
| 127 |
+
</godatafeed_services_cart>
|
| 128 |
+
|
| 129 |
+
<godatafeed_services_cart_product translate="title" module="services">
|
| 130 |
+
<model>services/cart_product_api</model>
|
| 131 |
+
<title>Cart Product API</title>
|
| 132 |
+
<acl>cart/product</acl>
|
| 133 |
+
<methods>
|
| 134 |
+
<cart_product_custom_add translate="title" module="services">
|
| 135 |
+
<title>Add product to shopping cart</title>
|
| 136 |
+
<method>customAdd</method>
|
| 137 |
+
<acl>cart/product/add</acl>
|
| 138 |
+
</cart_product_custom_add>
|
| 139 |
+
</methods>
|
| 140 |
+
<faults module="services">
|
| 141 |
+
<store_not_exists>
|
| 142 |
+
<code>1001</code>
|
| 143 |
+
<message>Can not make operation because store is not exists</message>
|
| 144 |
+
</store_not_exists>
|
| 145 |
+
<quote_not_exists>
|
| 146 |
+
<code>1002</code>
|
| 147 |
+
<message>Can not make operation because quote is not exists</message>
|
| 148 |
+
</quote_not_exists>
|
| 149 |
+
<invalid_product_data>
|
| 150 |
+
<code>1021</code>
|
| 151 |
+
<message>Product's data is not valid.</message>
|
| 152 |
+
</invalid_product_data>
|
| 153 |
+
<add_product_fault>
|
| 154 |
+
<code>1022</code>
|
| 155 |
+
<message>Product(s) could not be added.</message>
|
| 156 |
+
</add_product_fault>
|
| 157 |
+
<add_product_quote_save_fault>
|
| 158 |
+
<code>1023</code>
|
| 159 |
+
<message>Quote could not be saved during adding product(s) operation.</message>
|
| 160 |
+
</add_product_quote_save_fault>
|
| 161 |
+
<update_product_fault>
|
| 162 |
+
<code>1024</code>
|
| 163 |
+
<message>Product(s) could not be updated.</message>
|
| 164 |
+
</update_product_fault>
|
| 165 |
+
<update_product_quote_save_fault>
|
| 166 |
+
<code>1025</code>
|
| 167 |
+
<message>Quote could not be saved during updating product(s) operation.</message>
|
| 168 |
+
</update_product_quote_save_fault>
|
| 169 |
+
<remove_product_fault>
|
| 170 |
+
<code>1026</code>
|
| 171 |
+
<message>Product(s) could not be removed.</message>
|
| 172 |
+
</remove_product_fault>
|
| 173 |
+
<remove_product_quote_save_fault>
|
| 174 |
+
<code>1027</code>
|
| 175 |
+
<message>Quote could not be saved during removing product(s) operation.</message>
|
| 176 |
+
</remove_product_quote_save_fault>
|
| 177 |
+
<customer_not_set_for_quote>
|
| 178 |
+
<code>1028</code>
|
| 179 |
+
<message>Customer is not set for quote.</message>
|
| 180 |
+
</customer_not_set_for_quote>
|
| 181 |
+
<customer_quote_not_exist>
|
| 182 |
+
<code>1029</code>
|
| 183 |
+
<message>Customer's quote is not existed.</message>
|
| 184 |
+
</customer_quote_not_exist>
|
| 185 |
+
<quotes_are_similar>
|
| 186 |
+
<code>1030</code>
|
| 187 |
+
<message>Quotes are identical.</message>
|
| 188 |
+
</quotes_are_similar>
|
| 189 |
+
<unable_to_move_all_products>
|
| 190 |
+
<code>1031</code>
|
| 191 |
+
<message>Product(s) could not be moved.</message>
|
| 192 |
+
</unable_to_move_all_products>
|
| 193 |
+
<product_move_quote_save_fault>
|
| 194 |
+
<code>1032</code>
|
| 195 |
+
<message>One of quote could not be saved during moving product(s) operation.</message>
|
| 196 |
+
</product_move_quote_save_fault>
|
| 197 |
+
</faults>
|
| 198 |
+
</godatafeed_services_cart_product>
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
<godatafeed_services_cart_customer translate="title" module="services">
|
| 202 |
+
<title>GoDataFeed OrderSync API - Customer</title>
|
| 203 |
+
<model>services/cart_customer_api</model>
|
| 204 |
+
<acl>cart/customer</acl>
|
| 205 |
+
<methods>
|
| 206 |
+
<cart_customer_custom_set translate="title" module="services">
|
| 207 |
+
<title>Set customer for shopping cart</title>
|
| 208 |
+
<method>customSet</method>
|
| 209 |
+
<acl>cart/customer/set</acl>
|
| 210 |
+
</cart_customer_custom_set>
|
| 211 |
+
<cart_customer_custom_addresses translate="title" module="services">
|
| 212 |
+
<title>Set customer's addresses in shopping cart</title>
|
| 213 |
+
<method>customSetAddresses</method>
|
| 214 |
+
<acl>cart/customer/addresses</acl>
|
| 215 |
+
</cart_customer_custom_addresses>
|
| 216 |
+
</methods>
|
| 217 |
+
<faults module="services">
|
| 218 |
+
<store_not_exists>
|
| 219 |
+
<code>1001</code>
|
| 220 |
+
<message>Can not make operation because store is not exists</message>
|
| 221 |
+
</store_not_exists>
|
| 222 |
+
<quote_not_exists>
|
| 223 |
+
<code>1002</code>
|
| 224 |
+
<message>Can not make operation because quote is not exists</message>
|
| 225 |
+
</quote_not_exists>
|
| 226 |
+
<customer_not_set>
|
| 227 |
+
<code>1041</code>
|
| 228 |
+
<message>Customer is not set.</message>
|
| 229 |
+
</customer_not_set>
|
| 230 |
+
<customer_not_exists>
|
| 231 |
+
<code>1042</code>
|
| 232 |
+
<message>The customer's identifier is not valid or customer is not existed</message>
|
| 233 |
+
</customer_not_exists>
|
| 234 |
+
<customer_not_created>
|
| 235 |
+
<code>1043</code>
|
| 236 |
+
<message>Customer could not be created.</message>
|
| 237 |
+
</customer_not_created>
|
| 238 |
+
<customer_data_invalid>
|
| 239 |
+
<code>1044</code>
|
| 240 |
+
<message>Customer data is not valid.</message>
|
| 241 |
+
</customer_data_invalid>
|
| 242 |
+
<customer_mode_is_unknown>
|
| 243 |
+
<code>1045</code>
|
| 244 |
+
<message>Customer's mode is unknown</message>
|
| 245 |
+
</customer_mode_is_unknown>
|
| 246 |
+
<customer_address_data_empty>
|
| 247 |
+
<code>1051</code>
|
| 248 |
+
<message>Customer address data is empty.</message>
|
| 249 |
+
</customer_address_data_empty>
|
| 250 |
+
<customer_address_invalid>
|
| 251 |
+
<code>1052</code>
|
| 252 |
+
<message>Customer's address data is not valid.</message>
|
| 253 |
+
</customer_address_invalid>
|
| 254 |
+
<invalid_address_id>
|
| 255 |
+
<code>1053</code>
|
| 256 |
+
<message>The customer's address identifier is not valid</message>
|
| 257 |
+
</invalid_address_id>
|
| 258 |
+
<address_is_not_set>
|
| 259 |
+
<code>1054</code>
|
| 260 |
+
<message>Customer address is not set.</message>
|
| 261 |
+
</address_is_not_set>
|
| 262 |
+
<address_not_belong_customer>
|
| 263 |
+
<code>1055</code>
|
| 264 |
+
<message>Customer address identifier do not belong customer, which set in quote</message>
|
| 265 |
+
</address_not_belong_customer>
|
| 266 |
+
</faults>
|
| 267 |
+
</godatafeed_services_cart_customer>
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
</resources>
|
| 271 |
</api>
|
| 272 |
</config>
|
app/code/local/GoDataFeed/Services/etc/config.xml
CHANGED
|
@@ -2,8 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<GoDataFeed_Services>
|
| 5 |
-
<!--
|
| 6 |
-
<version>1.0.10</version>
|
| 7 |
</GoDataFeed_Services>
|
| 8 |
</modules>
|
| 9 |
<global>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<GoDataFeed_Services>
|
| 5 |
+
<version>1.1.0</version> <!-- THIS ABSOLUTELY NEEDS TO BE IN SYNC WITH Version/Api.php -->
|
|
|
|
| 6 |
</GoDataFeed_Services>
|
| 7 |
</modules>
|
| 8 |
<global>
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>GoDataFeed</name>
|
| 4 |
-
<version>1.0
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.godatafeed.com/supportedecommerce.aspx?sp=magento">©GoDataFeed All rights reserved</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>GoDataFeed’s powerful, turn-key datafeed management solution empowers Magento merchants with an affordable and effective way to optimize and automate their datafeed marketing.</summary>
|
| 10 |
<description>This extension automates product retrieval from Magento while providing enhanced attribute information. Install this extension to streamline your channel feed management with GoDataFeed.</description>
|
| 11 |
-
<notes>1.0
|
| 12 |
<authors><author><name>GoDataFeedSupport</name><user>auto-converted</user><email>support@godatafeed.com</email></author></authors>
|
| 13 |
-
<date>2012-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir name="GoDataFeed"><dir name="Services"><dir name="Helper"><file name="Data.php" hash="fbbbbac77dc06cc167e5ab2d3bd69263"/></dir><dir name="Model"><dir name="Catalog"><dir name="Product"><file name="Api.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies/>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>GoDataFeed</name>
|
| 4 |
+
<version>1.1.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.godatafeed.com/supportedecommerce.aspx?sp=magento">©GoDataFeed All rights reserved</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>GoDataFeed’s powerful, turn-key datafeed management solution empowers Magento merchants with an affordable and effective way to optimize and automate their datafeed marketing.</summary>
|
| 10 |
<description>This extension automates product retrieval from Magento while providing enhanced attribute information. Install this extension to streamline your channel feed management with GoDataFeed.</description>
|
| 11 |
+
<notes>1.1.0</notes>
|
| 12 |
<authors><author><name>GoDataFeedSupport</name><user>auto-converted</user><email>support@godatafeed.com</email></author></authors>
|
| 13 |
+
<date>2012-10-28</date>
|
| 14 |
+
<time>10:15:34</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="GoDataFeed"><dir name="Services"><dir name="Helper"><file name="Data.php" hash="fbbbbac77dc06cc167e5ab2d3bd69263"/></dir><dir name="Model"><dir name="Api"><dir name="Resource"><dir name="Checkout"><file name="Product.php" hash="d03cd3c306e6b940c9d37ef780d76979"/></dir><file name="Checkout.php" hash="4f689b0150a47625e9b1912a50f99009"/><file name="Customer.php" hash="f9e722373eccc42a1ab5d1d1df8f62b4"/></dir></dir><dir name="Cart"><dir name="Customer"><file name="Api.php" hash="79f65194334c0263b2b87f18c7642be4"/></dir><dir name="Payment"><file name="Api.php" hash="2251058e3f468f02b8f25cbb7a2603f5"/></dir><dir name="Product"><file name="Api.php" hash="b1ad852e70fb70604011ccf61ca9a28b"/></dir><file name="Api.php" hash="858c1d1ec6ac2daeca1b5c94855bb7fd"/></dir><dir name="Catalog"><dir name="Product"><file name="Api.php" hash="1d6b34071d9f61d8daa9dcd3e67af859"/></dir></dir><dir name="Method"><file name="OrderSync.php" hash="9a60ed4e0758255ada4b3a7e53f275f1"/></dir><dir name="Order"><file name="Payment.php" hash="b37fa553313e2ac70fa661c9bf3108c7"/></dir><dir name="Quote"><file name="Payment.php" hash="eac432f14ee163b3f3b04a0ef574853d"/></dir><dir name="Service"><file name="Quote.php" hash="e480ad4fc4d4493ddbfb0b6f29ecf8a7"/></dir><dir name="Version"><file name="Api.php" hash="3f9d0a6690b476287f6a3c2e35581e26"/></dir><file name="Quote.php" hash="5474009133786a34b088c15c29309cef"/></dir><dir name="etc"><file name="api.xml" hash="db65e2c6e69b3b90109d6e551916c5a9"/><file name="config.xml" hash="bbb50c9d58eb45ee684400932a387a3f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GoDataFeed_Services.xml" hash="e2f0d059f7dcd4ed86519c397bb9c310"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies/>
|
| 18 |
</package>
|
