Version Notes
OroCRM Bridge extension adds a couple of improvements to Magento SOAP API v2 in order to expose more shopping cart and customer data.
Download this release
Release Info
| Developer | Oro, Inc |
| Extension | Oro_Api |
| Version | 1.1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.1 to 1.1.1
- app/code/community/Oro/Api/Helper/Data.php +16 -0
- app/code/community/Oro/Api/Model/Catalog/Product/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Customer/Api.php +0 -0
- app/code/community/Oro/Api/Model/Customer/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Newsletter/Subscriber/Api.php +0 -0
- app/code/community/Oro/Api/Model/Newsletter/Subscriber/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Observer/Crm/Controller.php +138 -0
- app/code/community/Oro/Api/Model/Observer/Sales/Order.php +36 -0
- app/code/community/Oro/Api/Model/Ping.php +2 -1
- app/code/community/Oro/Api/Model/Ping/V2.php +0 -0
- app/code/community/Oro/Api/Model/Report/Product/Viewed/Api.php +0 -0
- app/code/community/Oro/Api/Model/Report/Product/Viewed/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Resource/Reports/Product/Index/Viewed/Collection.php +0 -1
- app/code/community/Oro/Api/Model/Sales/Order/Api.php +1 -1
- app/code/community/Oro/Api/Model/Sales/Order/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Sales/Quote/Api.php +0 -0
- app/code/community/Oro/Api/Model/Sales/Quote/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Wishlist/Api.php +0 -0
- app/code/community/Oro/Api/Model/Wishlist/Api/V2.php +0 -0
- app/code/community/Oro/Api/Model/Wishlist/Item/Api.php +0 -0
- app/code/community/Oro/Api/Model/Wishlist/Item/Api/V2.php +0 -0
- app/code/community/Oro/Api/controllers/Adminhtml/Oro/GatewayController.php +73 -0
- app/code/community/Oro/Api/controllers/Adminhtml/Oro/SalesController.php +78 -0
- app/code/community/Oro/Api/etc/api.xml +0 -0
- app/code/community/Oro/Api/etc/config.xml +53 -2
- app/code/community/Oro/Api/etc/workflow.xml +6 -0
- app/code/community/Oro/Api/etc/wsdl.xml +1 -1
- app/code/community/Oro/Api/etc/wsi.xml +0 -0
- app/etc/modules/Oro_Api.xml +16 -1
- package.xml +4 -4
app/code/community/Oro/Api/Helper/Data.php
CHANGED
|
@@ -18,6 +18,14 @@
|
|
| 18 |
class Oro_Api_Helper_Data
|
| 19 |
extends Mage_Api_Helper_Data
|
| 20 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
/**
|
| 22 |
* Parse filters and format them to be applicable for collection filtration
|
| 23 |
*
|
|
@@ -132,4 +140,12 @@ class Oro_Api_Helper_Data
|
|
| 132 |
|
| 133 |
return true;
|
| 134 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 18 |
class Oro_Api_Helper_Data
|
| 19 |
extends Mage_Api_Helper_Data
|
| 20 |
{
|
| 21 |
+
/**
|
| 22 |
+
* @return string
|
| 23 |
+
*/
|
| 24 |
+
public function getModuleName()
|
| 25 |
+
{
|
| 26 |
+
return $this->_getModuleName();
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
/**
|
| 30 |
* Parse filters and format them to be applicable for collection filtration
|
| 31 |
*
|
| 140 |
|
| 141 |
return true;
|
| 142 |
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* @return bool
|
| 146 |
+
*/
|
| 147 |
+
public function isOroRequest()
|
| 148 |
+
{
|
| 149 |
+
return (bool) Mage::registry('is-oro-request');
|
| 150 |
+
}
|
| 151 |
}
|
app/code/community/Oro/Api/Model/Catalog/Product/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Customer/Api.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Customer/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Newsletter/Subscriber/Api.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Newsletter/Subscriber/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Observer/Crm/Controller.php
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Oro Inc.
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is published at http://opensource.org/licenses/osl-3.0.php.
|
| 10 |
+
* If you did not receive a copy of the license and are unable to
|
| 11 |
+
* obtain it through the world-wide-web, please send an email
|
| 12 |
+
* to license@magecore.com so we can send you a copy immediately
|
| 13 |
+
*
|
| 14 |
+
* @category Oro
|
| 15 |
+
* @package Api
|
| 16 |
+
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
| 17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 18 |
+
*/
|
| 19 |
+
class Oro_Api_Model_Observer_Crm_Controller
|
| 20 |
+
{
|
| 21 |
+
/**
|
| 22 |
+
* Catch Oro requests and set required flags
|
| 23 |
+
*
|
| 24 |
+
* @param Varien_Event_Observer $observer
|
| 25 |
+
*/
|
| 26 |
+
public function handleRequest(Varien_Event_Observer $observer)
|
| 27 |
+
{
|
| 28 |
+
/** @var Mage_Core_Controller_Front_Action $controller */
|
| 29 |
+
$controller = $observer->getEvent()->getData('controller_action');
|
| 30 |
+
|
| 31 |
+
if (!preg_match('/^.+?\\/oro_gateway\\/clearSession/ui', $controller->getRequest()->getPathInfo())) {
|
| 32 |
+
if (preg_match('/^.+?\\/oro_gateway\\/do$/ui', $controller->getRequest()->getOriginalPathInfo()) || $controller->getRequest()->getParam('is-oro-request') || $controller->getRequest()->getCookie('is-oro-request')) {
|
| 33 |
+
$controller->setFlag('', 'is-oro-request', true);
|
| 34 |
+
if (!Mage::registry('is-oro-request')) {
|
| 35 |
+
Mage::register('is-oro-request', true);
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @param Varien_Event_Observer $observer
|
| 43 |
+
*/
|
| 44 |
+
public function handleResponse(Varien_Event_Observer $observer)
|
| 45 |
+
{
|
| 46 |
+
/** @var Mage_Core_Controller_Front_Action $controller */
|
| 47 |
+
$controller = $observer->getEvent()->getData('controller_action');
|
| 48 |
+
$session = Mage::getSingleton('adminhtml/session');
|
| 49 |
+
if (Mage::helper('oro_api')->isOroRequest()) {
|
| 50 |
+
if ($controller->getFullActionName() == $session->getData('oro_end_point')) {
|
| 51 |
+
$messages = Mage::getSingleton('adminhtml/session')->getMessages(false);
|
| 52 |
+
$quoteMessages = Mage::getSingleton('adminhtml/session_quote')->getMessages(false);
|
| 53 |
+
$errors = array_merge($messages->getErrors(), $quoteMessages->getErrors());
|
| 54 |
+
|
| 55 |
+
// assume that if error messages exist then do no redirect to "success_url"
|
| 56 |
+
if (empty($errors)) {
|
| 57 |
+
$this->_setCookieValue(0);
|
| 58 |
+
|
| 59 |
+
// clear all messages
|
| 60 |
+
Mage::getSingleton('adminhtml/session')->getMessages(true);
|
| 61 |
+
Mage::getSingleton('adminhtml/session_quote')->getMessages(true);
|
| 62 |
+
|
| 63 |
+
$controller->getResponse()->clearHeader('Location');
|
| 64 |
+
$controller->getResponse()->clearBody();
|
| 65 |
+
$controller->getResponse()->appendBody(
|
| 66 |
+
'<script type="text/javascript">setTimeout(function(){location.href = "'
|
| 67 |
+
. $session->getData('oro_success_url')
|
| 68 |
+
. '"}, 1000)</script>'
|
| 69 |
+
)->sendResponse();
|
| 70 |
+
exit;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
$this->_setCookieValue(1);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* @param Varien_Event_Observer $observer
|
| 80 |
+
*/
|
| 81 |
+
public function handleRenderLayout(Varien_Event_Observer $observer)
|
| 82 |
+
{
|
| 83 |
+
if (Mage::helper('oro_api')->isOroRequest()) {
|
| 84 |
+
$layout = Mage::app()->getLayout();
|
| 85 |
+
|
| 86 |
+
if (($contentBlock = $layout->getBlock('content')) instanceof Mage_Adminhtml_Block_Sales_Order_Create) {
|
| 87 |
+
$contentBlock->removeButton('reset');
|
| 88 |
+
|
| 89 |
+
// remove cart sidebar in case if we create order for active shopping cart
|
| 90 |
+
// because it has no sense to duplicate items info in two blocks
|
| 91 |
+
$sidebar = $layout->getBlock('sidebar');
|
| 92 |
+
/** @var $cartBlock Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Cart */
|
| 93 |
+
$cartBlock = $sidebar->getChild('cart');
|
| 94 |
+
if ($cartBlock && (bool)$cartBlock->getQuote()->getOrigData('is_active')) {
|
| 95 |
+
$sidebar->unsetChild('cart');
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/** @var Mage_Core_Block_Text $script */
|
| 100 |
+
$layout->createBlock('adminhtml/template', 'oro_script', array('template' => 'oro/api/script.phtml'));
|
| 101 |
+
|
| 102 |
+
$destination = null;
|
| 103 |
+
|
| 104 |
+
switch (true) {
|
| 105 |
+
case $layout->getBlock('form.additional.info') instanceof Mage_Core_Block_Text_List:
|
| 106 |
+
$destination = $layout->getBlock('form.additional.info');
|
| 107 |
+
break;
|
| 108 |
+
case $layout->getBlock('before_body_end') instanceof Mage_Core_Block_Text_List:
|
| 109 |
+
$destination = $layout->getBlock('before_body_end');
|
| 110 |
+
break;
|
| 111 |
+
case $layout->getBlock('content') instanceof Mage_Core_Block_Text_List:
|
| 112 |
+
$destination = $layout->getBlock('content');
|
| 113 |
+
break;
|
| 114 |
+
default:
|
| 115 |
+
$destination = null;
|
| 116 |
+
break;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
if ($destination) {
|
| 120 |
+
$destination->insert('oro_script');
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
if ($layout->getBlock('root') instanceof Mage_Core_Block_Template) {
|
| 124 |
+
$layout->getBlock('root')->setTemplate('oro/api/page.phtml');
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* Set oro cookie value
|
| 131 |
+
*
|
| 132 |
+
* @param mixed $value
|
| 133 |
+
*/
|
| 134 |
+
protected function _setCookieValue($value)
|
| 135 |
+
{
|
| 136 |
+
Mage::getSingleton('core/cookie')->set('is-oro-request', $value, null, null, null, null, false);
|
| 137 |
+
}
|
| 138 |
+
}
|
app/code/community/Oro/Api/Model/Observer/Sales/Order.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Oro Inc.
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is published at http://opensource.org/licenses/osl-3.0.php.
|
| 10 |
+
* If you did not receive a copy of the license and are unable to
|
| 11 |
+
* obtain it through the world-wide-web, please send an email
|
| 12 |
+
* to license@magecore.com so we can send you a copy immediately
|
| 13 |
+
*
|
| 14 |
+
* @category Oro
|
| 15 |
+
* @package Api
|
| 16 |
+
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
| 17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 18 |
+
*/
|
| 19 |
+
class Oro_Api_Model_Observer_Sales_Order
|
| 20 |
+
{
|
| 21 |
+
/**
|
| 22 |
+
* Deactivates quote after succeed order placement, this is temporary solution for correct CRM processing
|
| 23 |
+
*
|
| 24 |
+
* @param Varien_Event_Observer $observer
|
| 25 |
+
*/
|
| 26 |
+
public function onSubmitAllAfter(Varien_Event_Observer $observer)
|
| 27 |
+
{
|
| 28 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
| 29 |
+
$quote = $observer->getQuote();
|
| 30 |
+
|
| 31 |
+
if (Mage::helper('oro_api')->isOroRequest() && (bool)$quote->getOrigData('is_active')) {
|
| 32 |
+
$quote->setIsActive(false)
|
| 33 |
+
->save();
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
}
|
app/code/community/Oro/Api/Model/Ping.php
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
*/
|
| 18 |
class Oro_Api_Model_Ping extends Mage_Api_Model_Resource_Abstract
|
| 19 |
{
|
| 20 |
-
const VERSION = '1.
|
| 21 |
/**
|
| 22 |
* @return array
|
| 23 |
*/
|
|
@@ -26,6 +26,7 @@ class Oro_Api_Model_Ping extends Mage_Api_Model_Resource_Abstract
|
|
| 26 |
return array(
|
| 27 |
'version' => self::VERSION,
|
| 28 |
'mage_version' => Mage::getVersion(),
|
|
|
|
| 29 |
);
|
| 30 |
}
|
| 31 |
}
|
| 17 |
*/
|
| 18 |
class Oro_Api_Model_Ping extends Mage_Api_Model_Resource_Abstract
|
| 19 |
{
|
| 20 |
+
const VERSION = '1.1.0';
|
| 21 |
/**
|
| 22 |
* @return array
|
| 23 |
*/
|
| 26 |
return array(
|
| 27 |
'version' => self::VERSION,
|
| 28 |
'mage_version' => Mage::getVersion(),
|
| 29 |
+
'admin_url' => Mage::getUrl('adminhtml'),
|
| 30 |
);
|
| 31 |
}
|
| 32 |
}
|
app/code/community/Oro/Api/Model/Ping/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Report/Product/Viewed/Api.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Report/Product/Viewed/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Resource/Reports/Product/Index/Viewed/Collection.php
CHANGED
|
@@ -39,7 +39,6 @@ class Oro_Api_Model_Resource_Reports_Product_Index_Viewed_Collection
|
|
| 39 |
*/
|
| 40 |
protected function _getWhereCondition()
|
| 41 |
{
|
| 42 |
-
|
| 43 |
return array();
|
| 44 |
}
|
| 45 |
}
|
| 39 |
*/
|
| 40 |
protected function _getWhereCondition()
|
| 41 |
{
|
|
|
|
| 42 |
return array();
|
| 43 |
}
|
| 44 |
}
|
app/code/community/Oro/Api/Model/Sales/Order/Api.php
CHANGED
|
@@ -75,7 +75,7 @@ class Oro_Api_Model_Sales_Order_Api extends Mage_Sales_Model_Api_Resource
|
|
| 75 |
);
|
| 76 |
}
|
| 77 |
|
| 78 |
-
$result =
|
| 79 |
$result['shipping_address'] = $this->_getAttributes($order->getShippingAddress(), 'order_address');
|
| 80 |
$result['billing_address'] = $this->_getAttributes($order->getBillingAddress(), 'order_address');
|
| 81 |
$result['items'] = array();
|
| 75 |
);
|
| 76 |
}
|
| 77 |
|
| 78 |
+
$result = array();
|
| 79 |
$result['shipping_address'] = $this->_getAttributes($order->getShippingAddress(), 'order_address');
|
| 80 |
$result['billing_address'] = $this->_getAttributes($order->getBillingAddress(), 'order_address');
|
| 81 |
$result['items'] = array();
|
app/code/community/Oro/Api/Model/Sales/Order/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Sales/Quote/Api.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Sales/Quote/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Wishlist/Api.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Wishlist/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Wishlist/Item/Api.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/Model/Wishlist/Item/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/Oro/Api/controllers/Adminhtml/Oro/GatewayController.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Oro Inc.
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is published at http://opensource.org/licenses/osl-3.0.php.
|
| 9 |
+
* If you did not receive a copy of the license and are unable to
|
| 10 |
+
* obtain it through the world-wide-web, please send an email
|
| 11 |
+
* to license@magecore.com so we can send you a copy immediately
|
| 12 |
+
*
|
| 13 |
+
* @category Oro
|
| 14 |
+
* @package Api
|
| 15 |
+
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
class Oro_Api_Adminhtml_Oro_GatewayController
|
| 19 |
+
extends Mage_Adminhtml_Controller_Action
|
| 20 |
+
{
|
| 21 |
+
protected $_publicActions = array('do');
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Go to real admin url with session secret key
|
| 25 |
+
*/
|
| 26 |
+
public function doAction()
|
| 27 |
+
{
|
| 28 |
+
$request = $this->getRequest();
|
| 29 |
+
$params = $request->getParams();
|
| 30 |
+
|
| 31 |
+
if (isset($params['route'])) {
|
| 32 |
+
$route = $params['route'];
|
| 33 |
+
unset($params['route']);
|
| 34 |
+
$params['is-oro-request'] = true;
|
| 35 |
+
|
| 36 |
+
$url = $this->getUrl('adminhtml/' . $route, array('_query' => $params));
|
| 37 |
+
|
| 38 |
+
$configFile = Mage::getConfig()->getModuleDir('etc',Mage::helper('oro_api')->getModuleName()) . DS . 'workflow.xml';
|
| 39 |
+
/** @var Mage_Catalog_Model_Config $config */
|
| 40 |
+
$config = Mage::getModel('core/config');
|
| 41 |
+
$config->loadFile($configFile);
|
| 42 |
+
|
| 43 |
+
$workFlow = $request->getParam('workflow');
|
| 44 |
+
|
| 45 |
+
$endPoints = $config->getXpath("{$workFlow}/end_point_action");
|
| 46 |
+
if (count($endPoints)) {
|
| 47 |
+
$endPoint = (string)array_shift($endPoints);
|
| 48 |
+
|
| 49 |
+
Mage::getSingleton('adminhtml/session')->setData('oro_end_point', $endPoint);
|
| 50 |
+
Mage::getSingleton('adminhtml/session')->setData('oro_success_url', $request->getParam('success_url'));
|
| 51 |
+
Mage::getSingleton('adminhtml/session')->setData('oro_error_url', $request->getParam('error_url'));
|
| 52 |
+
|
| 53 |
+
$this->_redirectUrl($url);
|
| 54 |
+
|
| 55 |
+
} else {
|
| 56 |
+
$this->getResponse()->setBody($this->__('Endpoint not found.'));
|
| 57 |
+
}
|
| 58 |
+
} else {
|
| 59 |
+
$this->getResponse()->setBody($this->__('Please specify route name.'));
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Gateway error
|
| 65 |
+
*/
|
| 66 |
+
public function errorAction()
|
| 67 |
+
{
|
| 68 |
+
$response = $this->getResponse();
|
| 69 |
+
|
| 70 |
+
$response->setBody($this->__('Gateway error.'));
|
| 71 |
+
$response->setHttpResponseCode(400);
|
| 72 |
+
}
|
| 73 |
+
}
|
app/code/community/Oro/Api/controllers/Adminhtml/Oro/SalesController.php
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Oro Inc.
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is published at http://opensource.org/licenses/osl-3.0.php.
|
| 9 |
+
* If you did not receive a copy of the license and are unable to
|
| 10 |
+
* obtain it through the world-wide-web, please send an email
|
| 11 |
+
* to license@magecore.com so we can send you a copy immediately
|
| 12 |
+
*
|
| 13 |
+
* @category Oro
|
| 14 |
+
* @package Api
|
| 15 |
+
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
class Oro_Api_Adminhtml_Oro_SalesController
|
| 19 |
+
extends Mage_Adminhtml_Controller_Action
|
| 20 |
+
{
|
| 21 |
+
public function newOrderAction()
|
| 22 |
+
{
|
| 23 |
+
$quote = false;
|
| 24 |
+
$session = Mage::getSingleton('adminhtml/session_quote');
|
| 25 |
+
$session->clear();
|
| 26 |
+
|
| 27 |
+
$quoteId = $this->getRequest()->getParam('quote');
|
| 28 |
+
if (null !== $quoteId) {
|
| 29 |
+
$quote = $this->_getQuoteById($quoteId);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
$customerId = $this->getRequest()->getParam('customer');
|
| 33 |
+
if (null !== $customerId && $this->_checkCustomer($customerId)) {
|
| 34 |
+
$session->setQuoteId(null);
|
| 35 |
+
$session->setCustomerId((int)$customerId);
|
| 36 |
+
} elseif (false !== $quote) {
|
| 37 |
+
$customerId = (int)$quote->getCustomerId();
|
| 38 |
+
|
| 39 |
+
$session->setStoreId($quote->getStoreId());
|
| 40 |
+
$session->setQuoteId($quote->getId());
|
| 41 |
+
$session->setCustomerId($customerId);
|
| 42 |
+
} else {
|
| 43 |
+
return $this->_redirect('*/oro_gateway/error');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return $this->_redirect('*/sales_order_create/index', array('customer_id' => $customerId));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Load customer's frontend quote by given ID
|
| 51 |
+
*
|
| 52 |
+
* @param int $quoteId
|
| 53 |
+
*
|
| 54 |
+
* @return bool|Mage_Sales_Model_Quote
|
| 55 |
+
*/
|
| 56 |
+
protected function _getQuoteById($quoteId)
|
| 57 |
+
{
|
| 58 |
+
/** @var Mage_Sales_Model_Quote $quote */
|
| 59 |
+
$quote = Mage::getModel('sales/quote');
|
| 60 |
+
$quote->loadByIdWithoutStore($quoteId);
|
| 61 |
+
|
| 62 |
+
return $quote->getId() ? $quote : false;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Checks whether customer exists
|
| 67 |
+
*
|
| 68 |
+
* @param int $customerId
|
| 69 |
+
*
|
| 70 |
+
* @return bool
|
| 71 |
+
*/
|
| 72 |
+
private function _checkCustomer($customerId)
|
| 73 |
+
{
|
| 74 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 75 |
+
|
| 76 |
+
return (bool)$customer->getId();
|
| 77 |
+
}
|
| 78 |
+
}
|
app/code/community/Oro/Api/etc/api.xml
CHANGED
|
File without changes
|
app/code/community/Oro/Api/etc/config.xml
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<Oro_Api>
|
| 23 |
-
<version>1.
|
| 24 |
</Oro_Api>
|
| 25 |
</modules>
|
| 26 |
<global>
|
|
@@ -51,4 +51,55 @@
|
|
| 51 |
</oro_api_setup>
|
| 52 |
</resources>
|
| 53 |
</global>
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<Oro_Api>
|
| 23 |
+
<version>1.1.0</version>
|
| 24 |
</Oro_Api>
|
| 25 |
</modules>
|
| 26 |
<global>
|
| 51 |
</oro_api_setup>
|
| 52 |
</resources>
|
| 53 |
</global>
|
| 54 |
+
<admin>
|
| 55 |
+
<routers>
|
| 56 |
+
<adminhtml>
|
| 57 |
+
<args>
|
| 58 |
+
<modules>
|
| 59 |
+
<oro_api before="Mage_Adminhtml">Oro_Api_Adminhtml</oro_api>
|
| 60 |
+
</modules>
|
| 61 |
+
</args>
|
| 62 |
+
</adminhtml>
|
| 63 |
+
</routers>
|
| 64 |
+
</admin>
|
| 65 |
+
<adminhtml>
|
| 66 |
+
<events>
|
| 67 |
+
<controller_action_predispatch>
|
| 68 |
+
<observers>
|
| 69 |
+
<oro_api_handle_crm_request>
|
| 70 |
+
<type>singleton</type>
|
| 71 |
+
<class>oro_api/observer_crm_controller</class>
|
| 72 |
+
<method>handleRequest</method>
|
| 73 |
+
</oro_api_handle_crm_request>
|
| 74 |
+
</observers>
|
| 75 |
+
</controller_action_predispatch>
|
| 76 |
+
<controller_action_postdispatch>
|
| 77 |
+
<observers>
|
| 78 |
+
<oro_api_handle_crm_response>
|
| 79 |
+
<type>singleton</type>
|
| 80 |
+
<class>oro_api/observer_crm_controller</class>
|
| 81 |
+
<method>handleResponse</method>
|
| 82 |
+
</oro_api_handle_crm_response>
|
| 83 |
+
</observers>
|
| 84 |
+
</controller_action_postdispatch>
|
| 85 |
+
<controller_action_layout_render_before>
|
| 86 |
+
<observers>
|
| 87 |
+
<oro_api_handle_crm_layout>
|
| 88 |
+
<type>singleton</type>
|
| 89 |
+
<class>oro_api/observer_crm_controller</class>
|
| 90 |
+
<method>handleRenderLayout</method>
|
| 91 |
+
</oro_api_handle_crm_layout>
|
| 92 |
+
</observers>
|
| 93 |
+
</controller_action_layout_render_before>
|
| 94 |
+
<checkout_submit_all_after>
|
| 95 |
+
<observers>
|
| 96 |
+
<oro_api_sales_order_created>
|
| 97 |
+
<type>singleton</type>
|
| 98 |
+
<class>oro_api/observer_sales_order</class>
|
| 99 |
+
<method>onSubmitAllAfter</method>
|
| 100 |
+
</oro_api_sales_order_created>
|
| 101 |
+
</observers>
|
| 102 |
+
</checkout_submit_all_after>
|
| 103 |
+
</events>
|
| 104 |
+
</adminhtml>
|
| 105 |
+
</config>
|
app/code/community/Oro/Api/etc/workflow.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<oro_sales_new_order>
|
| 4 |
+
<end_point_action>adminhtml_sales_order_create_save</end_point_action>
|
| 5 |
+
</oro_sales_new_order>
|
| 6 |
+
</config>
|
app/code/community/Oro/Api/etc/wsdl.xml
CHANGED
|
@@ -200,7 +200,7 @@
|
|
| 200 |
<all>
|
| 201 |
<element name="version" type="xsd:string" minOccurs="0" />
|
| 202 |
<element name="mage_version" type="xsd:string" minOccurs="0" />
|
| 203 |
-
<element name="
|
| 204 |
</all>
|
| 205 |
</complexType>
|
| 206 |
|
| 200 |
<all>
|
| 201 |
<element name="version" type="xsd:string" minOccurs="0" />
|
| 202 |
<element name="mage_version" type="xsd:string" minOccurs="0" />
|
| 203 |
+
<element name="admin_url" type="xsd:string" minOccurs="0" />
|
| 204 |
</all>
|
| 205 |
</complexType>
|
| 206 |
|
app/code/community/Oro/Api/etc/wsi.xml
CHANGED
|
File without changes
|
app/etc/modules/Oro_Api.xml
CHANGED
|
@@ -1,6 +1,21 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<!--
|
| 3 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
-->
|
| 5 |
<config>
|
| 6 |
<modules>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<!--
|
| 3 |
+
/**
|
| 4 |
+
* MageCore
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is published at http://opensource.org/licenses/osl-3.0.php.
|
| 10 |
+
* If you did not receive a copy of the license and are unable to
|
| 11 |
+
* obtain it through the world-wide-web, please send an email
|
| 12 |
+
* to license@magecore.com so we can send you a copy immediately
|
| 13 |
+
*
|
| 14 |
+
* @category Oro
|
| 15 |
+
* @package Api
|
| 16 |
+
* @copyright Copyright 2013 Oro Inc. (http://www.orocrm.com)
|
| 17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 18 |
+
*/
|
| 19 |
-->
|
| 20 |
<config>
|
| 21 |
<modules>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Oro_Api</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
<description>OroCRM Bridge extension adds a couple of improvements to Magento SOAP API v2 in order to expose more shopping cart and customer data.</description>
|
| 11 |
<notes>OroCRM Bridge extension adds a couple of improvements to Magento SOAP API v2 in order to expose more shopping cart and customer data.</notes>
|
| 12 |
<authors><author><name>Oro, Inc</name><user>orocrm</user><email>info@orocrm.com</email></author></authors>
|
| 13 |
-
<date>2014-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magecommunity"><dir name="Oro"><dir name="Api"><dir name="Helper"><file name="Data.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.13</min><max>5.5.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Oro_Api</name>
|
| 4 |
+
<version>1.1.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>OroCRM Bridge extension adds a couple of improvements to Magento SOAP API v2 in order to expose more shopping cart and customer data.</description>
|
| 11 |
<notes>OroCRM Bridge extension adds a couple of improvements to Magento SOAP API v2 in order to expose more shopping cart and customer data.</notes>
|
| 12 |
<authors><author><name>Oro, Inc</name><user>orocrm</user><email>info@orocrm.com</email></author></authors>
|
| 13 |
+
<date>2014-04-15</date>
|
| 14 |
+
<time>10:30:53</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Oro"><dir name="Api"><dir name="Helper"><file name="Data.php" hash="94d7cebbd20dca0e0176e300a4165434"/></dir><dir name="Model"><dir name="Catalog"><dir name="Product"><dir name="Api"><file name="V2.php" hash="9fe5e65e1b189ba6a9fed25fe8d858d6"/></dir></dir></dir><dir name="Customer"><dir name="Api"><file name="V2.php" hash="89fc6f16e7f452438d4927669ea0f0de"/></dir><file name="Api.php" hash="5da59afaac86ecb594f8e3d280cdc67d"/></dir><dir name="Newsletter"><dir name="Subscriber"><dir name="Api"><file name="V2.php" hash="7b18db294f86ccf841a95aa7b7e656af"/></dir><file name="Api.php" hash="a49473afaca6c5bbbb82f58f41ff1650"/></dir></dir><dir name="Observer"><dir name="Crm"><file name="Controller.php" hash="10e07e0b8086c9475c6128cd2ac43878"/></dir><dir name="Sales"><file name="Order.php" hash="81e2f8992f57a406130c893072365782"/></dir></dir><dir name="Ping"><file name="V2.php" hash="0fa10110ecb67d32079c5530a979c55a"/></dir><file name="Ping.php" hash="e5f8c2feb8ece7f27ff4f13277da68fd"/><dir name="Report"><dir name="Product"><dir name="Viewed"><dir name="Api"><file name="V2.php" hash="c8481504cefd028a17cc4a6555182ad0"/></dir><file name="Api.php" hash="fe175f2aab97cafa47574f1da2e169a3"/></dir></dir></dir><dir name="Resource"><dir name="Reports"><dir name="Product"><dir name="Index"><dir name="Viewed"><file name="Collection.php" hash="199749c5c972ab305abff0c9b10e9954"/></dir></dir></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="Api"><file name="V2.php" hash="0621bd68c420feb8000dae6861c49369"/></dir><file name="Api.php" hash="62c6b56d1fbe74b44d0ec087b605334d"/></dir><dir name="Quote"><dir name="Api"><file name="V2.php" hash="4e8ba0ed7757110c4eae1d239b2adf76"/></dir><file name="Api.php" hash="193c05456f86b5072f0ee5c20cb22eac"/></dir></dir><dir name="Wishlist"><dir name="Api"><file name="V2.php" hash="f0ac63e1cf9440ed0e4ca72eb93834f2"/></dir><file name="Api.php" hash="3ebfc3b7841c265921ea05d63f8ba5a9"/><dir name="Item"><dir name="Api"><file name="V2.php" hash="43a919dae8dd432e211878a39ba3f4a2"/></dir><file name="Api.php" hash="8d5d856ea533b9b122c96d0bef32861b"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Oro"><file name="GatewayController.php" hash="aca4efd099a889a77fb119356d9fab23"/><file name="SalesController.php" hash="4ba37d2b0d86c0eeaf9e6fa2b7bac843"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="2ee90b80f4d29ab73b3517a3d19e7aa3"/><file name="config.xml" hash="bbaa0acc4714204e0dd4bad2bbdf8263"/><file name="workflow.xml" hash="12ad592e533d8a53187af25c46fb017e"/><file name="wsdl.xml" hash="daa6f02635ba6912c1155a6fb003a155"/><file name="wsi.xml" hash="ed1f4cac2c8afd96e266517c7ddfcb2b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Oro_Api.xml" hash="e4836dedcf0ace31dd01b117a1fd962e"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.13</min><max>5.5.0</max></php></required></dependencies>
|
| 18 |
</package>
|
