Version Notes
Synchronize your inventory and order data with Prolog logistic software
Download this release
Release Info
| Developer | Silvertouch |
| Extension | Sttl_Prolog |
| Version | 0.1.1 |
| Comparing to | |
| See all releases | |
Version 0.1.1
- SILVER_Prolog_Sync_User_Guide_Ver_2.0.pdf +0 -0
- app/code/local/Sttl/Prolog/Helper/Data.php +212 -0
- app/code/local/Sttl/Prolog/Model/Observer.php +466 -0
- app/code/local/Sttl/Prolog/etc/config.xml +95 -0
- app/code/local/Sttl/Prolog/etc/system.xml +65 -0
- app/code/local/Sttl/Prolog/sql/prolog_setup/mysql4-install-0.1.0.php +83 -0
- app/etc/modules/Sttl_Prolog.xml +9 -0
- package.xml +28 -0
SILVER_Prolog_Sync_User_Guide_Ver_2.0.pdf
ADDED
|
Binary file
|
app/code/local/Sttl/Prolog/Helper/Data.php
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* SilverTouch Technologies Limited.
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the EULA
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
| 11 |
+
*
|
| 12 |
+
* @category Sttl
|
| 13 |
+
* @package Sttl_Prolog
|
| 14 |
+
* @copyright Copyright (c) 2011 SilverTouch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
| 15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Sttl_Prolog_Helper_Data extends Mage_Core_Helper_Abstract
|
| 19 |
+
{
|
| 20 |
+
const XML_PATH_PROLOG_URL = 'prolog/general/prolog_url';
|
| 21 |
+
const XML_PATH_PROLOG_USERNAME = 'prolog/general/prolog_username';
|
| 22 |
+
const XML_PATH_PROLOG_PASSWORD = 'prolog/general/prolog_password';
|
| 23 |
+
const XML_PATH_PROLOG_CUSTOMERID = 'prolog/general/prolog_customerid';
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Get Prolog Url
|
| 27 |
+
* return string
|
| 28 |
+
*/
|
| 29 |
+
public function getPrologUrl()
|
| 30 |
+
{
|
| 31 |
+
return Mage::getStoreConfig(self::XML_PATH_PROLOG_URL);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Get Prolog Username
|
| 36 |
+
* return string
|
| 37 |
+
*/
|
| 38 |
+
public function getPrologUsername()
|
| 39 |
+
{
|
| 40 |
+
return Mage::getStoreConfig(self::XML_PATH_PROLOG_USERNAME);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Get Prolog Password
|
| 45 |
+
* return string
|
| 46 |
+
*/
|
| 47 |
+
public function getPrologPassword()
|
| 48 |
+
{
|
| 49 |
+
$password = Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_PROLOG_PASSWORD));
|
| 50 |
+
return $password;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Get Prolog Customer Id
|
| 55 |
+
* return string
|
| 56 |
+
*/
|
| 57 |
+
public function getPrologCustomerId()
|
| 58 |
+
{
|
| 59 |
+
return Mage::getStoreConfig(self::XML_PATH_PROLOG_CUSTOMERID);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
public function xml2arrayNew($contents, $get_attributes=1, $priority = 'tag')
|
| 63 |
+
{
|
| 64 |
+
if(!$contents) return array();
|
| 65 |
+
|
| 66 |
+
if(!function_exists('xml_parser_create')) {
|
| 67 |
+
return array();
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
$parser = xml_parser_create('');
|
| 71 |
+
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
|
| 72 |
+
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
| 73 |
+
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
| 74 |
+
xml_parse_into_struct($parser, trim($contents), $xml_values);
|
| 75 |
+
xml_parser_free($parser);
|
| 76 |
+
|
| 77 |
+
if(!$xml_values) return;
|
| 78 |
+
|
| 79 |
+
$xml_array = array();
|
| 80 |
+
$parents = array();
|
| 81 |
+
$opened_tags = array();
|
| 82 |
+
$arr = array();
|
| 83 |
+
|
| 84 |
+
$current = &$xml_array;
|
| 85 |
+
|
| 86 |
+
$repeated_tag_index = array();
|
| 87 |
+
foreach($xml_values as $data) {
|
| 88 |
+
unset($attributes,$value);
|
| 89 |
+
|
| 90 |
+
extract($data);
|
| 91 |
+
|
| 92 |
+
$result = array();
|
| 93 |
+
$attributes_data = array();
|
| 94 |
+
|
| 95 |
+
if(isset($value)) {
|
| 96 |
+
if($priority == 'tag') $result = $value;
|
| 97 |
+
else $result['value'] = $value;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if(isset($attributes) and $get_attributes) {
|
| 101 |
+
foreach($attributes as $attr => $val) {
|
| 102 |
+
if($priority == 'tag') $attributes_data[$attr] = $val;
|
| 103 |
+
else $result['attr'][$attr] = $val;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
if($type == "open") {
|
| 108 |
+
$parent[$level-1] = &$current;
|
| 109 |
+
if(!is_array($current) or (!in_array($tag, array_keys($current)))) {
|
| 110 |
+
$current[$tag] = $result;
|
| 111 |
+
if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
|
| 112 |
+
$repeated_tag_index[$tag.'_'.$level] = 1;
|
| 113 |
+
|
| 114 |
+
$current = &$current[$tag];
|
| 115 |
+
|
| 116 |
+
} else {
|
| 117 |
+
|
| 118 |
+
if(isset($current[$tag][0])) {
|
| 119 |
+
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
|
| 120 |
+
$repeated_tag_index[$tag.'_'.$level]++;
|
| 121 |
+
} else {
|
| 122 |
+
$current[$tag] = array($current[$tag],$result);
|
| 123 |
+
$repeated_tag_index[$tag.'_'.$level] = 2;
|
| 124 |
+
|
| 125 |
+
if(isset($current[$tag.'_attr'])) {
|
| 126 |
+
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
|
| 127 |
+
unset($current[$tag.'_attr']);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
}
|
| 131 |
+
$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
|
| 132 |
+
$current = &$current[$tag][$last_item_index];
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
} elseif($type == "complete") {
|
| 136 |
+
if(!isset($current[$tag])) {
|
| 137 |
+
$current[$tag] = $result;
|
| 138 |
+
$repeated_tag_index[$tag.'_'.$level] = 1;
|
| 139 |
+
if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
} else {
|
| 144 |
+
if(isset($current[$tag][0]) and is_array($current[$tag])) {
|
| 145 |
+
|
| 146 |
+
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
|
| 147 |
+
|
| 148 |
+
if($priority == 'tag' and $get_attributes and $attributes_data) {
|
| 149 |
+
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
|
| 150 |
+
}
|
| 151 |
+
$repeated_tag_index[$tag.'_'.$level]++;
|
| 152 |
+
|
| 153 |
+
} else {
|
| 154 |
+
$current[$tag] = array($current[$tag],$result);
|
| 155 |
+
$repeated_tag_index[$tag.'_'.$level] = 1;
|
| 156 |
+
if($priority == 'tag' and $get_attributes) {
|
| 157 |
+
if(isset($current[$tag.'_attr'])) {
|
| 158 |
+
|
| 159 |
+
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
|
| 160 |
+
unset($current[$tag.'_attr']);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
if($attributes_data) {
|
| 164 |
+
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
$repeated_tag_index[$tag.'_'.$level]++;
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
} elseif($type == 'close') {
|
| 172 |
+
$current = &$parent[$level-1];
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
return($xml_array);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
public function & func_array_path_new(&$array, $tag_path, $strict=false)
|
| 180 |
+
{
|
| 181 |
+
if (!is_array($array) || empty($array)) return false;
|
| 182 |
+
|
| 183 |
+
if (empty($tag_path)) return $array;
|
| 184 |
+
|
| 185 |
+
$path = explode('/',$tag_path);
|
| 186 |
+
|
| 187 |
+
$elem =& $array;
|
| 188 |
+
|
| 189 |
+
foreach ($path as $key) {
|
| 190 |
+
if (isset($elem[$key])) {
|
| 191 |
+
$tmp_elem =& $elem[$key];
|
| 192 |
+
}
|
| 193 |
+
else {
|
| 194 |
+
if (!$strict && isset($elem['#'][$key])) {
|
| 195 |
+
$tmp_elem =& $elem['#'][$key];
|
| 196 |
+
}
|
| 197 |
+
else if (!$strict && isset($elem[0]['#'][$key])) {
|
| 198 |
+
$tmp_elem =& $elem[0]['#'][$key];
|
| 199 |
+
}
|
| 200 |
+
else {
|
| 201 |
+
return false;
|
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|
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the EULA
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
| 11 |
+
*
|
| 12 |
+
* @category Sttl
|
| 13 |
+
* @package Sttl_Prolog
|
| 14 |
+
* @copyright Copyright (c) 2011 SilverTouch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
| 15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
class Sttl_Prolog_Model_Observer
|
| 19 |
+
{
|
| 20 |
+
public $_prologUrl = null;
|
| 21 |
+
public $_prologUsername = null;
|
| 22 |
+
public $_prologPassword = null;
|
| 23 |
+
|
| 24 |
+
//public $prologShipCode = array('ups_GND' => 'UPSG', 'ups_1DA' => 'UPS1', 'ups_2DA' => 'UPS2');
|
| 25 |
+
|
| 26 |
+
public function getLoginDetail()
|
| 27 |
+
{
|
| 28 |
+
$this->_prologUrl = Mage::helper('prolog')->getPrologUrl();
|
| 29 |
+
$this->_prologUsername = Mage::helper('prolog')->getPrologUsername();
|
| 30 |
+
$this->_prologPassword = Mage::helper('prolog')->getPrologPassword();
|
| 31 |
+
}
|
| 32 |
+
/**
|
| 33 |
+
* Update Inventory
|
| 34 |
+
*/
|
| 35 |
+
public function scheduledUpdateInventory ()
|
| 36 |
+
{
|
| 37 |
+
$productCollection = Mage::getModel('catalog/product')->getCollection()
|
| 38 |
+
//->addAttributeToSelect('prolog_product_id')
|
| 39 |
+
->addFieldToFilter(array(
|
| 40 |
+
array('attribute'=>'prolog_product_id', 'neq'=>''))
|
| 41 |
+
);
|
| 42 |
+
$this->getLoginDetail();
|
| 43 |
+
|
| 44 |
+
// call product model and create product object
|
| 45 |
+
$product = Mage::getModel('catalog/product');
|
| 46 |
+
|
| 47 |
+
$soapAction = "SOAPAction: http://prolog3pl.com/PLGetInventory\r\n";
|
| 48 |
+
|
| 49 |
+
foreach ($productCollection as $productId) {
|
| 50 |
+
|
| 51 |
+
// Load product using product id
|
| 52 |
+
$product->load($productId->getId());
|
| 53 |
+
$plProductId = $productId->getPrologProductId();
|
| 54 |
+
|
| 55 |
+
if ($plProductId != "") {
|
| 56 |
+
//Get Prolog Available Inventory
|
| 57 |
+
$xmlDocument = '<?xml version="1.0" encoding="utf-8"?>
|
| 58 |
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
| 59 |
+
<soap:Body><PLGetInventory xmlns="http://prolog3pl.com/"><args>
|
| 60 |
+
<SystemId>' . $this->_prologUsername . '</SystemId><Password>' . $this->_prologPassword . '</Password><AllProducts>false</AllProducts><Products><string>'.$plProductId.'</string></Products>
|
| 61 |
+
</args></PLGetInventory></soap:Body></soap:Envelope>';
|
| 62 |
+
|
| 63 |
+
$result = $this->postXMLtoURL($this->_prologUrl, "/ProWaresService.asmx", $xmlDocument, $soapAction);
|
| 64 |
+
|
| 65 |
+
$current = "";
|
| 66 |
+
$count = 0;
|
| 67 |
+
$data = $this->getBody($result);
|
| 68 |
+
$data=eregi_replace(">"."[[:space:]]+"."<","><",$data);
|
| 69 |
+
$plarray =Mage::helper('prolog')->xml2arrayNew($data);
|
| 70 |
+
//print_r($plarray);
|
| 71 |
+
|
| 72 |
+
$plQuantityAvailable = $plarray['soap:Envelope']['soap:Body']['PLGetInventoryResponse']['PLGetInventoryResult']
|
| 73 |
+
['Inventory']['PLInventory']['QuantityAvailable'];
|
| 74 |
+
|
| 75 |
+
$stockData = $product->getStockData();
|
| 76 |
+
|
| 77 |
+
// update stock data using new data
|
| 78 |
+
$stockData['qty'] = $plQuantityAvailable;
|
| 79 |
+
if($plQuantityAvailable>0) {
|
| 80 |
+
$stockData['is_in_stock'] = 1;
|
| 81 |
+
} else {
|
| 82 |
+
$stockData['is_in_stock'] = 0;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// then set product's stock data to update
|
| 86 |
+
$product->setStockData($stockData);
|
| 87 |
+
|
| 88 |
+
// call save() method to save your product with updated data
|
| 89 |
+
$product->save();
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Send Order value in Prolog
|
| 97 |
+
*/
|
| 98 |
+
public function placeOrderPL ($observer)
|
| 99 |
+
{
|
| 100 |
+
$this->getLoginDetail();
|
| 101 |
+
|
| 102 |
+
$order = $observer->getOrder();
|
| 103 |
+
$OrderNumber = $order->getIncrementId();
|
| 104 |
+
$CustomerNumber = null;
|
| 105 |
+
$customerObject = Mage::getSingleton('customer/session');
|
| 106 |
+
/*if ($customerObject->isLoggedIn()) {
|
| 107 |
+
$CustomerNumber = $customerObject->getCustomerId();
|
| 108 |
+
$OrderNumber = $CustomerNumber.'_'.$OrderNumber;
|
| 109 |
+
}*/
|
| 110 |
+
$CustomerNumber = Mage::helper('prolog')->getPrologCustomerId();
|
| 111 |
+
$OrderNumber = $CustomerNumber.'_'.$OrderNumber;
|
| 112 |
+
|
| 113 |
+
$id = $order->getId();
|
| 114 |
+
$orderModel = Mage::getModel('sales/order')->load($id);
|
| 115 |
+
$orderModel->setPrologOrderId($OrderNumber);
|
| 116 |
+
$orderModel->setId($id);
|
| 117 |
+
$orderModel->save();
|
| 118 |
+
|
| 119 |
+
$CustomerOrderNumber = '';
|
| 120 |
+
$CustomerPO = '';
|
| 121 |
+
$OrderDate = Mage::getModel('core/date')->date('Y-m-d H:i:s');
|
| 122 |
+
$OrderDate = str_replace(' ', 'T', $OrderDate);
|
| 123 |
+
$Delay = '0';
|
| 124 |
+
$AutoAllocate = 'true';
|
| 125 |
+
$PartialShip = 'false';
|
| 126 |
+
$SplitShip = 'false';
|
| 127 |
+
|
| 128 |
+
$orderShippingMethod = $order->getshipping_method();
|
| 129 |
+
|
| 130 |
+
if ($orderShippingMethod == 'ups_GND') {
|
| 131 |
+
$ShippingService = 'UPSG';
|
| 132 |
+
} else if ($orderShippingMethod == 'ups_1DA') {
|
| 133 |
+
$ShippingService = 'UPS1';
|
| 134 |
+
} else if ($orderShippingMethod == 'ups_2DA') {
|
| 135 |
+
$ShippingService = 'UPS2';
|
| 136 |
+
} else if ($orderShippingMethod == 'usps_Priority Mail') {
|
| 137 |
+
$ShippingService = 'PM';
|
| 138 |
+
} else if ($orderShippingMethod == 'usps_Priority Mail International') {
|
| 139 |
+
$ShippingService = 'PMI';
|
| 140 |
+
} else if ($orderShippingMethod == 'usps_First-Class') {
|
| 141 |
+
$ShippingService = 'USPSFC';
|
| 142 |
+
} else {
|
| 143 |
+
$ShippingService = null;
|
| 144 |
+
}
|
| 145 |
+
/*print_r($ShippingService);
|
| 146 |
+
exit;*/
|
| 147 |
+
$BillThridParty = 'false';
|
| 148 |
+
$AccountNumber = '';
|
| 149 |
+
$SaturdayDelivery = 'false';
|
| 150 |
+
$Residential = 'false';
|
| 151 |
+
$InsurePackages = 'false';
|
| 152 |
+
$InsureThreshold = '0';
|
| 153 |
+
$EmailConfirmationAddress = $order->getBillingAddress()->getEmail();
|
| 154 |
+
$PackingListComment = 'Thank you for your order.';
|
| 155 |
+
|
| 156 |
+
$Subtotal = $order->getSubtotal();
|
| 157 |
+
$Shipping = $order->getShippingAmount();
|
| 158 |
+
$Handling = '0.00';
|
| 159 |
+
$Discount = $order->getDiscountAmount();
|
| 160 |
+
$Tax = $order->getTaxAmount();
|
| 161 |
+
$Total = $order->getGrandTotal();
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
//Get Shipping Details
|
| 167 |
+
$shippingAddressFirstName = $order->getShippingAddress()->getFirstname();
|
| 168 |
+
$shippingAddressLastName = $order->getShippingAddress()->getLastname();
|
| 169 |
+
$shippingAddressCompanyName = $order->getShippingAddress()->getCompany();
|
| 170 |
+
$shippingAddressAddress1 = $order->getShippingAddress()->getStreet1();
|
| 171 |
+
$shippingAddressAddress2 = $order->getShippingAddress()->getStreet2();
|
| 172 |
+
$shippingAddressAddress3 = '';
|
| 173 |
+
$shippingAddressCity = $order->getShippingAddress()->getCity();
|
| 174 |
+
$shippingAddressState = $order->getShippingAddress()->getRegion();
|
| 175 |
+
$shippingAddressPostalCode = $order->getShippingAddress()->getPostcode();
|
| 176 |
+
$shippingAddressCountry = $order->getShippingAddress()->getCountryId();
|
| 177 |
+
$shippingAddressPhoneNumber = $order->getShippingAddress()->getTelephone();
|
| 178 |
+
$shippingAddressEmailAddress = $order->getShippingAddress()->getEmail();
|
| 179 |
+
|
| 180 |
+
//Get Billing Details
|
| 181 |
+
$billingAddressFirstName = $order->getShippingAddress()->getFirstname();
|
| 182 |
+
$billingAddressLastName = $order->getBillingAddress()->getLastname();
|
| 183 |
+
$billingAddressCompanyName = $order->getBillingAddress()->getCompany();
|
| 184 |
+
$billingAddressAddress1 = $order->getBillingAddress()->getStreet1();
|
| 185 |
+
$billingAddressAddress2 = $order->getBillingAddress()->getStreet2();
|
| 186 |
+
$billingAddressAddress3 = '';
|
| 187 |
+
$billingAddressCity = $order->getBillingAddress()->getCity();
|
| 188 |
+
$billingAddressState = $order->getBillingAddress()->getRegion();
|
| 189 |
+
$billingAddressPostalCode = $order->getBillingAddress()->getPostcode();
|
| 190 |
+
$billingAddressCountry = $order->getBillingAddress()->getCountryId();
|
| 191 |
+
$billingAddressPhoneNumber = $order->getBillingAddress()->getTelephone();
|
| 192 |
+
$billingAddressEmailAddress = $order->getBillingAddress()->getEmail();
|
| 193 |
+
|
| 194 |
+
$xmlOrderInfo = ''.
|
| 195 |
+
'<SystemId>'.$this->_prologUsername.'</SystemId>'.
|
| 196 |
+
'<Password>'.$this->_prologPassword.'</Password>'.
|
| 197 |
+
'<Orders>'.
|
| 198 |
+
' <PLOrder>'.
|
| 199 |
+
' <OrderNumber>'.$OrderNumber.'</OrderNumber>'.
|
| 200 |
+
' <CustomerNumber>'.$CustomerNumber.'</CustomerNumber>'.
|
| 201 |
+
' <CustomerOrderNumber>'.$CustomerOrderNumber.'</CustomerOrderNumber>'.
|
| 202 |
+
' <CustomerPO>'.$CustomerPO.'</CustomerPO>'.
|
| 203 |
+
' <OrderDate>'.$OrderDate.'</OrderDate>'.
|
| 204 |
+
' <Delay>'.$Delay.'</Delay>'.
|
| 205 |
+
' <AutoAllocate>'.$AutoAllocate.'</AutoAllocate>'.
|
| 206 |
+
' <PartialShip>'.$PartialShip.'</PartialShip>'.
|
| 207 |
+
' <SplitShip>'.$SplitShip.'</SplitShip>'.
|
| 208 |
+
' <ShippingService>'.$ShippingService.'</ShippingService>'.
|
| 209 |
+
' <BillThridParty>'.$BillThridParty.'</BillThridParty>'.
|
| 210 |
+
' <AccountNumber>'.$AccountNumber.'</AccountNumber>'.
|
| 211 |
+
' <SaturdayDelivery>'.$SaturdayDelivery.'</SaturdayDelivery>'.
|
| 212 |
+
' <Residential>'.$Residential.'</Residential>'.
|
| 213 |
+
' <InsurePackages>'.$InsurePackages.'</InsurePackages>'.
|
| 214 |
+
' <InsureThreshold>'.$InsureThreshold.'</InsureThreshold>'.
|
| 215 |
+
' <EmailConfirmationAddress>'.$EmailConfirmationAddress.'</EmailConfirmationAddress>'.
|
| 216 |
+
' <PackingListComment>'.$PackingListComment.'</PackingListComment>'.
|
| 217 |
+
' <Subtotal>'.$Subtotal.'</Subtotal>'.
|
| 218 |
+
' <Shipping>'.$Shipping.'</Shipping>'.
|
| 219 |
+
' <Handling>'.$Handling.'</Handling>'.
|
| 220 |
+
' <Discount>'.$Discount.'</Discount>'.
|
| 221 |
+
' <Tax>'.$Tax.'</Tax>'.
|
| 222 |
+
' <Total>'.$Total.'</Total>'.
|
| 223 |
+
' <OrderLines>';
|
| 224 |
+
|
| 225 |
+
//Get Product Details
|
| 226 |
+
$orderItems = $order->getItemsCollection();
|
| 227 |
+
foreach ($orderItems as $item){
|
| 228 |
+
if($item->getRowTotal() > 0) {
|
| 229 |
+
$productSku = $item->getSku();
|
| 230 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $productSku);
|
| 231 |
+
$productDescription = '';
|
| 232 |
+
$xmlOrderInfo = $xmlOrderInfo.
|
| 233 |
+
' <PLOrderLine>'.
|
| 234 |
+
' <LineNumber>'.$product->getPrologLineNumber().'</LineNumber>'.
|
| 235 |
+
' <Product>'.$product->getPrologProductId().'</Product>'.
|
| 236 |
+
' <Description>'.$productDescription.'</Description>'.
|
| 237 |
+
' <Quantity>'.$item->getQtyOrdered().'</Quantity>'.
|
| 238 |
+
' <Price>'.$item->getPrice().'</Price>'.
|
| 239 |
+
' </PLOrderLine>';
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
$xmlOrderInfo = $xmlOrderInfo.
|
| 244 |
+
' </OrderLines>'.
|
| 245 |
+
' <ShippingAddress>'.
|
| 246 |
+
' <FirstName>'.$shippingAddressFirstName.'</FirstName>'.
|
| 247 |
+
' <LastName>'.$shippingAddressLastName.'</LastName>'.
|
| 248 |
+
' <CompanyName>'.$shippingAddressCompanyName.'</CompanyName>'.
|
| 249 |
+
' <Address1>'.$shippingAddressAddress1.'</Address1>'.
|
| 250 |
+
' <Address2>'.$shippingAddressAddress2.'</Address2>'.
|
| 251 |
+
' <Address3>'.$shippingAddressAddress3.'</Address3>'.
|
| 252 |
+
' <City>'.$shippingAddressCity.'</City>'.
|
| 253 |
+
' <State>'.$shippingAddressState.'</State>'.
|
| 254 |
+
' <PostalCode>'.$shippingAddressPostalCode.'</PostalCode>'.
|
| 255 |
+
' <Country>'.$shippingAddressCountry.'</Country>'.
|
| 256 |
+
' <PhoneNumber>'.$shippingAddressPhoneNumber.'</PhoneNumber>'.
|
| 257 |
+
' <EmailAddress>'.$shippingAddressEmailAddress.'</EmailAddress>'.
|
| 258 |
+
' </ShippingAddress>'.
|
| 259 |
+
' <BillingAddress>'.
|
| 260 |
+
' <FirstName>'.$billingAddressFirstName.'</FirstName>'.
|
| 261 |
+
' <LastName>'.$billingAddressLastName.'</LastName>'.
|
| 262 |
+
' <CompanyName>'.$billingAddressCompanyName.'</CompanyName>'.
|
| 263 |
+
' <Address1>'.$billingAddressAddress1.'</Address1>'.
|
| 264 |
+
' <Address2>'.$billingAddressAddress2.'</Address2>'.
|
| 265 |
+
' <Address3>'.$billingAddressAddress3.'</Address3>'.
|
| 266 |
+
' <City>'.$billingAddressCity.'</City>'.
|
| 267 |
+
' <State>'.$billingAddressState.'</State>'.
|
| 268 |
+
' <PostalCode>'.$billingAddressPostalCode.'</PostalCode>'.
|
| 269 |
+
' <Country>'.$billingAddressCountry.'</Country>'.
|
| 270 |
+
' <PhoneNumber>'.$billingAddressPhoneNumber.'</PhoneNumber>'.
|
| 271 |
+
' <EmailAddress>'.$billingAddressEmailAddress.'</EmailAddress>'.
|
| 272 |
+
' </BillingAddress>'.
|
| 273 |
+
' </PLOrder>'.
|
| 274 |
+
'</Orders>';
|
| 275 |
+
/*print_r($xmlOrderInfo);
|
| 276 |
+
exit;*/
|
| 277 |
+
|
| 278 |
+
$xmlDocument = '<?xml version="1.0" encoding="utf-8"?>
|
| 279 |
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
| 280 |
+
<soap:Body><PLSubmitOrder xmlns="http://prolog3pl.com/">
|
| 281 |
+
<args>'.$xmlOrderInfo.'</args></PLSubmitOrder></soap:Body></soap:Envelope>';
|
| 282 |
+
|
| 283 |
+
$soapAction = "SOAPAction: http://prolog3pl.com/PLSubmitOrder\r\n";
|
| 284 |
+
$result = $this->postXMLtoURL($this->_prologUrl, "/ProWaresService.asmx", $xmlDocument, $soapAction);
|
| 285 |
+
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/**
|
| 289 |
+
* get Order status from Prolog
|
| 290 |
+
*/
|
| 291 |
+
public function scheduledUpdateOrder()
|
| 292 |
+
{
|
| 293 |
+
$shippingDetails = null;
|
| 294 |
+
$carrier = null;
|
| 295 |
+
$title = null;
|
| 296 |
+
$plOrderStatus = null;
|
| 297 |
+
$trackingnumber = null;
|
| 298 |
+
|
| 299 |
+
$this->getLoginDetail();
|
| 300 |
+
|
| 301 |
+
$soapAction = "SOAPAction: http://prolog3pl.com/PLGetOrderStatus\r\n";
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()
|
| 306 |
+
->addFieldToFilter('status', array('neq' => 'complete'))
|
| 307 |
+
->addFieldToFilter('status', array('neq' => 'canceled'))
|
| 308 |
+
->addFieldToFilter('prolog_order_id',array('neq'=>''));
|
| 309 |
+
//$orderCollection->getSelect()->where('status != "complete" and status != "canceled" or prolog_order_id != null');
|
| 310 |
+
|
| 311 |
+
foreach ($orderCollection as $order) {
|
| 312 |
+
$orderObject = Mage::getModel('sales/order')->load($order->getEntityId());
|
| 313 |
+
$prologOrderId = $orderObject->getPrologOrderId();
|
| 314 |
+
|
| 315 |
+
if ($prologOrderId) {
|
| 316 |
+
|
| 317 |
+
$xmlDocument = '<?xml version="1.0" encoding="utf-8"?>
|
| 318 |
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
| 319 |
+
<soap:Body><PLGetOrderStatus xmlns="http://prolog3pl.com/"><args>
|
| 320 |
+
<SystemId>' . $this->_prologUsername . '</SystemId><Password>' . $this->_prologPassword . '</Password><OrderNumbers><string>'.$prologOrderId.'</string></OrderNumbers>
|
| 321 |
+
</args></PLGetOrderStatus></soap:Body></soap:Envelope>';
|
| 322 |
+
|
| 323 |
+
$result = $this->postXMLtoURL($this->_prologUrl, "/ProWaresService.asmx", $xmlDocument, $soapAction);
|
| 324 |
+
|
| 325 |
+
$current = "";
|
| 326 |
+
$count = 0;
|
| 327 |
+
$data = $this->getBody($result);
|
| 328 |
+
$data=eregi_replace(">"."[[:space:]]+"."<","><",$data);
|
| 329 |
+
|
| 330 |
+
$plOrderArray = Mage::helper('prolog')->xml2arrayNew($data);
|
| 331 |
+
$plOrderStatus = $plOrderArray['soap:Envelope']['soap:Body']['PLGetOrderStatusResponse']
|
| 332 |
+
['PLGetOrderStatusResult']['Orders']['PLOrderStatusHeader']['Status'];
|
| 333 |
+
$trackingnumber = $plOrderArray['soap:Envelope']['soap:Body']['PLGetOrderStatusResponse']
|
| 334 |
+
['PLGetOrderStatusResult']['Orders']['PLOrderStatusHeader']['Shipments']['PLOrderStatusShipment']
|
| 335 |
+
['Packages']['PLOrderStatusPackage']['TrackingNumber'];
|
| 336 |
+
|
| 337 |
+
//echo $plOrderStatus;
|
| 338 |
+
//Change Order Status in magento using prolog order status
|
| 339 |
+
if ($plOrderStatus == 'OPEN') {
|
| 340 |
+
if($orderObject->getStatus() == 'holded') {
|
| 341 |
+
$orderObject->unhold()->save();
|
| 342 |
+
}
|
| 343 |
+
} else if ($plOrderStatus == 'HOLD') {
|
| 344 |
+
$orderObject->hold()->save();
|
| 345 |
+
} else if ($plOrderStatus == 'COMPLETED') {
|
| 346 |
+
if($orderObject->getStatus() == 'holded') {
|
| 347 |
+
$orderObject->unhold()->save();
|
| 348 |
+
}
|
| 349 |
+
//Send Shipping Mail to Customer
|
| 350 |
+
if ($orderObject->canShip()) {
|
| 351 |
+
$this->SendShippingMail($orderObject);
|
| 352 |
+
}
|
| 353 |
+
} else if ($plOrderStatus == 'CANCELED') {
|
| 354 |
+
if($orderObject->getStatus() == 'holded') {
|
| 355 |
+
$orderObject->unhold()->save();
|
| 356 |
+
}
|
| 357 |
+
$orderObject->cancel()->save();
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
//echo $order->getEntityId()." ".$orderObject->getPrologOrderId()."<br/>";
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
/*
|
| 365 |
+
* Send Shipping Mail
|
| 366 |
+
*/
|
| 367 |
+
private function SendShippingMail ($orderObject)
|
| 368 |
+
{
|
| 369 |
+
$shippingDetails = split("_",$orderObject->getShippingMethod());
|
| 370 |
+
if($shippingDetails[0] == 'ups') {
|
| 371 |
+
$carrier = $shippingDetails[0];
|
| 372 |
+
$title = 'United Parcel Service';
|
| 373 |
+
} else if($shippingDetails[0] == 'usps') {
|
| 374 |
+
$carrier = $shippingDetails[0];
|
| 375 |
+
$title = 'United States Postal Service';
|
| 376 |
+
}
|
| 377 |
+
$convertor = Mage::getModel('sales/convert_order');
|
| 378 |
+
$shipment = $convertor->toShipment($orderObject);
|
| 379 |
+
|
| 380 |
+
foreach ($orderObject->getAllItems() as $orderItem) {
|
| 381 |
+
if (!$orderItem->getQtyToShip()) {
|
| 382 |
+
continue;
|
| 383 |
+
}
|
| 384 |
+
if ($orderItem->getIsVirtual()) {
|
| 385 |
+
continue;
|
| 386 |
+
}
|
| 387 |
+
$item = $convertor->itemToShipmentItem($orderItem);
|
| 388 |
+
$qty = $orderItem->getQtyToShip();
|
| 389 |
+
$item->setQty($qty);
|
| 390 |
+
$shipment->addItem($item);
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
$data = array();
|
| 394 |
+
$data['carrier_code'] = $carrier;
|
| 395 |
+
$data['title'] = $title;
|
| 396 |
+
$data['number'] = $trackingnumber;
|
| 397 |
+
|
| 398 |
+
$track = Mage::getModel('sales/order_shipment_track')->addData($data);
|
| 399 |
+
$shipment->addTrack($track);
|
| 400 |
+
|
| 401 |
+
$shipment->register();
|
| 402 |
+
$shipment->addComment('', false);
|
| 403 |
+
|
| 404 |
+
$shipment->setEmailSent(true);
|
| 405 |
+
|
| 406 |
+
$shipment->getOrder()->setIsInProcess(true);
|
| 407 |
+
|
| 408 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
| 409 |
+
->addObject($shipment)
|
| 410 |
+
->addObject($shipment->getOrder())
|
| 411 |
+
->save();
|
| 412 |
+
|
| 413 |
+
$shipment->sendEmail(true, '');
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
/**
|
| 417 |
+
* Get result from prolog
|
| 418 |
+
*
|
| 419 |
+
* @param string $server
|
| 420 |
+
* @param string $path
|
| 421 |
+
* @param string $xmlDocument
|
| 422 |
+
* @param string $sopAction
|
| 423 |
+
* @return xml value
|
| 424 |
+
*/
|
| 425 |
+
public function postXMLToURL ($server, $path, $xmlDocument, $soapAction)
|
| 426 |
+
{
|
| 427 |
+
$xmlSource = $xmlDocument;
|
| 428 |
+
$contentLength = strlen($xmlSource);
|
| 429 |
+
$fp = fsockopen($server, 80);
|
| 430 |
+
fputs($fp, "POST $path HTTP/1.0\r\n");
|
| 431 |
+
fputs($fp, "Host: $server\r\n");
|
| 432 |
+
fputs($fp, "Content-Type: text/xml\r\n");
|
| 433 |
+
fputs($fp, "Content-Length: $contentLength\r\n");
|
| 434 |
+
fputs($fp, $soapAction);
|
| 435 |
+
fputs($fp, "Connection: close\r\n");
|
| 436 |
+
fputs($fp, "\r\n"); // all headers sent
|
| 437 |
+
fputs($fp, $xmlSource);
|
| 438 |
+
$result = '';
|
| 439 |
+
while (!feof($fp)) {
|
| 440 |
+
$result .= fgets($fp, 128);
|
| 441 |
+
}
|
| 442 |
+
return $result;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
* Remove regular expression
|
| 447 |
+
*
|
| 448 |
+
* @param xml $httpResponse
|
| 449 |
+
* @return xml
|
| 450 |
+
*/
|
| 451 |
+
public function getBody ($httpResponse)
|
| 452 |
+
{
|
| 453 |
+
$lines = preg_split('/(\r\n|\r|\n)/', $httpResponse);
|
| 454 |
+
$responseBody = '';
|
| 455 |
+
$lineCount = count($lines);
|
| 456 |
+
for ($i = 0; $i < $lineCount; $i++) {
|
| 457 |
+
if ($lines[$i] == '') {
|
| 458 |
+
break;
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
for ($j = $i + 1; $j < $lineCount; $j++) {
|
| 462 |
+
$responseBody .= $lines[$j] . "\n";
|
| 463 |
+
}
|
| 464 |
+
return $responseBody;
|
| 465 |
+
}
|
| 466 |
+
}
|
app/code/local/Sttl/Prolog/etc/config.xml
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Sttl_Prolog>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Sttl_Prolog>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<events>
|
| 10 |
+
<checkout_type_onepage_save_order_after>
|
| 11 |
+
<observers>
|
| 12 |
+
<prolog_observer>
|
| 13 |
+
<type>singleton</type>
|
| 14 |
+
<class>prolog/observer</class>
|
| 15 |
+
<method>placeOrderPL</method>
|
| 16 |
+
</prolog_observer>
|
| 17 |
+
</observers>
|
| 18 |
+
</checkout_type_onepage_save_order_after>
|
| 19 |
+
</events>
|
| 20 |
+
</frontend>
|
| 21 |
+
<adminhtml>
|
| 22 |
+
<acl>
|
| 23 |
+
<resources>
|
| 24 |
+
<all>
|
| 25 |
+
<title>Allow Everything</title>
|
| 26 |
+
</all>
|
| 27 |
+
<admin>
|
| 28 |
+
<children>
|
| 29 |
+
<prolog>
|
| 30 |
+
<title>Prolog Module</title>
|
| 31 |
+
<sort_order>200</sort_order>
|
| 32 |
+
</prolog>
|
| 33 |
+
<system>
|
| 34 |
+
<children>
|
| 35 |
+
<config>
|
| 36 |
+
<children>
|
| 37 |
+
<prolog>
|
| 38 |
+
<title>Prolog Account</title>
|
| 39 |
+
</prolog>
|
| 40 |
+
</children>
|
| 41 |
+
</config>
|
| 42 |
+
</children>
|
| 43 |
+
</system>
|
| 44 |
+
</children>
|
| 45 |
+
</admin>
|
| 46 |
+
</resources>
|
| 47 |
+
</acl>
|
| 48 |
+
</adminhtml>
|
| 49 |
+
<global>
|
| 50 |
+
<models>
|
| 51 |
+
<prolog>
|
| 52 |
+
<class>Sttl_Prolog_Model</class>
|
| 53 |
+
<resourceModel>prolog_mysql4</resourceModel>
|
| 54 |
+
</prolog>
|
| 55 |
+
</models>
|
| 56 |
+
<resources>
|
| 57 |
+
<prolog_setup>
|
| 58 |
+
<setup>
|
| 59 |
+
<module>Sttl_Prolog</module>
|
| 60 |
+
<class>Mage_Eav_Model_Entity_Setup</class>
|
| 61 |
+
</setup>
|
| 62 |
+
<connection>
|
| 63 |
+
<use>core_setup</use>
|
| 64 |
+
</connection>
|
| 65 |
+
</prolog_setup>
|
| 66 |
+
<prolog_write>
|
| 67 |
+
<connection>
|
| 68 |
+
<use>core_write</use>
|
| 69 |
+
</connection>
|
| 70 |
+
</prolog_write>
|
| 71 |
+
<prolog_read>
|
| 72 |
+
<connection>
|
| 73 |
+
<use>core_read</use>
|
| 74 |
+
</connection>
|
| 75 |
+
</prolog_read>
|
| 76 |
+
</resources>
|
| 77 |
+
<helpers>
|
| 78 |
+
<prolog>
|
| 79 |
+
<class>Sttl_Prolog_Helper</class>
|
| 80 |
+
</prolog>
|
| 81 |
+
</helpers>
|
| 82 |
+
</global>
|
| 83 |
+
<crontab>
|
| 84 |
+
<jobs>
|
| 85 |
+
<prolog_inventory>
|
| 86 |
+
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
|
| 87 |
+
<run><model>prolog/observer::scheduledUpdateInventory</model></run>
|
| 88 |
+
</prolog_inventory>
|
| 89 |
+
<prolog_order>
|
| 90 |
+
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
|
| 91 |
+
<run><model>prolog/observer::scheduledUpdateOrder</model></run>
|
| 92 |
+
</prolog_order>
|
| 93 |
+
</jobs>
|
| 94 |
+
</crontab>
|
| 95 |
+
</config>
|
app/code/local/Sttl/Prolog/etc/system.xml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<sttl_tab translate="label" module="prolog">
|
| 5 |
+
<label>SILVER EXTENSIONS</label>
|
| 6 |
+
<sort_order>195</sort_order>
|
| 7 |
+
</sttl_tab>
|
| 8 |
+
</tabs>
|
| 9 |
+
<sections>
|
| 10 |
+
<prolog translate="label comment" module="prolog">
|
| 11 |
+
<tab>sttl_tab</tab>
|
| 12 |
+
<label>SILVER Prolog Sync</label>
|
| 13 |
+
<frontend_type>text</frontend_type>
|
| 14 |
+
<sort_order>1000</sort_order>
|
| 15 |
+
<show_in_default>1</show_in_default>
|
| 16 |
+
<show_in_website>1</show_in_website>
|
| 17 |
+
<show_in_store>1</show_in_store>
|
| 18 |
+
<groups>
|
| 19 |
+
<general translate="label comment" module="prolog">
|
| 20 |
+
<label>General Settings</label>
|
| 21 |
+
<frontend_type>text</frontend_type>
|
| 22 |
+
<sort_order>5</sort_order>
|
| 23 |
+
<show_in_default>1</show_in_default>
|
| 24 |
+
<show_in_website>1</show_in_website>
|
| 25 |
+
<show_in_store>1</show_in_store>
|
| 26 |
+
<fields>
|
| 27 |
+
<prolog_url translate="label">
|
| 28 |
+
<label>Prolog Url</label>
|
| 29 |
+
<frontend_type>text</frontend_type>
|
| 30 |
+
<sort_order>0</sort_order>
|
| 31 |
+
<show_in_default>1</show_in_default>
|
| 32 |
+
<show_in_website>1</show_in_website>
|
| 33 |
+
<show_in_store>1</show_in_store>
|
| 34 |
+
</prolog_url>
|
| 35 |
+
<prolog_username translate="label">
|
| 36 |
+
<label>Prolog Username</label>
|
| 37 |
+
<frontend_type>text</frontend_type>
|
| 38 |
+
<sort_order>1</sort_order>
|
| 39 |
+
<show_in_default>1</show_in_default>
|
| 40 |
+
<show_in_website>1</show_in_website>
|
| 41 |
+
<show_in_store>1</show_in_store>
|
| 42 |
+
</prolog_username>
|
| 43 |
+
<prolog_password translate="label">
|
| 44 |
+
<label>Prolog Password</label>
|
| 45 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 46 |
+
<frontend_type>obscure</frontend_type>
|
| 47 |
+
<sort_order>2</sort_order>
|
| 48 |
+
<show_in_default>1</show_in_default>
|
| 49 |
+
<show_in_website>1</show_in_website>
|
| 50 |
+
<show_in_store>1</show_in_store>
|
| 51 |
+
</prolog_password>
|
| 52 |
+
<prolog_customerid translate="label">
|
| 53 |
+
<label>Prolog Customer Id</label>
|
| 54 |
+
<frontend_type>text</frontend_type>
|
| 55 |
+
<sort_order>3</sort_order>
|
| 56 |
+
<show_in_default>1</show_in_default>
|
| 57 |
+
<show_in_website>1</show_in_website>
|
| 58 |
+
<show_in_store>1</show_in_store>
|
| 59 |
+
</prolog_customerid>
|
| 60 |
+
</fields>
|
| 61 |
+
</general>
|
| 62 |
+
</groups>
|
| 63 |
+
</prolog>
|
| 64 |
+
</sections>
|
| 65 |
+
</config>
|
app/code/local/Sttl/Prolog/sql/prolog_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
$conn = $installer->getConnection();
|
| 7 |
+
|
| 8 |
+
// add prolog product id to main product
|
| 9 |
+
|
| 10 |
+
$installer->addAttribute('catalog_product', 'prolog_product_id', array(
|
| 11 |
+
'group' => 'General',
|
| 12 |
+
'type' => 'varchar',
|
| 13 |
+
'backend' => '',
|
| 14 |
+
'frontend' => '',
|
| 15 |
+
'label' => 'Prolog Business Unit Product Id',
|
| 16 |
+
'input' => 'text',
|
| 17 |
+
'class' => '',
|
| 18 |
+
'source' => '',
|
| 19 |
+
'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
| 20 |
+
'visible' => true,
|
| 21 |
+
'required' => false,
|
| 22 |
+
'user_defined' => true,
|
| 23 |
+
'searchable' => false,
|
| 24 |
+
'filterable' => false,
|
| 25 |
+
'comparable' => false,
|
| 26 |
+
'visible_on_front' => false,
|
| 27 |
+
'unique' => false,
|
| 28 |
+
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
|
| 29 |
+
'is_configurable' => false,
|
| 30 |
+
'position' => 10,
|
| 31 |
+
'used_in_product_listing' => false
|
| 32 |
+
));
|
| 33 |
+
|
| 34 |
+
// add prolog line number to main product
|
| 35 |
+
|
| 36 |
+
$installer->addAttribute('catalog_product', 'prolog_line_number', array(
|
| 37 |
+
'group' => 'General',
|
| 38 |
+
'type' => 'varchar',
|
| 39 |
+
'backend' => '',
|
| 40 |
+
'frontend' => '',
|
| 41 |
+
'label' => 'Prolog Product#',
|
| 42 |
+
'input' => 'text',
|
| 43 |
+
'class' => '',
|
| 44 |
+
'source' => '',
|
| 45 |
+
'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
| 46 |
+
'visible' => true,
|
| 47 |
+
'required' => false,
|
| 48 |
+
'user_defined' => true,
|
| 49 |
+
'searchable' => false,
|
| 50 |
+
'filterable' => false,
|
| 51 |
+
'comparable' => false,
|
| 52 |
+
'visible_on_front' => false,
|
| 53 |
+
'unique' => false,
|
| 54 |
+
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
|
| 55 |
+
'is_configurable' => false,
|
| 56 |
+
'position' => 10,
|
| 57 |
+
'used_in_product_listing' => false
|
| 58 |
+
));
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
$installer->run("ALTER TABLE {$this->getTable('sales/order')}
|
| 62 |
+
ADD COLUMN `prolog_order_id` varchar(50) default NULL;");
|
| 63 |
+
|
| 64 |
+
$installer->run("ALTER TABLE {$this->getTable('sales/quote')}
|
| 65 |
+
ADD COLUMN `prolog_order_id` varchar(50) default NULL;");
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 69 |
+
|
| 70 |
+
$setup->addAttribute('order', 'prolog_order_id', array(
|
| 71 |
+
'label' => 'prolog_order_id',
|
| 72 |
+
'visible' => true,
|
| 73 |
+
'required' => false,
|
| 74 |
+
'position' => 1,
|
| 75 |
+
));
|
| 76 |
+
/*$setup->addAttribute('quote', 'prolog_order_id', array(
|
| 77 |
+
'label' => 'prolog_order_id',
|
| 78 |
+
'visible' => true,
|
| 79 |
+
'required' => false,
|
| 80 |
+
'position' => 1,
|
| 81 |
+
));*/
|
| 82 |
+
$installer->setConfigData('prolog/general/prolog_url', 'clientws.prolog3pl.com');
|
| 83 |
+
$installer->endSetup();
|
app/etc/modules/Sttl_Prolog.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Sttl_Prolog>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Sttl_Prolog>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Sttl_Prolog_18</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://www.silvertouch.com/MagentoExtensions/licence">STTL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Synchronize your inventory and order data with Prolog logistic software</summary>
|
| 10 |
+
<description>1. This extension facilitates Store Admin to synchronize Inventory from Prolog to Magento
|
| 11 |
+
2. Orders placed through Magento are transferred automatically to Prolog for processing.
|
| 12 |
+
3. Once orders have been processed in Prolog, the status will also automatically be synchronized with Magento.
|
| 13 |
+
4. Customers get the latest status for their orders from Magento Store front.
|
| 14 |
+
5. Cron jobs are required to be created so inventory and orders status can be updated automatically from Prolog to Magento.
|
| 15 |
+
6. Extension works with multi line orders.
|
| 16 |
+
7. Extension works with Configurable products.
|
| 17 |
+
8. This Extension work ONLY for shipping method- UPS Ground, UPS Next Day Air, UPS 2nd Day Air, USPS Priority Mail & USPS Priority Mail International
|
| 18 |
+
9. The extension does not generate Packing slip
|
| 19 |
+

|
| 20 |
+
IMPORTANT: Inventory cannot be Synchronized from Magento to Prolog.</description>
|
| 21 |
+
<notes>Synchronize your inventory and order data with Prolog logistic software</notes>
|
| 22 |
+
<authors><author><name>Silvertouch</name><user>silvertouch</user><email>magento@silvertouch.com</email></author></authors>
|
| 23 |
+
<date>2014-05-03</date>
|
| 24 |
+
<time>10:54:04</time>
|
| 25 |
+
<contents><target name="magelocal"><dir name="Sttl"><dir name="Prolog"><dir name="Helper"><file name="Data.php" hash="e6099ecb59df958803cf36413eedaab5"/></dir><dir name="Model"><file name="Observer.php" hash="97feb298951c741e89248d630dc55dd6"/></dir><dir name="etc"><file name="config.xml" hash="e7aade2a002f54120561405c755bd4f6"/><file name="system.xml" hash="b5c8602d7d73a4be1460c9520f98979c"/></dir><dir name="sql"><dir name="prolog_setup"><file name="mysql4-install-0.1.0.php" hash="d3e1f9007b3480508c07476cd70e4be3"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sttl_Prolog.xml" hash="400d2da11d9e8b6bcb961e82713fd04b"/></dir></target><target name="mage"><dir name="."><file name="SILVER_Prolog_Sync_User_Guide_Ver_2.0.pdf" hash="488592ff5d1bb540c3d3de28766009d3"/></dir></target></contents>
|
| 26 |
+
<compatible/>
|
| 27 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 28 |
+
</package>
|
