Version Notes
* Added language support
* Added connection to fraisr
Download this release
Release Info
| Developer | Andre Herrn |
| Extension | Fraisr |
| Version | 0.4.0 |
| Comparing to | |
| See all releases | |
Code changes from version 0.3.5 to 0.4.0
- app/code/community/Fraisr/Connect/Block/Adminhtml/Log.php +5 -5
- app/code/community/Fraisr/Connect/Block/Catalog/Product/View/Label.php +1 -0
- app/code/community/Fraisr/Connect/Helper/Data.php +2 -1
- app/code/community/Fraisr/Connect/Helper/Synchronisation/Order.php +43 -0
- app/code/community/Fraisr/Connect/Model/Config.php +12 -1
- app/code/community/Fraisr/Connect/Model/Observer.php +32 -0
- app/code/community/Fraisr/Connect/Model/Order.php +19 -39
- app/code/community/Fraisr/Connect/controllers/AbstractController.php +90 -0
- app/code/community/Fraisr/Connect/controllers/Adminhtml/SynchronisationController.php +14 -14
- app/code/community/Fraisr/Connect/controllers/OrdersController.php +22 -0
- app/code/community/Fraisr/Connect/etc/config.xml +14 -2
- app/code/community/Fraisr/Connect/sql/fraisrconnect_setup/mysql4-upgrade-0.3.5-0.4.0.php +21 -0
- package.xml +7 -6
app/code/community/Fraisr/Connect/Block/Adminhtml/Log.php
CHANGED
|
@@ -82,10 +82,10 @@ class Fraisr_Connect_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Gri
|
|
| 82 |
));
|
| 83 |
|
| 84 |
//Add order sync button
|
| 85 |
-
$this->_addButton('order_synchronisation', array(
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
));
|
| 90 |
}
|
| 91 |
}
|
| 82 |
));
|
| 83 |
|
| 84 |
//Add order sync button
|
| 85 |
+
// $this->_addButton('order_synchronisation', array(
|
| 86 |
+
// 'label' => $helper->__('Synchronize orders'),
|
| 87 |
+
// 'onclick' => 'setLocation(\'' . $urlModel->getUrl('fraisrconnect/adminhtml_synchronisation/order') .'\')',
|
| 88 |
+
// 'class' => 'add',
|
| 89 |
+
// ));
|
| 90 |
}
|
| 91 |
}
|
app/code/community/Fraisr/Connect/Block/Catalog/Product/View/Label.php
CHANGED
|
@@ -40,6 +40,7 @@ class Fraisr_Connect_Block_Catalog_Product_View_Label extends Mage_Catalog_Block
|
|
| 40 |
|
| 41 |
//Return iframe url
|
| 42 |
return $config->getApiUri().$config->getDonationLabelIframeUri(
|
|
|
|
| 43 |
$base64Hash
|
| 44 |
);
|
| 45 |
}
|
| 40 |
|
| 41 |
//Return iframe url
|
| 42 |
return $config->getApiUri().$config->getDonationLabelIframeUri(
|
| 43 |
+
substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2),
|
| 44 |
$base64Hash
|
| 45 |
);
|
| 46 |
}
|
app/code/community/Fraisr/Connect/Helper/Data.php
CHANGED
|
@@ -50,7 +50,8 @@ class Fraisr_Connect_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 50 |
{
|
| 51 |
$frontendSettings = array(
|
| 52 |
'label' => Mage::getModel('fraisrconnect/config')->getDonationLabel(),
|
| 53 |
-
'position' => Mage::getModel('fraisrconnect/config')->getDonationLabelPosition()
|
|
|
|
| 54 |
);
|
| 55 |
return Zend_Json::encode($frontendSettings);
|
| 56 |
}
|
| 50 |
{
|
| 51 |
$frontendSettings = array(
|
| 52 |
'label' => Mage::getModel('fraisrconnect/config')->getDonationLabel(),
|
| 53 |
+
'position' => Mage::getModel('fraisrconnect/config')->getDonationLabelPosition(),
|
| 54 |
+
'language' => substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2)
|
| 55 |
);
|
| 56 |
return Zend_Json::encode($frontendSettings);
|
| 57 |
}
|
app/code/community/Fraisr/Connect/Helper/Synchronisation/Order.php
CHANGED
|
@@ -66,6 +66,49 @@ class Fraisr_Connect_Helper_Synchronisation_Order extends Fraisr_Connect_Helper_
|
|
| 66 |
return $orderItemCollection;
|
| 67 |
}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
/**
|
| 70 |
* Get order item qty for fraisr-synchronisation
|
| 71 |
*
|
| 66 |
return $orderItemCollection;
|
| 67 |
}
|
| 68 |
|
| 69 |
+
/**
|
| 70 |
+
* Check if the order_item is valid to be transferred to fraisr
|
| 71 |
+
*
|
| 72 |
+
* @param Mage_Sales_Model_Order_Item $orderItem
|
| 73 |
+
* @return boolean
|
| 74 |
+
*/
|
| 75 |
+
public function isOrderItemValid($orderItem)
|
| 76 |
+
{
|
| 77 |
+
//Check if all necessary data for the transfer is existing
|
| 78 |
+
if (true === is_null($orderItem->getFraisrProductId())
|
| 79 |
+
|| true === is_null($orderItem->getFraisrCauseId())
|
| 80 |
+
|| true === is_null($orderItem->getFraisrDonationPercentage())) {
|
| 81 |
+
return false;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
//Check if 'base_currency_code' or 'order_currency_code' is EUR
|
| 85 |
+
if ('EUR' !== $orderItem->getBaseCurrencyCode()
|
| 86 |
+
&& 'EUR' === $orderItem->getOrderCurrencyCode()) {
|
| 87 |
+
return false;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
return true;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
public function getJsonObject($orderItem){
|
| 94 |
+
$price = 0;
|
| 95 |
+
if ('EUR' === $orderItem->getBaseCurrencyCode()) {
|
| 96 |
+
$price = $orderItem->getBasePriceInclTax();
|
| 97 |
+
} elseif ('EUR' === $orderItem->getOrderCurrencyCode()) {
|
| 98 |
+
$price = $orderItem->getPriceInclTax();
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
return array(
|
| 102 |
+
'external_id' => $orderItem->getId(),
|
| 103 |
+
'fraisr_id' => $orderItem->getFraisrOrderId(),
|
| 104 |
+
'product' => $orderItem->getFraisrProductId(),
|
| 105 |
+
'amount' => $this->getOrderItemQty($orderItem),
|
| 106 |
+
'price' => $price,
|
| 107 |
+
'cause' => $orderItem->getFraisrCauseId(),
|
| 108 |
+
'donation' => $orderItem->getFraisrDonationPercentage()
|
| 109 |
+
);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
/**
|
| 113 |
* Get order item qty for fraisr-synchronisation
|
| 114 |
*
|
app/code/community/Fraisr/Connect/Model/Config.php
CHANGED
|
@@ -176,16 +176,27 @@ class Fraisr_Connect_Model_Config
|
|
| 176 |
);
|
| 177 |
}
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
/**
|
| 180 |
* Get donation label iframe url
|
| 181 |
*
|
| 182 |
* @param string $fraisrId
|
| 183 |
* @return string
|
| 184 |
*/
|
| 185 |
-
public function getDonationLabelIframeUri($fraisrId = '')
|
| 186 |
{
|
| 187 |
return (string) sprintf(
|
| 188 |
Mage::getStoreConfig('fraisrconnect/static/api/donation_label_iframe'),
|
|
|
|
| 189 |
$fraisrId
|
| 190 |
);
|
| 191 |
}
|
| 176 |
);
|
| 177 |
}
|
| 178 |
|
| 179 |
+
/**
|
| 180 |
+
* Get connect api url
|
| 181 |
+
*
|
| 182 |
+
* @return string
|
| 183 |
+
*/
|
| 184 |
+
public function getConnectApiUri()
|
| 185 |
+
{
|
| 186 |
+
return (string) Mage::getStoreConfig('fraisrconnect/static/api/connect');
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
/**
|
| 190 |
* Get donation label iframe url
|
| 191 |
*
|
| 192 |
* @param string $fraisrId
|
| 193 |
* @return string
|
| 194 |
*/
|
| 195 |
+
public function getDonationLabelIframeUri($lng = "en", $fraisrId = '')
|
| 196 |
{
|
| 197 |
return (string) sprintf(
|
| 198 |
Mage::getStoreConfig('fraisrconnect/static/api/donation_label_iframe'),
|
| 199 |
+
$lng,
|
| 200 |
$fraisrId
|
| 201 |
);
|
| 202 |
}
|
app/code/community/Fraisr/Connect/Model/Observer.php
CHANGED
|
@@ -242,4 +242,36 @@ class Fraisr_Connect_Model_Observer
|
|
| 242 |
->logError();
|
| 243 |
}
|
| 244 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
}
|
| 242 |
->logError();
|
| 243 |
}
|
| 244 |
}
|
| 245 |
+
|
| 246 |
+
public function connectToApi(){
|
| 247 |
+
$logger = Mage::getModel("fraisrconnect/log");
|
| 248 |
+
$config = Mage::getModel("fraisrconnect/config");
|
| 249 |
+
$callback_url = Mage::getUrl("fraisrconnect");
|
| 250 |
+
|
| 251 |
+
if($config->isActive() !== true)
|
| 252 |
+
return;
|
| 253 |
+
|
| 254 |
+
try{
|
| 255 |
+
$response = Mage::getModel('fraisrconnect/api_request')->requestPost(
|
| 256 |
+
Mage::getModel('fraisrconnect/config')->getConnectApiUri(),
|
| 257 |
+
compact("callback_url")
|
| 258 |
+
);
|
| 259 |
+
|
| 260 |
+
if($response["success"] !== true){
|
| 261 |
+
if(array_key_exists($response["error"])){
|
| 262 |
+
throw new Exception($response["error"]);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
throw new Exception("Unknown error occured:" . Zend_Json::encode($response));
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
$logger->setTitle("Connected to fraisr");
|
| 269 |
+
$logger->setMessage("Successfully connected to fraisr.");
|
| 270 |
+
$logger->logSuccess();
|
| 271 |
+
}catch(Exception $error){
|
| 272 |
+
$logger->setTitle("Connect Error");
|
| 273 |
+
$logger->setMessage($error->getMessage());
|
| 274 |
+
$logger->logError();
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
}
|
app/code/community/Fraisr/Connect/Model/Order.php
CHANGED
|
@@ -130,7 +130,7 @@ class Fraisr_Connect_Model_Order extends Mage_Core_Model_Abstract
|
|
| 130 |
foreach ($orderItemsToSynchronize as $orderItem) {
|
| 131 |
try {
|
| 132 |
//Validate order/order_item
|
| 133 |
-
if (false === $
|
| 134 |
continue;
|
| 135 |
}
|
| 136 |
|
|
@@ -172,30 +172,6 @@ class Fraisr_Connect_Model_Order extends Mage_Core_Model_Abstract
|
|
| 172 |
}
|
| 173 |
}
|
| 174 |
|
| 175 |
-
/**
|
| 176 |
-
* Check if the order_item is valid to be transferred to fraisr
|
| 177 |
-
*
|
| 178 |
-
* @param Mage_Sales_Model_Order_Item $orderItem
|
| 179 |
-
* @return boolean
|
| 180 |
-
*/
|
| 181 |
-
protected function isOrderItemValid($orderItem)
|
| 182 |
-
{
|
| 183 |
-
//Check if all necessary data for the transfer is existing
|
| 184 |
-
if (true === is_null($orderItem->getFraisrProductId())
|
| 185 |
-
|| true === is_null($orderItem->getFraisrCauseId())
|
| 186 |
-
|| true === is_null($orderItem->getFraisrDonationPercentage())) {
|
| 187 |
-
return false;
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
-
//Check if 'base_currency_code' or 'order_currency_code' is EUR
|
| 191 |
-
if ('EUR' !== $orderItem->getBaseCurrencyCode()
|
| 192 |
-
&& 'EUR' === $orderItem->getOrderCurrencyCode()) {
|
| 193 |
-
return false;
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
return true;
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
/**
|
| 200 |
* Prepare the data for the fraisr order create request
|
| 201 |
*
|
|
@@ -204,21 +180,25 @@ class Fraisr_Connect_Model_Order extends Mage_Core_Model_Abstract
|
|
| 204 |
*/
|
| 205 |
protected function prepareOrderRequestData($orderItem)
|
| 206 |
{
|
| 207 |
-
|
| 208 |
-
$price = 0;
|
| 209 |
-
if ('EUR' === $orderItem->getBaseCurrencyCode()) {
|
| 210 |
-
$price = $orderItem->getBasePriceInclTax();
|
| 211 |
-
} elseif ('EUR' === $orderItem->getOrderCurrencyCode()) {
|
| 212 |
-
$price = $orderItem->getPriceInclTax();
|
| 213 |
-
}
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
}
|
| 223 |
|
| 224 |
/**
|
| 130 |
foreach ($orderItemsToSynchronize as $orderItem) {
|
| 131 |
try {
|
| 132 |
//Validate order/order_item
|
| 133 |
+
if (false === $orderSyncHelper->isOrderItemValid($orderItem)) {
|
| 134 |
continue;
|
| 135 |
}
|
| 136 |
|
| 172 |
}
|
| 173 |
}
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
/**
|
| 176 |
* Prepare the data for the fraisr order create request
|
| 177 |
*
|
| 180 |
*/
|
| 181 |
protected function prepareOrderRequestData($orderItem)
|
| 182 |
{
|
| 183 |
+
return Mage::helper('fraisrconnect/synchronisation_order')->getJsonObject($orderItem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
//deprecated
|
| 186 |
+
|
| 187 |
+
//Calculate price
|
| 188 |
+
// $price = 0;
|
| 189 |
+
// if ('EUR' === $orderItem->getBaseCurrencyCode()) {
|
| 190 |
+
// $price = $orderItem->getBasePriceInclTax();
|
| 191 |
+
// } elseif ('EUR' === $orderItem->getOrderCurrencyCode()) {
|
| 192 |
+
// $price = $orderItem->getPriceInclTax();
|
| 193 |
+
// }
|
| 194 |
+
|
| 195 |
+
// return array(
|
| 196 |
+
// 'product' => $orderItem->getFraisrProductId(),
|
| 197 |
+
// 'amount' => Mage::helper('fraisrconnect/synchronisation_order')->getOrderItemQty($orderItem),
|
| 198 |
+
// 'price' => $price,
|
| 199 |
+
// 'cause' => $orderItem->getFraisrCauseId(),
|
| 200 |
+
// 'donation' => $orderItem->getFraisrDonationPercentage()
|
| 201 |
+
// );
|
| 202 |
}
|
| 203 |
|
| 204 |
/**
|
app/code/community/Fraisr/Connect/controllers/AbstractController.php
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
abstract class Fraisr_Connect_AbstractController extends Mage_Core_Controller_Front_Action{
|
| 4 |
+
/**
|
| 5 |
+
* @type Fraisr_Connect_Model_Config
|
| 6 |
+
*/
|
| 7 |
+
protected $_config = null;
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* @override
|
| 11 |
+
* @param Zend_Controller_Request_Abstract $request
|
| 12 |
+
* @param Zend_Controller_Response_Abstract $response
|
| 13 |
+
* @param array $invokeArgs
|
| 14 |
+
*/
|
| 15 |
+
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()){
|
| 16 |
+
parent::__construct($request, $response, $invokeArgs);
|
| 17 |
+
|
| 18 |
+
$this->getResponse()->setHeader("Content-Type", "application/json", true);
|
| 19 |
+
|
| 20 |
+
$this->_config = Mage::getModel("fraisrconnect/config");
|
| 21 |
+
|
| 22 |
+
try{
|
| 23 |
+
$this->_checkActive();
|
| 24 |
+
$this->_checkRequest();
|
| 25 |
+
}catch(Exception $error){
|
| 26 |
+
$this->_sendError($error);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* checks whether the plugin is enabled
|
| 32 |
+
* @throws Exception when plugin is disabled
|
| 33 |
+
*/
|
| 34 |
+
protected function _checkActive(){
|
| 35 |
+
if (!$this->_config->isActive())
|
| 36 |
+
throw new Exception("The fraisr plugin is currently disabled");
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* compares token
|
| 41 |
+
* @throws Exception when token is invalid
|
| 42 |
+
*/
|
| 43 |
+
protected function _checkRequest(){
|
| 44 |
+
if (null === ($token = $this->getRequest()->getParam("token", null)))
|
| 45 |
+
throw new Exception("Missing param 'token'");
|
| 46 |
+
|
| 47 |
+
if ($token !== $this->_getToken())
|
| 48 |
+
throw new Exception("Param 'token' is invalid.");
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* returns token
|
| 53 |
+
* @throws Exception if API key and/or secret are not defined
|
| 54 |
+
*/
|
| 55 |
+
protected function _getToken(){
|
| 56 |
+
$key = $this->_config->getApiKey();
|
| 57 |
+
$secret = $this->_config->getApiSecret();
|
| 58 |
+
|
| 59 |
+
if(strlen($key) > 0 && strlen($secret) > 0){
|
| 60 |
+
return hash("sha512", implode('|', array($key, $secret)));
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
throw new Exception("API key and/or secret are not defined");
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Sends an error response
|
| 68 |
+
* @param Exception $error
|
| 69 |
+
*/
|
| 70 |
+
protected function _sendError(Exception $error){
|
| 71 |
+
$this->getResponse()->setHttpResponseCode(400);
|
| 72 |
+
$body = array(
|
| 73 |
+
"message" => $error->getMessage()
|
| 74 |
+
);
|
| 75 |
+
$this->_send($body);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Sends the response
|
| 80 |
+
* @param Array|Object $body
|
| 81 |
+
*/
|
| 82 |
+
protected function _send($body){
|
| 83 |
+
$response = $this->getResponse();
|
| 84 |
+
$body = Zend_Json::encode($body);
|
| 85 |
+
$response->setBody($body);
|
| 86 |
+
die($response->sendResponse());
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
?>
|
app/code/community/Fraisr/Connect/controllers/Adminhtml/SynchronisationController.php
CHANGED
|
@@ -126,24 +126,24 @@ class Fraisr_Connect_Adminhtml_SynchronisationController extends Mage_Adminhtml_
|
|
| 126 |
/**
|
| 127 |
* Trigger order synchronisation
|
| 128 |
*
|
| 129 |
-
* @
|
| 130 |
*/
|
| 131 |
public function orderAction()
|
| 132 |
{
|
| 133 |
-
if (true === Mage::helper('fraisrconnect/adminhtml_data')->isActive(true)) {
|
| 134 |
-
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
}
|
| 147 |
|
| 148 |
$this->_redirectReferer();
|
| 149 |
return;
|
| 126 |
/**
|
| 127 |
* Trigger order synchronisation
|
| 128 |
*
|
| 129 |
+
* @deprecated
|
| 130 |
*/
|
| 131 |
public function orderAction()
|
| 132 |
{
|
| 133 |
+
// if (true === Mage::helper('fraisrconnect/adminhtml_data')->isActive(true)) {
|
| 134 |
+
// $orderSyncronisation = Mage::getModel('fraisrconnect/order');
|
| 135 |
+
// $orderSyncronisation->synchronize();
|
| 136 |
|
| 137 |
+
// if (false === $orderSyncronisation->isSynchronisationComplete()) {
|
| 138 |
+
// Mage::getSingleton('adminhtml/session')->addWarning(
|
| 139 |
+
// Mage::helper('fraisrconnect/data')->__('Not all orders have been synchronized because of a transmission error or a script timeout. Please start the process again.')
|
| 140 |
+
// );
|
| 141 |
+
// } else {
|
| 142 |
+
// Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 143 |
+
// Mage::helper('fraisrconnect/data')->__('fraisr order synchronisation completed.')
|
| 144 |
+
// );
|
| 145 |
+
// }
|
| 146 |
+
// }
|
| 147 |
|
| 148 |
$this->_redirectReferer();
|
| 149 |
return;
|
app/code/community/Fraisr/Connect/controllers/OrdersController.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
require_once "AbstractController.php";
|
| 4 |
+
|
| 5 |
+
class Fraisr_Connect_OrdersController extends Fraisr_Connect_AbstractController{
|
| 6 |
+
public function indexAction(){
|
| 7 |
+
$helper = Mage::helper("fraisrconnect/synchronisation_order");
|
| 8 |
+
$orders = $helper->getOrderItemsToSynchronize();
|
| 9 |
+
$body = array();
|
| 10 |
+
|
| 11 |
+
foreach ($orders as $order) {
|
| 12 |
+
if(!$helper->isOrderItemValid($order))
|
| 13 |
+
continue;
|
| 14 |
+
|
| 15 |
+
array_push($body, $helper->getJsonObject($order));
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
$this->_send($body);
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
?>
|
app/code/community/Fraisr/Connect/etc/config.xml
CHANGED
|
@@ -19,7 +19,7 @@
|
|
| 19 |
<config>
|
| 20 |
<modules>
|
| 21 |
<Fraisr_Connect>
|
| 22 |
-
<version>0.
|
| 23 |
</Fraisr_Connect>
|
| 24 |
</modules>
|
| 25 |
<global>
|
|
@@ -88,6 +88,15 @@
|
|
| 88 |
</fraisr_add_fraisrid_to_order_item>
|
| 89 |
</observers>
|
| 90 |
</sales_convert_quote_item_to_order_item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
</events>
|
| 92 |
</global>
|
| 93 |
<frontend>
|
|
@@ -178,6 +187,7 @@
|
|
| 178 |
</run>
|
| 179 |
</fraisrconnect_synchronisation_products>
|
| 180 |
<!-- Orders synchronisation -->
|
|
|
|
| 181 |
<fraisrconnect_synchronisation_orders>
|
| 182 |
<schedule>
|
| 183 |
<cron_expr>0 4 * * *</cron_expr>
|
|
@@ -186,6 +196,7 @@
|
|
| 186 |
<model>fraisrconnect/observer::synchronizeOrders</model>
|
| 187 |
</run>
|
| 188 |
</fraisrconnect_synchronisation_orders>
|
|
|
|
| 189 |
</jobs>
|
| 190 |
</crontab>
|
| 191 |
<default>
|
|
@@ -218,11 +229,12 @@
|
|
| 218 |
<api>
|
| 219 |
<live>https://www.fraisr.com/</live>
|
| 220 |
<sandbox>https://fraisr-test.herokuapp.com/</sandbox>
|
|
|
|
| 221 |
<cause>api/v1/causes/for-shops</cause>
|
| 222 |
<category>api/v1/categories</category>
|
| 223 |
<product>api/v1/products/%s</product>
|
| 224 |
<order>/api/v1/orders/%s</order>
|
| 225 |
-
<donation_label_iframe
|
| 226 |
<frontend_js>widgets/javascripts/magento/fraisr.js</frontend_js>
|
| 227 |
<frontend_css>widgets/stylesheets/magento/fraisr.css</frontend_css>
|
| 228 |
<plugin_identification_value>magento</plugin_identification_value>
|
| 19 |
<config>
|
| 20 |
<modules>
|
| 21 |
<Fraisr_Connect>
|
| 22 |
+
<version>0.4.0</version>
|
| 23 |
</Fraisr_Connect>
|
| 24 |
</modules>
|
| 25 |
<global>
|
| 88 |
</fraisr_add_fraisrid_to_order_item>
|
| 89 |
</observers>
|
| 90 |
</sales_convert_quote_item_to_order_item>
|
| 91 |
+
<admin_system_config_changed_section_fraisrconnect>
|
| 92 |
+
<observers>
|
| 93 |
+
<fraisr_connect_to_api>
|
| 94 |
+
<class>fraisrconnect/observer</class>
|
| 95 |
+
<method>connectToApi</method>
|
| 96 |
+
<type>singleton</type>
|
| 97 |
+
</fraisr_connect_to_api>
|
| 98 |
+
</observers>
|
| 99 |
+
</admin_system_config_changed_section_fraisrconnect>
|
| 100 |
</events>
|
| 101 |
</global>
|
| 102 |
<frontend>
|
| 187 |
</run>
|
| 188 |
</fraisrconnect_synchronisation_products>
|
| 189 |
<!-- Orders synchronisation -->
|
| 190 |
+
<!--
|
| 191 |
<fraisrconnect_synchronisation_orders>
|
| 192 |
<schedule>
|
| 193 |
<cron_expr>0 4 * * *</cron_expr>
|
| 196 |
<model>fraisrconnect/observer::synchronizeOrders</model>
|
| 197 |
</run>
|
| 198 |
</fraisrconnect_synchronisation_orders>
|
| 199 |
+
-->
|
| 200 |
</jobs>
|
| 201 |
</crontab>
|
| 202 |
<default>
|
| 229 |
<api>
|
| 230 |
<live>https://www.fraisr.com/</live>
|
| 231 |
<sandbox>https://fraisr-test.herokuapp.com/</sandbox>
|
| 232 |
+
<connect>api/v1/connect</connect>
|
| 233 |
<cause>api/v1/causes/for-shops</cause>
|
| 234 |
<category>api/v1/categories</category>
|
| 235 |
<product>api/v1/products/%s</product>
|
| 236 |
<order>/api/v1/orders/%s</order>
|
| 237 |
+
<donation_label_iframe>%s/trusted-shop/%s</donation_label_iframe>
|
| 238 |
<frontend_js>widgets/javascripts/magento/fraisr.js</frontend_js>
|
| 239 |
<frontend_css>widgets/stylesheets/magento/fraisr.css</frontend_css>
|
| 240 |
<plugin_identification_value>magento</plugin_identification_value>
|
app/code/community/Fraisr/Connect/sql/fraisrconnect_setup/mysql4-upgrade-0.3.5-0.4.0.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is available through the world-wide-web at this URL:
|
| 9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 10 |
+
*
|
| 11 |
+
* @category Fraisr
|
| 12 |
+
* @package Fraisr_Connect
|
| 13 |
+
* @copyright Copyright (c) 2013 das MedienKombinat Gmbh <kontakt@das-medienkombinat.de>
|
| 14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 15 |
+
* @author André Herrn <andre.herrn@das-medienkombinat.de>
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
$installer = $this;
|
| 19 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 20 |
+
$installer->startSetup();
|
| 21 |
+
$installer->endSetup();
|
package.xml
CHANGED
|
@@ -1,18 +1,19 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Fraisr</name>
|
| 4 |
-
<version>0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Extension zur Anbindung von Magento an den fraisr-Marktplatz</summary>
|
| 10 |
<description>Extension zur Anbindung von Magento an den fraisr-Marktplatz</description>
|
| 11 |
-
<notes
|
| 12 |
-
|
| 13 |
-
<
|
| 14 |
-
<
|
| 15 |
-
<
|
|
|
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Fraisr</name>
|
| 4 |
+
<version>0.4.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Extension zur Anbindung von Magento an den fraisr-Marktplatz</summary>
|
| 10 |
<description>Extension zur Anbindung von Magento an den fraisr-Marktplatz</description>
|
| 11 |
+
<notes>* Added language support
|
| 12 |
+
* Added connection to fraisr</notes>
|
| 13 |
+
<authors><author><name>Andre Herrn</name><user>fraisr</user><email>andre.herrn@das-medienkombinat.de</email></author><author><name>Christopher Knötschke</name><user>fraisr</user><email>chris@fraisr.com</email></author></authors>
|
| 14 |
+
<date>2013-10-11</date>
|
| 15 |
+
<time>13:28:21</time>
|
| 16 |
+
<contents><target name="magecommunity"><dir name="Fraisr"><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="Entity"><dir name="Attribute"><file name="FraisrId.php" hash="3b5b31fa5ea711b2ff7fd62493af9385"/><file name="FraisrUpdate.php" hash="7c4cd9a33e95d2a6157aa7e19e58faac"/></dir></dir><dir name="Log"><dir name="Edit"><file name="Form.php" hash="738ccce441a380d9e550dbb195d4ca65"/></dir><file name="Edit.php" hash="a7a9d340645576c63d48f878e7f89553"/><file name="Grid.php" hash="5fdad267ad670efa9ff8219aa6e81f58"/></dir><file name="Log.php" hash="70da89bf7cff8f93993701d3e97e57dc"/><dir name="System"><dir name="Config"><file name="Support.php" hash="87cefd408ad58ea5b60aa32960dbfcb9"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="Json"><file name="List.php" hash="bac5ca7939aba90877528281ab1c7d67"/><file name="View.php" hash="010195c62bded52ecaad7c5f2040f732"/></dir><dir name="View"><file name="Label.php" hash="de5f606295354b19ac28bdd18370c3b6"/></dir></dir></dir><dir name="Frontend"><file name="Widget.php" hash="104642fb642c5bc4d160df189d033f5a"/></dir></dir><file name="Exception.php" hash="56e65be5923c5095d3741b282d2dfd69"/><dir name="Helper"><dir name="Adminhtml"><file name="Data.php" hash="38160355e1a0e54f9a5306c5b5a413b2"/></dir><file name="Data.php" hash="1e11e42b6d3e5ed038aa5dd3faf07c68"/><dir name="Synchronisation"><file name="Abstract.php" hash="ddb949841004ec8aeb9d03f03753d6aa"/><file name="Order.php" hash="84a2996123f842415675670b37767d4b"/><file name="Product.php" hash="3870e04fb00db2e7f16f148d28509b89"/></dir></dir><dir name="Model"><dir name="Api"><file name="Exception.php" hash="e07c7c64278f3d1b6982eb36ac08e59f"/><file name="Request.php" hash="8f0359bf541e3fd6404a34976478a650"/><file name="Response.php" hash="6fcff68389fb6bff85b0743066e5f0cd"/></dir><file name="Category.php" hash="82c652c89ea5038e7a0a25a779acd481"/><file name="Cause.php" hash="c9fef8c82e096485a5a8945fe02a6115"/><file name="Config.php" hash="9fdcaf654f4544516ff684ef647dcfc8"/><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Category.php" hash="8516fdca6750d63b4e0c2b1430b12c36"/><file name="Cause.php" hash="45b934d6baa7e60c17b85f0ab444c824"/><file name="DonationPercentage.php" hash="603bccb9c8fcf68f76ed41fa421f4964"/><file name="Visibility.php" hash="eabb285ce7c1d02f88e3a5e909429da2"/></dir></dir></dir><file name="Log.php" hash="afa03219f67f5dfa3d6da9c69525b9f7"/><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="572bdc6a3a818a644a8afa170bd79a1c"/></dir><file name="Category.php" hash="ec8b07d6447905add97f3934622b839d"/><dir name="Cause"><file name="Collection.php" hash="37294f0c2b82e7dce37ef3aef99c45c2"/></dir><file name="Cause.php" hash="795bab5edab9c89987e09a8f260b2c73"/><dir name="Log"><file name="Collection.php" hash="1f0e9993959e694112be1762691600b3"/></dir><file name="Log.php" hash="88f831dc313b2873871a8db508717a47"/></dir><file name="Observer.php" hash="321a53a41ff22dadca94d1c38958a2fa"/><file name="Order.php" hash="0bb42ff34f3aa898d027df2ec28bd26c"/><file name="Product.php" hash="c7b3a18ce6e0f428929d2dc3e4fccc6f"/><dir name="Resource"><file name="Setup.php" hash="6e188164f57fe01fdade6af0e2b5966c"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="BanderolePosition.php" hash="6950b70d023c8d7ff475b7a1ec157363"/><file name="DonationLabel.php" hash="cad5e736745ec3d81a53c67e9cf2f018"/><file name="IconPosition.php" hash="70d21f296eea0833f8f2b5fd7278e1ec"/><file name="ProductAttribute.php" hash="9cbe063b1adc8e6441d490106cb290a8"/><file name="Scope.php" hash="90070b38db18fc47b07c590337253651"/></dir></dir></dir></dir><dir name="controllers"><file name="AbstractController.php" hash="f31bdb501dd175254a135eb63a760054"/><dir name="Adminhtml"><file name="LogController.php" hash="96be78d8f0bc0b927cb0296434066bed"/><file name="SynchronisationController.php" hash="c5034246cd58b91955a26a0cd1947b31"/></dir><file name="OrdersController.php" hash="4ae0b2dd6cb672485503b5695812439e"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c45830aa9aa1d61cb578280836fd1d77"/><file name="config.xml" hash="f50ed64513b12c502c29a1b28e367433"/><file name="system.xml" hash="3d33fe5e508b0667dc141b84d27e296e"/></dir><dir name="sql"><dir name="fraisrconnect_setup"><file name="mysql4-install-0.1.0.php" hash="538c2dda212b55e84facbe02020e8a1c"/><file name="mysql4-upgrade-0.1.0-0.1.2.php" hash="3c3826353e7aef17db3d43614022bd05"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="64341dc3b0e89ea6cce00ade40225305"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="746c98b109deea2b7648f16c9629a28d"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="04c452067cc87efd6140a369de5c0a27"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="a24f127685ec51d289b964a353258e05"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="011d3d7df9c2532d3295a53095764731"/><file name="mysql4-upgrade-0.1.7-0.1.8.php" hash="59b871795b0cef1789895a9e0de827eb"/><file name="mysql4-upgrade-0.1.8-0.2.0.php" hash="ca49d4510a5c6fbec8ce7414e11046a2"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="f9c5a6f192d10ef8985ae62904b7f68b"/><file name="mysql4-upgrade-0.2.1-0.2.2.php" hash="ca4e5fca6c3ab44f21a1d3cc92033bac"/><file name="mysql4-upgrade-0.2.2-0.3.0.php" hash="ef0fe908d322f82ebbb8b60b19320111"/><file name="mysql4-upgrade-0.3.0-0.3.3.php" hash="2f0b456b26f5d0fe02d59965c7ec1c47"/><file name="mysql4-upgrade-0.3.3-0.3.4.php" hash="12c4cf36ff8c0b4e64d1d3a46fed844a"/><file name="mysql4-upgrade-0.3.4-0.3.5.php" hash="d28242fa6ce43180fad6bcf501d90532"/><file name="mysql4-upgrade-0.3.5-0.4.0.php" hash="04c452067cc87efd6140a369de5c0a27"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fraisr_Connect.xml" hash="e037cdec4cbb114352f359be5167baf2"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="fraisrconnect"><dir name="catalog"><dir name="product"><dir name="json"><file name="list.phtml" hash="3361fe64acda92225d82cf028c960514"/><file name="view.phtml" hash="bf4b2a000e4c6f0748bf34f51f4238b5"/></dir><dir name="view"><file name="label_bottom.phtml" hash="bfa63e6c013424207d2d7df1d240ccb1"/><file name="label_top.phtml" hash="c9b9eec5c7bb546791eac70b770e9b68"/></dir></dir></dir><dir name="frontend"><file name="widget.phtml" hash="95f14bb9e6f2591a6b81d54437352e86"/></dir></dir></dir><dir name="layout"><file name="fraisrconnect.xml" hash="4f04d956b570f8e57f423fb77d408938"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="fraisrconnect"><dir name="system"><dir name="config"><file name="support.phtml" hash="be21e090f46e29ca2ce6e19474085fc4"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Fraisr_Connect.csv" hash="31eb112fb42c472d3b20781442f4c0d7"/></dir><dir name="en_US"><file name="Fraisr_Connect.csv" hash="8b3cbd33722724a7183fbfe3d6c1e5a2"/></dir></target></contents>
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 19 |
</package>
|
