Version Notes
Initial Stable GSP release for Magento Connect.
Download this release
Release Info
Developer | Raymond Lai |
Extension | pitneybowes_gsp |
Version | 1.0.0 |
Comparing to | |
See all releases |
Code changes from version 0.9.0 to 1.0.0
- app/code/local/Pb/Pbgsp/Block/Adminhtml/Sales/Order/Invoice/Totals.php +25 -17
- app/code/local/Pb/Pbgsp/Block/Adminhtml/Sales/Order/Totals.php +26 -17
- app/code/local/Pb/Pbgsp/Block/Checkout/Shipping/Method/Available.php +76 -67
- app/code/local/Pb/Pbgsp/Block/Form.php +60 -77
- app/code/local/Pb/Pbgsp/Block/Sales/Order/Invoice/Totals.php +23 -14
- app/code/local/Pb/Pbgsp/Block/Sales/Order/Totals.php +56 -35
- app/code/local/Pb/Pbgsp/Model/Api.php +452 -443
- app/code/local/Pb/Pbgsp/Model/Carrier/ShippingMethod.php +304 -298
- app/code/local/Pb/Pbgsp/Model/Catalog/Category.php +145 -128
- app/code/local/Pb/Pbgsp/Model/Catalog/Cron.php +102 -95
- app/code/local/Pb/Pbgsp/Model/Catalog/File.php +728 -673
- app/code/local/Pb/Pbgsp/Model/Catalog/Product.php +204 -198
- app/code/local/Pb/Pbgsp/Model/Credentials.php +128 -114
- app/code/local/Pb/Pbgsp/Model/Creditmemo/Duty.php +37 -30
- app/code/local/Pb/Pbgsp/Model/Handlingoptions.php +17 -17
- app/code/local/Pb/Pbgsp/Model/Helper.php +18 -11
- app/code/local/Pb/Pbgsp/Model/Inboundparcel.php +17 -11
- app/code/local/Pb/Pbgsp/Model/Invoice/Duty.php +39 -31
- app/code/local/Pb/Pbgsp/Model/Messages.php +127 -121
- app/code/local/Pb/Pbgsp/Model/Mysql4/Inboundparcel.php +16 -9
- app/code/local/Pb/Pbgsp/Model/Mysql4/Inboundparcel/Collection.php +16 -8
- app/code/local/Pb/Pbgsp/Model/Mysql4/Ordernumber.php +16 -9
- app/code/local/Pb/Pbgsp/Model/Mysql4/Ordernumber/Collection.php +15 -8
- app/code/local/Pb/Pbgsp/Model/Mysql4/Variable.php +16 -9
- app/code/local/Pb/Pbgsp/Model/Mysql4/Variable/Collection.php +15 -8
- app/code/local/Pb/Pbgsp/Model/Observer.php +340 -318
- app/code/local/Pb/Pbgsp/Model/Ordernumber.php +17 -11
- app/code/local/Pb/Pbgsp/Model/Pdf/Tax.php +21 -14
- app/code/local/Pb/Pbgsp/Model/Quote/Duty.php +84 -76
- app/code/local/Pb/Pbgsp/Model/Resource/Mysql4/Setup.php +11 -10
- app/code/local/Pb/Pbgsp/Model/Sales/Order/Shipment.php +137 -136
- app/code/local/Pb/Pbgsp/Model/Util.php +29 -23
- app/code/local/Pb/Pbgsp/Model/Variable.php +17 -11
- app/code/local/Pb/Pbgsp/data/pb_pbgsp_setup/data-install-1.0.0.php +19 -0
- app/code/local/Pb/Pbgsp/etc/config.xml +509 -491
- app/code/local/Pb/Pbgsp/etc/system.xml +379 -361
- app/code/local/Pb/Pbgsp/sql/pbgsp_setup/mysql4-install-1.0.0.php +96 -60
- package.xml +5 -5
app/code/local/Pb/Pbgsp/Block/Adminhtml/Sales/Order/Invoice/Totals.php
CHANGED
@@ -1,17 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Block/Adminhtml/Sales/Order/Invoice/Totals.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
class Pb_Pbgsp_Block_Adminhtml_Sales_Order_Invoice_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals {
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
public function addTotal(Varien_Object $total, $after=null) {
|
15 |
+
|
16 |
+
$shipMethod = $this->getOrder()->getShippingMethod();
|
17 |
+
$taxAmount = $this->getOrder()->getTaxAmount();
|
18 |
+
$total = Pb_Pbgsp_Block_Sales_Order_Totals::addDuties($total,$after,$shipMethod,$taxAmount);
|
19 |
+
return parent::addTotal($total,$after);
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
?>
|
app/code/local/Pb/Pbgsp/Block/Adminhtml/Sales/Order/Totals.php
CHANGED
@@ -1,17 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Block/Adminhtml/Sales/Order/Totals.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Pb_Pbgsp_Block_Adminhtml_Sales_Order_Totals extends Mage_Adminhtml_Block_Sales_Order_Totals {
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
public function addTotal(Varien_Object $total, $after=null) {
|
16 |
+
|
17 |
+
$shipMethod = $this->getOrder()->getShippingMethod();
|
18 |
+
$taxAmount = $this->getOrder()->getTaxAmount();
|
19 |
+
$total = Pb_Pbgsp_Block_Sales_Order_Totals::addDuties($total,$after,$shipMethod,$taxAmount);
|
20 |
+
return parent::addTotal($total,$after);
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
?>
|
app/code/local/Pb/Pbgsp/Block/Checkout/Shipping/Method/Available.php
CHANGED
@@ -1,67 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Block/Checkout/Shipping/Method/Available.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Pb_Pbgsp_Block_Checkout_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available {
|
12 |
+
|
13 |
+
protected $errors;
|
14 |
+
protected $restrictions;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Internal constructor, that is called from real constructor
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
parent::_construct();
|
23 |
+
$this->errors = Mage::getSingleton("customer/session")->getPbRestrictions();
|
24 |
+
$cart = Mage::getModel('checkout/cart');
|
25 |
+
$items = array();
|
26 |
+
foreach($cart->getItems() as $item) {
|
27 |
+
$items[$item->getProductId()] = array("name" => $item->getName(), "url" => $item->getProduct()->getProductUrl());
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->restrictions = array();
|
31 |
+
if(count($this->errors) > 0){
|
32 |
+
foreach ($this->errors as $sku => $value) {
|
33 |
+
$processor = new Pb_Pbgsp_Model_Messages();
|
34 |
+
$message = $processor->getDisplayMessage($value["code"],$value["message"]);
|
35 |
+
|
36 |
+
$product_sku = $this->getSku($value['index']);
|
37 |
+
if($product_sku!=''):
|
38 |
+
$i_sku = Mage::getModel('catalog/product')->loadByAttribute('sku', $product_sku)->getName();
|
39 |
+
$i_msg = "$i_sku needs to be removed or modified to continue.";
|
40 |
+
$message = str_replace("{IDENTIFY SKU}", $i_msg, $message);
|
41 |
+
else:
|
42 |
+
$message = str_replace("{IDENTIFY SKU}", $product_sku, $message);
|
43 |
+
endif;
|
44 |
+
array_push($this->restrictions,array("name" => $items[$sku]["name"],
|
45 |
+
"message" => $message,
|
46 |
+
"sku" => $sku,
|
47 |
+
"url" => $items[$sku]["url"]));
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
private function getSku($index){
|
54 |
+
if($index == null) return '';
|
55 |
+
$items = Mage::getSingleton('checkout/cart')->getItems();
|
56 |
+
$i = 0;
|
57 |
+
foreach ($items as $item):
|
58 |
+
if($i++==$index):
|
59 |
+
return $item->getSku();
|
60 |
+
endif;
|
61 |
+
endforeach;
|
62 |
+
return '';
|
63 |
+
}
|
64 |
+
public function displayRestrictions() {
|
65 |
+
if(isset($this->errors)) {
|
66 |
+
return true;
|
67 |
+
} else {
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getRestrictions() {
|
73 |
+
return $this->restrictions;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
?>
|
app/code/local/Pb/Pbgsp/Block/Form.php
CHANGED
@@ -1,77 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
;
|
59 |
-
|
60 |
-
|
61 |
-
Mage::helper('paypal')->__('You will be redirected to PayPal website when you place an order.')
|
62 |
-
)
|
63 |
-
->setMethodTitle('') // Output PayPal mark, omit title
|
64 |
-
->setMethodLabelAfterHtml($mark->toHtml())
|
65 |
-
;
|
66 |
-
return parent::_construct();
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Payment method code getter
|
71 |
-
* @return string
|
72 |
-
*/
|
73 |
-
public function getMethodCode()
|
74 |
-
{
|
75 |
-
return $this->_methodCode;
|
76 |
-
}
|
77 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Block/Form.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* PayPal Standard payment "form"
|
12 |
+
*/
|
13 |
+
class Pb_Pbgsp_Block_Form extends Mage_Payment_Block_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Payment method code
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $_methodCode = Mage_Paypal_Model_Config::METHOD_WPS;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Config model instance
|
23 |
+
*
|
24 |
+
* @var Mage_Paypal_Model_Config
|
25 |
+
*/
|
26 |
+
protected $_config;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Set template and redirect message
|
30 |
+
*/
|
31 |
+
protected function _construct()
|
32 |
+
{
|
33 |
+
Pb_Pbgsp_Model_Util::log("PBGSP form construct");
|
34 |
+
$this->_config = Mage::getModel('paypal/config')->setMethod($this->getMethodCode());
|
35 |
+
$locale = Mage::app()->getLocale();
|
36 |
+
$mark = Mage::getConfig()->getBlockClassName('core/template');
|
37 |
+
$mark = new $mark;
|
38 |
+
$mark->setTemplate('paypal/payment/mark.phtml')
|
39 |
+
->setPaymentAcceptanceMarkHref($this->_config->getPaymentMarkWhatIsPaypalUrl($locale))
|
40 |
+
->setPaymentAcceptanceMarkSrc($this->_config->getPaymentMarkImageUrl($locale->getLocaleCode()))
|
41 |
+
; // known issue: code above will render only static mark image
|
42 |
+
$this->setTemplate('paypal/payment/redirect.phtml')
|
43 |
+
->setRedirectMessage(
|
44 |
+
Mage::helper('paypal')->__('You will be redirected to PayPal website when you place an order.')
|
45 |
+
)
|
46 |
+
->setMethodTitle('') // Output PayPal mark, omit title
|
47 |
+
->setMethodLabelAfterHtml($mark->toHtml())
|
48 |
+
;
|
49 |
+
return parent::_construct();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Payment method code getter
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getMethodCode()
|
57 |
+
{
|
58 |
+
return $this->_methodCode;
|
59 |
+
}
|
60 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Pb/Pbgsp/Block/Sales/Order/Invoice/Totals.php
CHANGED
@@ -1,14 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Block/Sales/Order/Invoice/Totals.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Pb_Pbgsp_Block_Sales_Order_Invoice_Totals extends Mage_Sales_Block_Order_Invoice_Totals {
|
12 |
+
|
13 |
+
public function addTotal(Varien_Object $total, $after=null) {
|
14 |
+
|
15 |
+
$shipMethod = $this->getOrder()->getShippingMethod();
|
16 |
+
$taxAmount = $this->getOrder()->getTaxAmount();
|
17 |
+
$total = Pb_Pbgsp_Block_Sales_Order_Totals::addDuties($total,$after,$shipMethod,$taxAmount);
|
18 |
+
return parent::addTotal($total,$after);
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
23 |
+
?>
|
app/code/local/Pb/Pbgsp/Block/Sales/Order/Totals.php
CHANGED
@@ -1,35 +1,56 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Block/Sales/Order/Totals.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals {
|
10 |
+
|
11 |
+
public static function addDuties(Varien_Object $total, $after, $shipMethod, $taxAmount) {
|
12 |
+
|
13 |
+
// TODO: This is kind of ugly. I am replacing the tax template with a tax entry...
|
14 |
+
// By default this sets the block_name without parameters which loads the appropriate
|
15 |
+
// template. Need to see if this breaks anything.
|
16 |
+
|
17 |
+
$len = strlen("pbgsp_");
|
18 |
+
if (strlen($shipMethod) > $len && substr($shipMethod,0,$len) == "pbgsp_") {
|
19 |
+
if ($total->getCode() == "tax") {
|
20 |
+
$total = new Varien_Object(array(
|
21 |
+
'code' => 'tax',
|
22 |
+
'value' => $taxAmount,
|
23 |
+
'label' => 'Importation Charges'
|
24 |
+
));
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $total;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function addTotal(Varien_Object $total, $after=null) {
|
32 |
+
|
33 |
+
$shipMethod = $this->getOrder()->getShippingMethod();
|
34 |
+
$taxAmount = $this->getOrder()->getTaxAmount();
|
35 |
+
Pb_Pbgsp_Model_Util::log("Add Duty & Taxes at Order");
|
36 |
+
$total = self::addDuties($total,$after,$shipMethod,$taxAmount);
|
37 |
+
return parent::addTotal($total,$after);
|
38 |
+
|
39 |
+
}
|
40 |
+
public function getTotals($area=null)
|
41 |
+
{
|
42 |
+
$totals = parent::getTotals($area);
|
43 |
+
$shipMethod = $this->getOrder()->getShippingMethod();
|
44 |
+
$len = strlen("pbgsp_");
|
45 |
+
if (strlen($shipMethod) > $len && substr($shipMethod,0,$len) == "pbgsp_") {
|
46 |
+
Pb_Pbgsp_Model_Util::log("getTotals PB shipmethod");
|
47 |
+
if(array_key_exists("shipping",$totals)) {
|
48 |
+
$shipping = $totals['shipping'];
|
49 |
+
$shipping->setLabel('Transportation Charges');
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return $totals;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Api.php
CHANGED
@@ -1,443 +1,452 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$
|
47 |
-
|
48 |
-
curl_setopt($curl,
|
49 |
-
curl_setopt($curl,
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
curl_setopt($curl,
|
89 |
-
$
|
90 |
-
curl_setopt($curl,
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
//
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
$
|
99 |
-
$
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
$
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$ipaddress = $_SERVER['
|
123 |
-
else if (array_key_exists('
|
124 |
-
$ipaddress = $_SERVER['
|
125 |
-
else
|
126 |
-
$ipaddress = '
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
$
|
140 |
-
$
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
if(
|
198 |
-
$email =
|
199 |
-
|
200 |
-
|
201 |
-
'
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
'
|
213 |
-
'
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
'
|
225 |
-
'
|
226 |
-
'
|
227 |
-
'
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
'
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
'
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
'
|
293 |
-
'
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
Pb_Pbgsp_Model_Util::log(
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
Pb_Pbgsp_Model_Util::log(
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
$
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
'
|
414 |
-
'
|
415 |
-
'
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
Pb_Pbgsp_Model_Util::log(
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
}
|
442 |
-
|
443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Api.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Api
|
10 |
+
{
|
11 |
+
|
12 |
+
|
13 |
+
public static function CallAPI($method, $url, $data = false,$isSecondCall=false)
|
14 |
+
{
|
15 |
+
$curl = curl_init();
|
16 |
+
$headers = array();
|
17 |
+
$dataString = '';
|
18 |
+
switch ($method)
|
19 |
+
{
|
20 |
+
case "POST":
|
21 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
22 |
+
|
23 |
+
if ($data) {
|
24 |
+
$dataString = json_encode($data);
|
25 |
+
Pb_Pbgsp_Model_Util::log("Data to pass to get quote $dataString");
|
26 |
+
$headers[] = 'Content-Type: application/json';
|
27 |
+
$headers[] = 'Content-Length: ' . strlen($dataString);
|
28 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString);
|
29 |
+
}
|
30 |
+
|
31 |
+
break;
|
32 |
+
case "PUT":
|
33 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
|
34 |
+
if ($data) {
|
35 |
+
$dataString = json_encode($data);
|
36 |
+
Pb_Pbgsp_Model_Util::log("Data to pass to PUT $dataString");
|
37 |
+
$headers[] = 'Content-Type: application/json';
|
38 |
+
$headers[] = 'Content-Length: ' . strlen($dataString);
|
39 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString);
|
40 |
+
}
|
41 |
+
break;
|
42 |
+
default:
|
43 |
+
if ($data)
|
44 |
+
$url = sprintf("%s?%s", $url, http_build_query($data));
|
45 |
+
}
|
46 |
+
if($dataString != '')
|
47 |
+
Pb_Pbgsp_Model_Util::log("Passing $dataString to $url");
|
48 |
+
curl_setopt($curl, CURLOPT_URL, $url);
|
49 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
50 |
+
$token = self::getToken();
|
51 |
+
if(!$token)
|
52 |
+
throw new Exception("Could not get authentication token");
|
53 |
+
$headers[] = 'Cookie: '. $token['cookie'][0];
|
54 |
+
$headers[] = 'Authorization: '.$token['token_type'].' '.$token['access_token'];
|
55 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers );
|
56 |
+
curl_setopt($curl, CURLOPT_VERBOSE, 1); // turn verbose on
|
57 |
+
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
58 |
+
$result = curl_exec($curl);
|
59 |
+
$info = curl_getinfo($curl);
|
60 |
+
//Pb_Pbgsp_Model_Util::log($info);
|
61 |
+
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
62 |
+
if($status != 200 && $status != 201 && $status != 400)
|
63 |
+
{
|
64 |
+
Pb_Pbgsp_Model_Util::log("Http Status: $status");
|
65 |
+
Pb_Pbgsp_Model_Util::log("body : $result");
|
66 |
+
if($status == 401 && !$isSecondCall) {
|
67 |
+
//token expired regenerat it
|
68 |
+
Pb_Pbgsp_Model_Util::log("Regenerating token");
|
69 |
+
Mage::getSingleton("customer/session")->setPbToken(false);
|
70 |
+
self::CallAPI($method,$url,$data,true);
|
71 |
+
}
|
72 |
+
else {
|
73 |
+
throw new Exception($result,$status);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
curl_close($curl);
|
77 |
+
return $result;
|
78 |
+
}
|
79 |
+
|
80 |
+
public static function getToken() {
|
81 |
+
$token = Mage::getSingleton("customer/session")->getPbToken();
|
82 |
+
if(!$token) {
|
83 |
+
$curl = curl_init();
|
84 |
+
curl_setopt($curl, CURLOPT_POST, 1);
|
85 |
+
$username = trim(Pb_Pbgsp_Model_Credentials::getUsername());
|
86 |
+
$password = trim(Pb_Pbgsp_Model_Credentials::getPassword());
|
87 |
+
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
88 |
+
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
|
89 |
+
curl_setopt($curl, CURLINFO_HEADER_OUT, 1); // capture the header info
|
90 |
+
curl_setopt($curl, CURLOPT_VERBOSE, 1); // turn verbose on
|
91 |
+
// get headers too with this line
|
92 |
+
curl_setopt($curl, CURLOPT_HEADER, 1);
|
93 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
|
94 |
+
// Will return the response, if false it print the response
|
95 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
96 |
+
$url = Pb_Pbgsp_Model_Credentials::getAuthorizationUrl();
|
97 |
+
curl_setopt($curl, CURLOPT_URL, $url);
|
98 |
+
$response = curl_exec($curl);
|
99 |
+
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
100 |
+
$header = substr($response, 0, $header_size);
|
101 |
+
// get cookies
|
102 |
+
$cookies = array();
|
103 |
+
preg_match_all('/Set-Cookie:(?<cookie>\s{0,}.*)$/im', $header, $cookies);
|
104 |
+
$body = substr($response, $header_size);
|
105 |
+
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
106 |
+
$info = curl_getinfo($curl);
|
107 |
+
if($status != 200) {
|
108 |
+
Pb_Pbgsp_Model_Util::log("Error getting authentication token.". $response);
|
109 |
+
throw new Exception("Could not get authentication token",$status);
|
110 |
+
}
|
111 |
+
curl_close($curl);
|
112 |
+
$token = json_decode($body,true);
|
113 |
+
$token['cookie'] = $cookies['cookie'];
|
114 |
+
Mage::getSingleton("customer/session")->setPbToken($token);
|
115 |
+
}
|
116 |
+
return $token;
|
117 |
+
}
|
118 |
+
|
119 |
+
protected static function getClientIP() {
|
120 |
+
$ipaddress = '';
|
121 |
+
if (array_key_exists('HTTP_CLIENT_IP',$_SERVER))
|
122 |
+
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
|
123 |
+
else if (array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER))
|
124 |
+
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
125 |
+
else if (array_key_exists('HTTP_X_FORWARDED',$_SERVER))
|
126 |
+
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
|
127 |
+
else if (array_key_exists('HTTP_FORWARDED_FOR',$_SERVER))
|
128 |
+
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
|
129 |
+
else if (array_key_exists('HTTP_FORWARDED',$_SERVER))
|
130 |
+
$ipaddress = $_SERVER['HTTP_FORWARDED'];
|
131 |
+
else if (array_key_exists('REMOTE_ADDR',$_SERVER))
|
132 |
+
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
133 |
+
else
|
134 |
+
$ipaddress = '0.0.0.0';
|
135 |
+
return $ipaddress;
|
136 |
+
}
|
137 |
+
protected static function makeBasket($products, $address,$method='STANDARD')
|
138 |
+
{
|
139 |
+
$basketLines = array();
|
140 |
+
$totalProducts = 0;
|
141 |
+
/* BigPixel code for adding handling fee, 6/6/2012*/
|
142 |
+
|
143 |
+
|
144 |
+
$handlingFee = Pb_Pbgsp_Model_Credentials::getHandlingFee();
|
145 |
+
|
146 |
+
$handlingoption = Pb_Pbgsp_Model_Credentials::getHandlingOption();
|
147 |
+
$domesticShippingFee = Pb_Pbgsp_Model_Credentials::getDomesticShippingFee();
|
148 |
+
$domesticShippingOption = Pb_Pbgsp_Model_Credentials::getDomesticShippingOption();
|
149 |
+
|
150 |
+
$deliveryAdjMinDays = Pb_Pbgsp_Model_Credentials::getDeliveryAdjustmentMinDays();
|
151 |
+
$deliveryAdjMixDays = Pb_Pbgsp_Model_Credentials::getDeliveryAdjustmentMaxDays();
|
152 |
+
|
153 |
+
foreach ($products as $product) {
|
154 |
+
if ((!$product->getParentItem() && $product->getRealProductType()
|
155 |
+
!= Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) ||
|
156 |
+
($product->getParentItem() && $product->isChildrenCalculated())) {
|
157 |
+
/* @var Mage_Sales_Model_Order_Item $product */
|
158 |
+
|
159 |
+
$totalProducts += $product->getQty();
|
160 |
+
|
161 |
+
// Pb_Pbgsp_Model_Util::log('discount amount '. $product->getDiscountAmount());
|
162 |
+
// Pb_Pbgsp_Model_Util::log('Price '. $product->getPrice());
|
163 |
+
|
164 |
+
$price = $product->getPrice() - $product->getDiscountAmount();//$price - ($product->getDiscountAmount() * $product->getQty());
|
165 |
+
if($price == 0)
|
166 |
+
$price = 0.01; //set this price so that quote could be retrieved.
|
167 |
+
array_push($basketLines, array(
|
168 |
+
"lineId" => $product->getSku(),
|
169 |
+
"commodity" => array('merchantComRefId' => $product->getSku()),
|
170 |
+
"unitPrice" => array('price' => array('value' => $price)),
|
171 |
+
"quantity" => intval($product->getQty())
|
172 |
+
|
173 |
+
)
|
174 |
+
);
|
175 |
+
}
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
if(isset($handlingoption) && $handlingoption == "2") { //apply as per item
|
180 |
+
$handlingFee = $handlingFee * $totalProducts;
|
181 |
+
}
|
182 |
+
if(isset($domesticShippingOption) && $domesticShippingOption == "2") { //apply as per item
|
183 |
+
$domesticShippingFee = $domesticShippingFee * $totalProducts;
|
184 |
+
}
|
185 |
+
$toHubTransportations = array(
|
186 |
+
array(
|
187 |
+
'merchantShippingIdentifier' => 'PB',
|
188 |
+
'speed' => $method,
|
189 |
+
'shipping' => array('value' => $handlingFee),
|
190 |
+
'handling' => array('value' => $domesticShippingFee),
|
191 |
+
'total' => array('value' => $handlingFee + $domesticShippingFee),
|
192 |
+
'minDays' => $deliveryAdjMinDays,
|
193 |
+
'maxDays' => $deliveryAdjMixDays
|
194 |
+
)
|
195 |
+
);
|
196 |
+
|
197 |
+
if (strlen($address->getEmail()) > 0) {
|
198 |
+
$email = $address->getEmail();
|
199 |
+
}
|
200 |
+
elseif (strlen(Mage::getSingleton('checkout/cart')->getQuote()->getBillingAddress()->getEmail()) > 0) {
|
201 |
+
$email = Mage::getSingleton('checkout/cart')->getQuote()->getBillingAddress()->getEmail();
|
202 |
+
}
|
203 |
+
else {
|
204 |
+
$email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
205 |
+
}
|
206 |
+
if(!$email)
|
207 |
+
$email = "kamranattari@gmail.com";
|
208 |
+
|
209 |
+
$consignee = array(
|
210 |
+
'familyName' => $address->getLastname(),
|
211 |
+
'givenName' => $address->getFirstname(),
|
212 |
+
'email' => $email,
|
213 |
+
'phoneNumbers' => array(
|
214 |
+
array(
|
215 |
+
'number' => $address->getTelephone(),
|
216 |
+
'type' => 'other'
|
217 |
+
)
|
218 |
+
)
|
219 |
+
);
|
220 |
+
$shippingAddress = array(
|
221 |
+
'street1' => $address->getStreet1(),
|
222 |
+
'street2' => $address->getStreet2(),
|
223 |
+
|
224 |
+
'city' => $address->getCity(),
|
225 |
+
'countyOrRegion' => '',
|
226 |
+
'provinceOrState' => $address->getRegionCode(),
|
227 |
+
'country' => $address->getCountryId(),
|
228 |
+
'postalOrZipCode' => $address->getPostcode()
|
229 |
+
);
|
230 |
+
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
231 |
+
$basket = array(
|
232 |
+
'merchantId' => Pb_Pbgsp_Model_Credentials::getMerchantCode(),
|
233 |
+
'purchaserIPAddress' => self::getClientIP(),
|
234 |
+
'transactionId' => mt_rand(100000, 999999),
|
235 |
+
'quoteCurrency' => $currency,
|
236 |
+
'basketLines' => $basketLines
|
237 |
+
,
|
238 |
+
'toHubTransportations' => $toHubTransportations,
|
239 |
+
'consignee' => $consignee
|
240 |
+
,
|
241 |
+
'shippingAddress' => $shippingAddress
|
242 |
+
|
243 |
+
);
|
244 |
+
|
245 |
+
|
246 |
+
return $basket;
|
247 |
+
|
248 |
+
}
|
249 |
+
|
250 |
+
public static function generateInboundParcelNumber($shipment,$items,$mageOrderNumber,$cpOrderNumber) {
|
251 |
+
$inboundParcelCommodities = array();
|
252 |
+
/* @var Mage_Sales_Model_Order_Shipment $shipment*/
|
253 |
+
$totalWeight = 0;
|
254 |
+
foreach($shipment->getItemsCollection() as $item) {
|
255 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$item->getSku());
|
256 |
+
$commodity = array(
|
257 |
+
'merchantComRefId' => $item->getSku(),
|
258 |
+
|
259 |
+
'quantity' => intval($item->getQty()),
|
260 |
+
'coo' => $product->getCountryOfManufacture(),
|
261 |
+
'size' => array(
|
262 |
+
'weight' => $product->getWeight(),
|
263 |
+
'weightUnit' => 'lb'
|
264 |
+
)
|
265 |
+
|
266 |
+
);
|
267 |
+
array_push($inboundParcelCommodities,$commodity);
|
268 |
+
$totalWeight += $product->getWeight();
|
269 |
+
}
|
270 |
+
$tracks = array();
|
271 |
+
|
272 |
+
foreach($shipment->getTracksCollection() as $track) {
|
273 |
+
$tracks[] = $track;
|
274 |
+
}
|
275 |
+
$requestBody = array(
|
276 |
+
'merchantOrderNumber' => $cpOrderNumber,
|
277 |
+
'parcelIdentificationNumber' => $tracks[0]->getNumber(),
|
278 |
+
'inboundParcelCommodities' => $inboundParcelCommodities,
|
279 |
+
'shipper' => $tracks[0]->getTitle(),
|
280 |
+
'shipperService' => 'EXPRESS',
|
281 |
+
'shipperTrackingNumber'=> $tracks[0]->getNumber(),
|
282 |
+
'dcId' => '211113442',
|
283 |
+
'dcAddress' => array(
|
284 |
+
'street1' => '200 Main Street',
|
285 |
+
'city' => 'PHOENIX',
|
286 |
+
'provinceOrState' => 'AZ',
|
287 |
+
'country' => 'US',
|
288 |
+
'postalOrZipCode' => '85123'
|
289 |
+
),
|
290 |
+
'returnDetails' => array(
|
291 |
+
'returnAddress' => array(
|
292 |
+
'street1' => '200 Main Street',
|
293 |
+
'city' => 'PHOENIX',
|
294 |
+
'provinceOrState' => 'AZ',
|
295 |
+
'country' => 'US',
|
296 |
+
'postalOrZipCode' => '85123'
|
297 |
+
),
|
298 |
+
'contactInformation' => array(
|
299 |
+
'familyName' => 'Smith',
|
300 |
+
'givenName' => 'Mary',
|
301 |
+
'email' => 'retailer_email@test.com',
|
302 |
+
'phoneNumbers' => array(
|
303 |
+
array(
|
304 |
+
'number' => '12123232',
|
305 |
+
'type' => 'home'
|
306 |
+
)
|
307 |
+
)
|
308 |
+
)
|
309 |
+
),
|
310 |
+
'size' => array(
|
311 |
+
'weight' => $totalWeight,
|
312 |
+
'weightUnit' => 'LB'
|
313 |
+
)
|
314 |
+
);
|
315 |
+
$url = Pb_Pbgsp_Model_Credentials::getOrderMgmtAPIUrl().'/orders/'.
|
316 |
+
$cpOrderNumber.'/inbound-parcels';
|
317 |
+
$response = self::CallAPI('POST',$url,$requestBody);
|
318 |
+
$parcelResponse = json_decode($response,true);
|
319 |
+
Pb_Pbgsp_Model_Util::log('Response of inbound-parcels');
|
320 |
+
Pb_Pbgsp_Model_Util::log($parcelResponse);
|
321 |
+
return $parcelResponse;
|
322 |
+
|
323 |
+
}
|
324 |
+
public static function getCheckoutUrl($method) {
|
325 |
+
return Pb_Pbgsp_Model_Credentials::getCheckoutUrl().'/'.$method;
|
326 |
+
}
|
327 |
+
public static function getQuote($products,$address)
|
328 |
+
{
|
329 |
+
|
330 |
+
Pb_Pbgsp_Model_Util::log('Getting quote from clearpath');
|
331 |
+
$basket = Pb_Pbgsp_Model_Api::makeBasket($products, $address);
|
332 |
+
|
333 |
+
$url = self::getCheckoutUrl('quotes');
|
334 |
+
$response = self::CallAPI('POST',$url,$basket);
|
335 |
+
|
336 |
+
|
337 |
+
$quoteSet = json_decode($response,true);
|
338 |
+
Pb_Pbgsp_Model_Util::log('response of quotes ');
|
339 |
+
Pb_Pbgsp_Model_Util::log($quoteSet);
|
340 |
+
return $quoteSet;
|
341 |
+
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
|
346 |
+
public static function createOrder($products,$method,$address) {
|
347 |
+
|
348 |
+
|
349 |
+
try {
|
350 |
+
Pb_Pbgsp_Model_Util::log('Creating order in clearpath');
|
351 |
+
$basket = Pb_Pbgsp_Model_Api::makeBasket($products, $address,$method);
|
352 |
+
|
353 |
+
$url = self::getCheckoutUrl('orders');
|
354 |
+
$response = self::CallAPI('POST',$url,$basket);
|
355 |
+
Pb_Pbgsp_Model_Util::log("response of create order ". $response );
|
356 |
+
|
357 |
+
$orderSet = json_decode($response,true);
|
358 |
+
Pb_Pbgsp_Model_Util::log('response of orders ');
|
359 |
+
Pb_Pbgsp_Model_Util::log($orderSet);
|
360 |
+
foreach($orderSet['order'] as $order) {
|
361 |
+
$tax = 0;
|
362 |
+
if(!self::logIfError($order,'createOrder')) {
|
363 |
+
// if(array_key_exists('order',$order)) {
|
364 |
+
// $quote = $order['order'];
|
365 |
+
// $tax = $quote['totalImportation']['total']['value'];
|
366 |
+
// }
|
367 |
+
|
368 |
+
return $order;//array("orderNumber" => $order['orderId'], "tax" => $tax);
|
369 |
+
}
|
370 |
+
else {
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
|
374 |
+
}
|
375 |
+
return $orderSet;
|
376 |
+
}
|
377 |
+
catch(Exception $e) {
|
378 |
+
Pb_Pbgsp_Model_Util::log("Received unexpected exception from Pb while calling createOrder.");
|
379 |
+
Pb_Pbgsp_Model_Util::logException($e);
|
380 |
+
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
private static function logIfError($object,$action=null) {
|
387 |
+
if(array_key_exists('errors',$object) && count($object['errors']) > 0) {
|
388 |
+
$processor = new Pb_Pbgsp_Model_Messages();
|
389 |
+
foreach($object['errors'] as $error) {
|
390 |
+
$message = '';
|
391 |
+
if(array_key_exists('message',$error))
|
392 |
+
$message = $error['message'];
|
393 |
+
$message = $processor->getDisplayMessage($error["error"],$message);//.$sku;
|
394 |
+
if($action)
|
395 |
+
Pb_Pbgsp_Model_Util::log("Error received in action $action");
|
396 |
+
Pb_Pbgsp_Model_Util::log($message);
|
397 |
+
}
|
398 |
+
return true;
|
399 |
+
}
|
400 |
+
return false;
|
401 |
+
}
|
402 |
+
public static function confirmOrder($orderNumber,$order) {
|
403 |
+
/* @var Mage_Sales_Model_Order $order */
|
404 |
+
|
405 |
+
|
406 |
+
|
407 |
+
$billingAddress = $order->getBillingAddress();
|
408 |
+
$confirm = array(
|
409 |
+
'transactionId' => $order->getRealOrderId(),
|
410 |
+
'merchantOrderNumber' => $order->getRealOrderId(),
|
411 |
+
'purchaser' => array(
|
412 |
+
'familyName' => $order->getCustomerLastname(),
|
413 |
+
'givenName' => $order->getCustomerFirstname(),
|
414 |
+
'email' => $order->getCustomerEmail(),
|
415 |
+
'phoneNumbers' => array(
|
416 |
+
array(
|
417 |
+
'number' => $billingAddress->getTelephone(),
|
418 |
+
'type' => 'other'
|
419 |
+
)
|
420 |
+
)),
|
421 |
+
'purchaserBillingAddress' => array(
|
422 |
+
'street1' => $billingAddress->getStreet1(),
|
423 |
+
'street2' => '',
|
424 |
+
'city' => $billingAddress->getCity(),
|
425 |
+
'countyOrRegion' => '',
|
426 |
+
'provinceOrState' => $billingAddress->getRegionCode(),
|
427 |
+
'country' => $billingAddress->getCountryId(),
|
428 |
+
'postalOrZipCode' => $billingAddress->getPostcode(),
|
429 |
+
)
|
430 |
+
|
431 |
+
);
|
432 |
+
try {
|
433 |
+
$url = self::getCheckoutUrl("orders/$orderNumber/confirm");
|
434 |
+
$response = self::CallAPI('PUT',$url,$confirm);
|
435 |
+
Pb_Pbgsp_Model_Util::log("Passing $url ");
|
436 |
+
Pb_Pbgsp_Model_Util::log($confirm);
|
437 |
+
$confirmResponse = json_decode($response,true);
|
438 |
+
if(self::logIfError($confirmResponse,'confirmOrder'))//there is an error
|
439 |
+
return false;
|
440 |
+
return true;
|
441 |
+
}
|
442 |
+
catch(Exception $e) {
|
443 |
+
Pb_Pbgsp_Model_Util::log("Received unexpected exception from Pb while calling confirming order.");
|
444 |
+
Pb_Pbgsp_Model_Util::log($e->getMessage(). ' '. $e->getTraceAsString());
|
445 |
+
return false;
|
446 |
+
}
|
447 |
+
return true;
|
448 |
+
}
|
449 |
+
|
450 |
+
}
|
451 |
+
|
452 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Carrier/ShippingMethod.php
CHANGED
@@ -1,298 +1,304 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
*
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
$
|
43 |
-
|
44 |
-
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
$
|
107 |
-
$
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
$
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
$
|
130 |
-
$method->
|
131 |
-
|
132 |
-
// record
|
133 |
-
$
|
134 |
-
$method->
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
$
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
// skip if
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
$address->
|
201 |
-
$address->
|
202 |
-
$address->
|
203 |
-
$address->
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$address->
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
$
|
241 |
-
$
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
$
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Model/Carrier/ShippingMethod.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
class Pb_Pbgsp_Model_Carrier_ShippingMethod extends Mage_Shipping_Model_Carrier_Abstract
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* unique internal shipping method identifier
|
14 |
+
*
|
15 |
+
* @var string [a-z0-9_]
|
16 |
+
*/
|
17 |
+
protected $_code = 'pbgsp';
|
18 |
+
|
19 |
+
public function getConfigData($field) {
|
20 |
+
/* BigPixel 3/25/2012. hide errors for not applicable countries */
|
21 |
+
|
22 |
+
return parent::getConfigData($field);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param $result
|
27 |
+
* @param $errors
|
28 |
+
* Adds custom error messages to $result
|
29 |
+
*/
|
30 |
+
public function displayErrors($result,$quote) {
|
31 |
+
$processor = new Pb_Pbgsp_Model_Messages();
|
32 |
+
$isUnitErrorAdded = false;
|
33 |
+
|
34 |
+
foreach($quote['quoteLines'] as $quoteLine) {
|
35 |
+
if(array_key_exists('unitErrors',$quoteLine)) {
|
36 |
+
foreach($quoteLine['unitErrors'] as $error) {
|
37 |
+
$message = '';
|
38 |
+
if(array_key_exists('message',$error))
|
39 |
+
$message = $error['message'];
|
40 |
+
$message = $processor->getDisplayMessage($error["error"],$message);//.$sku;
|
41 |
+
$sku = $quoteLine['merchantComRefId'];
|
42 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
|
43 |
+
$message = $message . " Please remove ". $product->getName() . " from cart.";
|
44 |
+
$this->_addError($result,$message);
|
45 |
+
$isUnitErrorAdded = true;
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
if(!$isUnitErrorAdded) {
|
52 |
+
foreach($quote['errors'] as $error) {
|
53 |
+
$message = '';
|
54 |
+
if(array_key_exists('message',$error))
|
55 |
+
$message = $error['message'];
|
56 |
+
$message = $processor->getDisplayMessage($error["error"],$message);//.$sku;
|
57 |
+
$this->_addError($result,$message);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
private function _addError($result,$message) {
|
64 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
65 |
+
$error->setCarrier('pbgsp');
|
66 |
+
$error->setCarrierTitle("Pitney Bowes");
|
67 |
+
$error->setErrorMessage($message);
|
68 |
+
$result->append($error);
|
69 |
+
Pb_Pbgsp_Model_Util::log("Added error $message");
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $index
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
private function getSku($index){
|
77 |
+
$items = Mage::getSingleton('checkout/cart')->getItems();
|
78 |
+
$i = 0;
|
79 |
+
foreach ($items as $item):
|
80 |
+
if($i++==$index):
|
81 |
+
return $item->getSku();
|
82 |
+
endif;
|
83 |
+
endforeach;
|
84 |
+
return '';
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param $index
|
89 |
+
* @return mixed
|
90 |
+
*/
|
91 |
+
public function getRestrictId($index){
|
92 |
+
$sku = $this->getSku($index);
|
93 |
+
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
|
94 |
+
return $id;
|
95 |
+
}
|
96 |
+
|
97 |
+
private function _getShipMethodFromQuote($quote,$items) {
|
98 |
+
$handlingFee = Pb_Pbgsp_Model_Credentials::getHandlingFee();
|
99 |
+
|
100 |
+
$handlingoption = Pb_Pbgsp_Model_Credentials::getHandlingOption();
|
101 |
+
$domesticShippingFee = Pb_Pbgsp_Model_Credentials::getDomesticShippingFee();
|
102 |
+
$domesticShippingOption = Pb_Pbgsp_Model_Credentials::getDomesticShippingOption();
|
103 |
+
|
104 |
+
$deliveryAdjMinDays = Pb_Pbgsp_Model_Credentials::getDeliveryAdjustmentMinDays();
|
105 |
+
$deliveryAdjMixDays = Pb_Pbgsp_Model_Credentials::getDeliveryAdjustmentMaxDays();
|
106 |
+
$totalQty = 0;
|
107 |
+
foreach($items as $item) {
|
108 |
+
$totalQty += $item->getQty();
|
109 |
+
}
|
110 |
+
if(isset($handlingoption) && $handlingoption == "2") { //apply as per item
|
111 |
+
$handlingFee = $handlingFee * $totalQty;
|
112 |
+
}
|
113 |
+
if(isset($domesticShippingOption) && $domesticShippingOption == "2") { //apply as per item
|
114 |
+
$domesticShippingFee = $domesticShippingFee * $totalQty;
|
115 |
+
}
|
116 |
+
$transportation = $quote['totalTransportation'];
|
117 |
+
// create new instance of method rate
|
118 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
119 |
+
|
120 |
+
// record carrier information
|
121 |
+
$method->setCarrier($this->_code);
|
122 |
+
|
123 |
+
// get config info
|
124 |
+
$vv = Mage::getStoreConfig('carriers/pbgsp/title');
|
125 |
+
$method->setCarrierTitle($vv);
|
126 |
+
|
127 |
+
// record method information
|
128 |
+
$title = $transportation['speed']." - ".(intval($transportation['minDays']) + $deliveryAdjMinDays)."-".(intval($transportation['maxDays']) + $deliveryAdjMixDays )." days";
|
129 |
+
$method->setMethod($transportation['speed']);
|
130 |
+
$method->setMethodTitle($title);
|
131 |
+
|
132 |
+
// rate cost is optional property to record how much it costs to vendor to ship
|
133 |
+
$method->setCost($transportation['shipping']['value']);
|
134 |
+
$method->setPrice((floatval($transportation['total']['value']) + $handlingFee + $domesticShippingFee));
|
135 |
+
|
136 |
+
if(Pb_Pbgsp_Model_Credentials::isFreeTaxEnabled()) {
|
137 |
+
Pb_Pbgsp_Model_Util::log('Free tax enabled');
|
138 |
+
$method->setTax(0);
|
139 |
+
}
|
140 |
+
|
141 |
+
else {
|
142 |
+
Pb_Pbgsp_Model_Util::log('Free tax disabled');
|
143 |
+
$method->setTax($quote['totalImportation']['total']['value']);
|
144 |
+
}
|
145 |
+
|
146 |
+
return $method;
|
147 |
+
}
|
148 |
+
private function _getCheapestShipMethod($quoteSet,$items)
|
149 |
+
{
|
150 |
+
$minPrice = -1;
|
151 |
+
$minQuote = null;
|
152 |
+
foreach ($quoteSet['quote'] as $quote) {
|
153 |
+
|
154 |
+
if (array_key_exists('totalTransportation', $quote)) {
|
155 |
+
$transportation = $quote['totalTransportation'];
|
156 |
+
$cost = floatval($transportation['total']['value']);
|
157 |
+
if($minPrice == -1 || $minPrice > $cost) {
|
158 |
+
$minPrice = $cost;
|
159 |
+
$minQuote = $quote;
|
160 |
+
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
+
return $this->_getShipMethodFromQuote($minQuote,$items);
|
166 |
+
}
|
167 |
+
/**
|
168 |
+
* Collect rates for this shipping method based on information in $request
|
169 |
+
*
|
170 |
+
* @param Mage_Shipping_Model_Rate_Request $data
|
171 |
+
* @return Mage_Shipping_Model_Rate_Result
|
172 |
+
*/
|
173 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
174 |
+
{
|
175 |
+
//Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Carrier_ShippingMethod.collectRates ' . Mage::getStoreConfig('carriers/'.$this->_code.'/active'));
|
176 |
+
// skip if not enabled
|
177 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
178 |
+
return false;
|
179 |
+
}
|
180 |
+
|
181 |
+
// skip if the store is not located in the US
|
182 |
+
Pb_Pbgsp_Model_Util::log($request->country_id);
|
183 |
+
if ($request->country_id != "US") {
|
184 |
+
return false;
|
185 |
+
}
|
186 |
+
|
187 |
+
// get necessary configuration values
|
188 |
+
|
189 |
+
|
190 |
+
// this object will be returned as result of this method
|
191 |
+
// containing all the shipping rates of this method
|
192 |
+
$result = Mage::getModel('shipping/rate_result');
|
193 |
+
|
194 |
+
$items = Mage::getSingleton('checkout/cart')->getItems();
|
195 |
+
$address = Mage::getSingleton('checkout/cart')->getQuote()->getShippingAddress();
|
196 |
+
|
197 |
+
if(!$items || count($items) == 0)
|
198 |
+
$items = $request->getAllItems();
|
199 |
+
if(!$address->getCountryId()) {
|
200 |
+
$address->setCountryId($request->getDestCountryId());
|
201 |
+
$address->setCity($request->getDestCity());
|
202 |
+
$address->setStreet($request->getDestStreet());
|
203 |
+
$address->setRegion($request->getDestRegionCode());
|
204 |
+
$address->setPostcode($request->getDestPostcode());
|
205 |
+
$address->setEmail('test@bigpixelstudio.com');
|
206 |
+
$address->setFirstname('firstname');
|
207 |
+
$address->setLastname('lastname');
|
208 |
+
$address->setTelephone('1231231234');
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
// Clear all restrictions from previous calls
|
213 |
+
Mage::getSingleton("customer/session")->setPbRestrictions(null);
|
214 |
+
$allowSpecific = Mage::getStoreConfig('carriers/'.$this->_code .'/sallowspecific');
|
215 |
+
if($allowSpecific) {
|
216 |
+
$activeCountries = Mage::getStoreConfig('carriers/'.$this->_code .'/specificcountry');
|
217 |
+
|
218 |
+
if(!(strpos($activeCountries,$address->getCountryId()) !== false)) {
|
219 |
+
Pb_Pbgsp_Model_Util::log($address->getCountryId().' not found');
|
220 |
+
return false;
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
// NOTE: Insert calls to Magento Domestic Shipping costs here. Pass the newly calculated
|
226 |
+
// domestic shipping costs to the API calls to get a proper full quote.
|
227 |
+
|
228 |
+
|
229 |
+
if (!$address->getStreet1() || !$address->getCity()) {
|
230 |
+
$address->setFirstname('firstname');
|
231 |
+
$address->setLastname('lastname');
|
232 |
+
$address->setCity('city');
|
233 |
+
$address->setTelephone('phone');
|
234 |
+
$address->setEmail('email@email.com');
|
235 |
+
$address->setStreet(array('street'));
|
236 |
+
}
|
237 |
+
|
238 |
+
try {
|
239 |
+
|
240 |
+
$shipMethodAvailable = false;
|
241 |
+
$quoteSet = Pb_Pbgsp_Model_Api::getQuote($items, $address);
|
242 |
+
$freeShippingEnabled = Mage::getStoreConfig('carriers/pbgsp/free_shipping_enable');
|
243 |
+
$freeShippingSubTotal = Mage::getStoreConfig('carriers/pbgsp/free_shipping_subtotal');
|
244 |
+
|
245 |
+
$totalOrderPrice = $this->getTotalOrderPrice($items);
|
246 |
+
$shipMethods = array();
|
247 |
+
foreach($quoteSet['quote'] as $quote) {
|
248 |
+
if(array_key_exists('errors',$quote) && count($quote['errors']) > 0) {
|
249 |
+
$this->displayErrors($result,$quote);
|
250 |
+
}
|
251 |
+
else if(array_key_exists('totalTransportation',$quote)) {
|
252 |
+
if($freeShippingEnabled && $totalOrderPrice >= $freeShippingSubTotal) {
|
253 |
+
//get cheapest shipping method from quoteSet
|
254 |
+
$method = $this->_getCheapestShipMethod($quoteSet,$items);
|
255 |
+
$method->setCost(0);
|
256 |
+
$method->setPrice(0);
|
257 |
+
$method->setTax(0);
|
258 |
+
$result->append($method);
|
259 |
+
array_push($shipMethods,$method);
|
260 |
+
break;
|
261 |
+
}
|
262 |
+
else {
|
263 |
+
$method = $this->_getShipMethodFromQuote($quote,$items);
|
264 |
+
|
265 |
+
// add this rate to the result
|
266 |
+
$result->append($method);
|
267 |
+
array_push($shipMethods,$method);
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
$shipMethodAvailable = true;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
if($shipMethodAvailable) {
|
275 |
+
Mage::getSingleton('checkout/session')->setPbMethods($shipMethods);
|
276 |
+
}
|
277 |
+
}
|
278 |
+
catch(Exception $e) {
|
279 |
+
Pb_Pbgsp_Model_Util::log("Error getting quotes");
|
280 |
+
Pb_Pbgsp_Model_Util::logException($e);
|
281 |
+
//$message = $e->getMessage();
|
282 |
+
//if($e->getMessage() == '')
|
283 |
+
$message = "We've received an unexpected error while getting your quote. Please try again. If the error persists contact magentosupport@pb.com.";
|
284 |
+
$this->_addError($result,$message);
|
285 |
+
|
286 |
+
}
|
287 |
+
return $result;
|
288 |
+
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
private function getTotalOrderPrice($products)
|
293 |
+
{
|
294 |
+
$totalOrderPrice = 0;
|
295 |
+
foreach ($products as $product) {
|
296 |
+
if ((!$product->getParentItem() && $product->getRealProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) || ($product->getParentItem() && $product->isChildrenCalculated())) {
|
297 |
+
$totalOrderPrice += $product->getPrice() * $product->getQty();
|
298 |
+
|
299 |
+
}
|
300 |
+
}
|
301 |
+
return $totalOrderPrice;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Catalog/Category.php
CHANGED
@@ -1,128 +1,145 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
public function
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
return $this->category->
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
//
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
public function
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
echo "
|
96 |
-
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
//
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Catalog/Category.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Catalog_Category {
|
10 |
+
protected $category;
|
11 |
+
private static $roots;
|
12 |
+
protected $url;
|
13 |
+
public function __construct($id,$url=null) {
|
14 |
+
if (gettype($id) == "object" && get_class($id) == "Mage_Catalog_Model_Category") {
|
15 |
+
$this->category = $id;
|
16 |
+
} else {
|
17 |
+
$this->category = Mage::getModel('catalog/category')->load($id);
|
18 |
+
}
|
19 |
+
$this->url = $url;
|
20 |
+
}
|
21 |
+
public function getCategory() {
|
22 |
+
return $this->category;
|
23 |
+
}
|
24 |
+
public function getName() {
|
25 |
+
return $this->category->getName();
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getCode() {
|
29 |
+
return $this->category->getId();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getUrl() {
|
33 |
+
//Pb_Pbgsp_Model_Util::log($this->category->getUrl());
|
34 |
+
if($this->url)
|
35 |
+
return $this->url;
|
36 |
+
return $this->category->getUrl();
|
37 |
+
//return Mage::app()->getStore($this->category->getStoreId())->getBaseUrl();
|
38 |
+
}
|
39 |
+
|
40 |
+
public function isRoot() {
|
41 |
+
if (!$this->category->getParentId()) {
|
42 |
+
return true;
|
43 |
+
}
|
44 |
+
if (!self::$roots) {
|
45 |
+
$categoryOp = new Mage_Adminhtml_Block_Catalog_Category_Abstract();
|
46 |
+
self::$roots = $categoryOp->getRootIds();
|
47 |
+
}
|
48 |
+
foreach (self::$roots as $rootId) {
|
49 |
+
if ($this->getCode() == $rootId) {
|
50 |
+
return true;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getParentCode() {
|
57 |
+
return $this->category->getParentId();
|
58 |
+
}
|
59 |
+
private function _shouldUpload($lastDiff) {
|
60 |
+
|
61 |
+
Pb_Pbgsp_Model_Util::log($this->category->getPbPbgspUploadActive());
|
62 |
+
if(!$this->category->getPbPbgspUploadActive()) return false;
|
63 |
+
$lastUpload = $this -> category -> getPbPbgspUpload();
|
64 |
+
//Pb_Pbgsp_Model_Util::log('Product '. $this -> getSKU() . ' lastUpload='. $lastUpload . ' '. date('m-d-Y H:i:s',$lastUpload));
|
65 |
+
if (!$lastUpload) {
|
66 |
+
// First upload.
|
67 |
+
return true;
|
68 |
+
} else if ($lastDiff <= $lastUpload - (30 * 60)) {
|
69 |
+
// Added after the last diff
|
70 |
+
return true;
|
71 |
+
} else {
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
public function writeToFile($file,$lastDiff) {
|
76 |
+
if($this->_shouldUpload($lastDiff)) {
|
77 |
+
$name = Pb_Pbgsp_Model_Catalog_File::stripHtml($this->getName());
|
78 |
+
$name = preg_replace("/[^A-Za-z0-9 ,.\-\+=;:\\(){}\[\]@?%$#]/", '', $name);
|
79 |
+
|
80 |
+
$parentCateID = '';
|
81 |
+
if($this->getParentCode() != 1 && !$this->isRoot()){
|
82 |
+
$parentCateID = $this->getParentCode();
|
83 |
+
}
|
84 |
+
fputcsv($file,array($this->getCode(),$parentCateID,$name,'',$this->getUrl()));
|
85 |
+
return true;
|
86 |
+
}
|
87 |
+
return false;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
// This is done via API
|
92 |
+
public function upload() {
|
93 |
+
echo "Uploading category: ".$this->category->getName()."... ";
|
94 |
+
if (Pb_Pbgsp_Model_Api::addCategory($this)) {
|
95 |
+
echo "ok";
|
96 |
+
} else {
|
97 |
+
echo "failed!";
|
98 |
+
}
|
99 |
+
echo "<br/>";
|
100 |
+
|
101 |
+
$products = $this->category->getProductCollection();
|
102 |
+
// TODO: Products that are part of multiple categories will be uploaded
|
103 |
+
// multiple times.
|
104 |
+
foreach ($products as $product) {
|
105 |
+
$clearPathProduct = new Pb_Pbgsp_Model_Catalog_Product($product);
|
106 |
+
echo "Uploading product: ".$clearPathProduct->getName()."... ";
|
107 |
+
if (Pb_Pbgsp_Model_Api::addCommodity($clearPathProduct)) {
|
108 |
+
echo "ok";
|
109 |
+
} else {
|
110 |
+
echo "failed!";
|
111 |
+
}
|
112 |
+
echo "<br/>";
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
$children = $this->category->getChildrenCategories();
|
117 |
+
|
118 |
+
// TODO: this code will run out of memory if there are a lot of categories....
|
119 |
+
// Need to convert the recursive call to a loop at some point.
|
120 |
+
foreach ($children as $child) {
|
121 |
+
$childCategory = new Pb_Pbgsp_Model_Catalog_Category($child);
|
122 |
+
$childCategory->upload();
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
// This fuction starts at the Magento root and its not very efficient... see isRoot for proper implementation.
|
127 |
+
// This function is only used by the API upload.
|
128 |
+
public static function getAllRootCategories() {
|
129 |
+
$roots = array();
|
130 |
+
|
131 |
+
$categories = Mage::getModel('catalog/category')->getCollection();//->getSelect()->order(array('IF(`id`>0, `id`, 9999) ASC'));
|
132 |
+
$categories = $categories->getIterator();
|
133 |
+
|
134 |
+
foreach ($categories as $category) {
|
135 |
+
$parents = $category->getParentId();
|
136 |
+
if (!$parents) {
|
137 |
+
$rootCategory = new Pb_Pbgsp_Model_Catalog_Category($category->getId());
|
138 |
+
array_push($roots,$rootCategory);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
return $roots;
|
142 |
+
}
|
143 |
+
|
144 |
+
}
|
145 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Catalog/Cron.php
CHANGED
@@ -1,95 +1,102 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
//
|
41 |
-
$this->uploadCatalog(
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
$this->lastFull
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$this->
|
67 |
-
}
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
$this->lastDiff
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Catalog/Cron.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Catalog_Cron {
|
10 |
+
|
11 |
+
private $lastDiff;
|
12 |
+
private $lastFull;
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
public function catalogSync() {
|
17 |
+
Pb_Pbgsp_Model_Util::log("Start Sync...");
|
18 |
+
$diffPeriod = Mage::getStoreConfig('carriers/pbgsp/catalog_diff');
|
19 |
+
$fullPeriod = Mage::getStoreConfig('carriers/pbgsp/catalog_full');
|
20 |
+
|
21 |
+
$collection = Mage::getModel("pb_pbgsp/variable")->getCollection();
|
22 |
+
foreach ($collection as $variable) {
|
23 |
+
Pb_Pbgsp_Model_Util::log($variable->getName()." -> ".$variable->getValue());
|
24 |
+
if ($variable->getName() == "lastFull") {
|
25 |
+
$this->lastFull = $variable;
|
26 |
+
}
|
27 |
+
if ($variable->getName() == "lastDiff") {
|
28 |
+
$this->lastDiff = $variable;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
$appRoot = Mage::getRoot();
|
34 |
+
$mageRoot = dirname($appRoot);
|
35 |
+
$configOptions = Mage::getModel('core/config_options');
|
36 |
+
$configOptions->createDirIfNotExists($mageRoot.'/var/pbgsp');
|
37 |
+
chmod($mageRoot . '/var/pbgsp/', 0777);
|
38 |
+
|
39 |
+
if (!isset($this->lastFull) || $this->lastFull->getValue() < time() - $fullPeriod*24*3600) {
|
40 |
+
// Full catalog upload needed
|
41 |
+
$this->uploadCatalog();
|
42 |
+
} else if (!isset($this->lastDiff) && $this->lastFull->getValue() < time() - $diffPeriod*3600) {
|
43 |
+
// First catalog diff upload
|
44 |
+
$this->uploadCatalog($this->lastFull);
|
45 |
+
} else if (isset($this->lastDiff) && ($this->lastDiff->getValue() < time() - $diffPeriod*3600 &&
|
46 |
+
$this->lastFull->getValue() < time() - $diffPeriod*3600)) {
|
47 |
+
// Catalog diff upload
|
48 |
+
$this->uploadCatalog($this->lastDiff);
|
49 |
+
}
|
50 |
+
else {
|
51 |
+
Pb_Pbgsp_Model_Util::log('PB Export cron. Do not export catalog');
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
public function uploadCatalog($lastDiff = false) {
|
58 |
+
if (!$lastDiff) {
|
59 |
+
Pb_Pbgsp_Model_Util::log("Full catalog upload");
|
60 |
+
$file = new Pb_Pbgsp_Model_Catalog_File();
|
61 |
+
if (isset($this->lastFull)) {
|
62 |
+
$this->lastFull->setValue(time());
|
63 |
+
} else {
|
64 |
+
$this->lastFull = Mage::getModel("pb_pbgsp/variable");
|
65 |
+
$this->lastFull->setName("lastFull");
|
66 |
+
$this->lastFull->setValue(time());
|
67 |
+
}
|
68 |
+
$this->lastFull->save();
|
69 |
+
} else {
|
70 |
+
Pb_Pbgsp_Model_Util::log("catalog diff");
|
71 |
+
$file = new Pb_Pbgsp_Model_Catalog_File($lastDiff->getValue());
|
72 |
+
if (isset($this->lastDiff)) {
|
73 |
+
$this->lastDiff->setValue(time());
|
74 |
+
} else {
|
75 |
+
$this->lastDiff = Mage::getModel("pb_pbgsp/variable");
|
76 |
+
$this->lastDiff->setName("lastDiff");
|
77 |
+
$this->lastDiff->setValue(time());
|
78 |
+
}
|
79 |
+
$this->lastDiff->save();
|
80 |
+
}
|
81 |
+
|
82 |
+
Pb_Pbgsp_Model_Util::log("RAY:Create Function Started");
|
83 |
+
|
84 |
+
$file->createNew();
|
85 |
+
|
86 |
+
Pb_Pbgsp_Model_Util::log("RAY:Create Function Complete");
|
87 |
+
|
88 |
+
Pb_Pbgsp_Model_Util::log("RAY:upload Started");
|
89 |
+
$file->upload();
|
90 |
+
$file->logProdWithoutCategories();
|
91 |
+
Pb_Pbgsp_Model_Util::log("RAY:upload Complete");
|
92 |
+
}
|
93 |
+
|
94 |
+
public function processStatusNotifications() {
|
95 |
+
$file = new Pb_Pbgsp_Model_Catalog_File();
|
96 |
+
$file->processStatusNotifications();
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Catalog/File.php
CHANGED
@@ -1,673 +1,728 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
private $
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
$
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
$
|
102 |
-
$
|
103 |
-
$
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$
|
123 |
-
|
124 |
-
|
125 |
-
$
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
$
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
->
|
139 |
-
|
140 |
-
|
141 |
-
$
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
$
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
$
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
->addAttributeToSelect('
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
$
|
218 |
-
$
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
$
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
$
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
$
|
253 |
-
$
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
//Pb_Pbgsp_Model_Util::log(
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
$
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
$
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
$
|
399 |
-
$
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
$
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
);
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
$
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
$
|
457 |
-
if(!isset($
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
$
|
519 |
-
$
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
}
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
$this->
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
if
|
555 |
-
$
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
$
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
return
|
623 |
-
}
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
->
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
$
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
/**
|
663 |
-
* @param $
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Model/Catalog/File.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Pb_Pbgsp_Model_Catalog_File {
|
12 |
+
|
13 |
+
|
14 |
+
private $file;
|
15 |
+
private $filename;
|
16 |
+
private $lastDiff;
|
17 |
+
private $productIds;
|
18 |
+
private $lastFileName;
|
19 |
+
private $uploadedCategories;
|
20 |
+
public function __construct($lastDiff = false) {
|
21 |
+
$this->lastDiff = $lastDiff;
|
22 |
+
$this->productIds = array();
|
23 |
+
$this->uploadedCategories = array();
|
24 |
+
}
|
25 |
+
|
26 |
+
private function _getTempDir() {
|
27 |
+
$appRoot = Mage::getRoot();
|
28 |
+
$mageRoot = dirname($appRoot);
|
29 |
+
$configOptions = Mage::getModel('core/config_options');
|
30 |
+
$tmpDir = $mageRoot . '/var/pbgsp/tmp/';
|
31 |
+
$configOptions->createDirIfNotExists( $tmpDir);
|
32 |
+
chmod($tmpDir, 0777);
|
33 |
+
return $tmpDir;
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
private function _getDataFileName($dataFeedName,$part=null) {
|
38 |
+
$partName = '';
|
39 |
+
if($part)
|
40 |
+
$partName = '_part'.$part;
|
41 |
+
$fileName = Pb_Pbgsp_Model_Credentials::getCatalogSenderID() . "_".$dataFeedName."_update_". Pb_Pbgsp_Model_Credentials::getPBID().'_'.date('Ymd_His').'_'.mt_rand(100000, 999999);
|
42 |
+
if($part == 1)
|
43 |
+
$this->lastFileName = $fileName;
|
44 |
+
else
|
45 |
+
$fileName = $this->lastFileName;
|
46 |
+
return $fileName.$partName.'.csv';
|
47 |
+
}
|
48 |
+
private function _createNewCommoditiyFile($part=null) {
|
49 |
+
$fileName = $this->_getDataFileName('catalog',$part);
|
50 |
+
|
51 |
+
|
52 |
+
$this->filename = $this->_getTempDir().$fileName;
|
53 |
+
$this->file = fopen($this->filename,"w+");
|
54 |
+
chmod($this->filename, 0777);
|
55 |
+
//add header row
|
56 |
+
fputcsv($this->file,array('MERCHANT_COMMODITY_REF_ID','COMMODITY_NAME_TITLE','SHORT_DESCRIPTION',
|
57 |
+
'LONG_DESCRIPTION','RETAILER_ID','COMMODITY_URL','RETAILER_UNIQUE_ID','PCH_CATEGORY_ID',
|
58 |
+
'RH_CATEGORY_ID','STANDARD_PRICE','WEIGHT_UNIT','DISTANCE_UNIT','COO','IMAGE_URL','PARENT_SKU',
|
59 |
+
'CHILD_SKU','PARCELS_PER_SKU','UPC','UPC_CHECK_DIGIT','GTIN','MPN','ISBN','BRAND','MANUFACTURER',
|
60 |
+
'MODEL_NUMBER','MANUFACTURER_STOCK_NUMBER','COMMODITY_CONDITION','COMMODITY_HEIGHT',
|
61 |
+
'COMMODITY_WIDTH','COMMODITY_LENGTH','PACKAGE_WEIGHT','PACKAGE_HEIGHT','PACKAGE_WIDTH',
|
62 |
+
'PACKAGE_LENGTH','HAZMAT','ORMD','CHEMICAL_INDICATOR','PESTICIDE_INDICATOR','AEROSOL_INDICATOR',
|
63 |
+
'RPPC_INDICATOR','BATTERY_TYPE','NON_SPILLABLE_BATTERY','FUEL_RESTRICTION','SHIP_ALONE',
|
64 |
+
'RH_CATEGORY_ID_PATH','RH_CATEGORY_NAME_PATH'));//,'RH_CATEGORY_URL_PATH','GPC','COMMODITY_WEIGHT','HS_CODE','CURRENCY'
|
65 |
+
|
66 |
+
fflush($this->file);
|
67 |
+
}
|
68 |
+
private function _createNewCategoryFile($part=null) {
|
69 |
+
$fileName = $this->_getDataFileName('category-tree',$part);
|
70 |
+
|
71 |
+
|
72 |
+
$this->filename = $this->_getTempDir().$fileName;
|
73 |
+
$this->file = fopen($this->filename,"w+");
|
74 |
+
chmod($this->filename, 0777);
|
75 |
+
//add header row
|
76 |
+
fputcsv($this->file,array('CATEGORY_ID','PARENT_CATEGORY_ID','NAME',
|
77 |
+
'ID_PATH','URL'));
|
78 |
+
|
79 |
+
fflush($this->file);
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
private function _getSelectedCategory($categories,$catId) {
|
86 |
+
foreach($categories as $cat) {
|
87 |
+
if($cat->getId() == $catId)
|
88 |
+
return $cat;
|
89 |
+
}
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
/**
|
93 |
+
* Extracts the categories and products and exports them into xml file.
|
94 |
+
*/
|
95 |
+
public function createNew() {
|
96 |
+
|
97 |
+
$maxRecordsCount = Pb_Pbgsp_Model_Credentials::getMaxRecordsCount();
|
98 |
+
if(!$maxRecordsCount)
|
99 |
+
$maxRecordsCount = 10000;
|
100 |
+
|
101 |
+
$prodCount = 0;
|
102 |
+
$catCount = 0;
|
103 |
+
$fileRecordCount = 0;
|
104 |
+
//get stores which has disabled clearpath
|
105 |
+
$stores = Mage::app()->getStores();
|
106 |
+
$defaultStoreUrl = Mage::getBaseUrl();
|
107 |
+
$secDefaultStoreUrl = str_replace("http","https",$defaultStoreUrl);
|
108 |
+
$disabledStores = array();
|
109 |
+
$addedCategories = array();
|
110 |
+
$part=1;
|
111 |
+
foreach($stores as $store) {
|
112 |
+
|
113 |
+
$isActive = Mage::getStoreConfig('carriers/pbgsp/active',$store);
|
114 |
+
$baseURL = $store->getBaseUrl();
|
115 |
+
|
116 |
+
if(!$isActive) {
|
117 |
+
$disabledStores[] = $store;
|
118 |
+
Pb_Pbgsp_Model_Util::log("Disabled store". $store->getId(). ' '. $store->getCode());
|
119 |
+
}
|
120 |
+
else {
|
121 |
+
$rootId = Mage::app()->getStore($store->getId())->getRootCategoryId();
|
122 |
+
$rootCat = Mage::getModel('catalog/category')->load($rootId);
|
123 |
+
/* @var $rootCat Mage_Catalog_Model_Category */
|
124 |
+
$rootCat->setData('store',$store);
|
125 |
+
Pb_Pbgsp_Model_Util::log("Default store url $defaultStoreUrl store ".$store->getCode()." store base url".
|
126 |
+
$baseURL." root cat url". $rootCat->getUrl(). " cat name". $rootCat->getName());
|
127 |
+
$catUrl = str_replace($defaultStoreUrl,$baseURL,$rootCat->getUrl());
|
128 |
+
if($catUrl == $rootCat->getUrl())
|
129 |
+
$catUrl = str_replace($secDefaultStoreUrl,$baseURL,$rootCat->getUrl());
|
130 |
+
$cat = new Pb_Pbgsp_Model_Catalog_Category($rootCat,$catUrl);
|
131 |
+
if(!$this->file || $fileRecordCount > $maxRecordsCount)
|
132 |
+
{
|
133 |
+
$this->_createNewCategoryFile($part);
|
134 |
+
$fileRecordCount=0;
|
135 |
+
$part++;
|
136 |
+
}
|
137 |
+
if($cat->writeToFile($this->file,$this->lastDiff))
|
138 |
+
$this->uploadedCategories[] = $rootCat;
|
139 |
+
fflush($this->file);
|
140 |
+
$catCount++;
|
141 |
+
$fileRecordCount++;
|
142 |
+
$categories = Mage::getModel('catalog/category')
|
143 |
+
->getCollection()
|
144 |
+
->addUrlRewriteToResult()
|
145 |
+
->addAttributeToSelect('name')
|
146 |
+
->addAttributeToSelect('pb_pbgsp_upload_active')
|
147 |
+
->addAttributeToSelect('pb_pbgsp_upload')
|
148 |
+
->addFieldToFilter('path', array('like'=> "1/$rootId/%"));
|
149 |
+
$addedCategories[] = $rootCat;
|
150 |
+
|
151 |
+
foreach($categories as $category) {
|
152 |
+
if(!$this->file || $fileRecordCount > $maxRecordsCount)
|
153 |
+
{
|
154 |
+
$this->_createNewCategoryFile($part);
|
155 |
+
$fileRecordCount=0;
|
156 |
+
$part++;
|
157 |
+
}
|
158 |
+
/* @var $category Mage_Catalog_Model_Category */
|
159 |
+
$category->setStoreId($store->getId());
|
160 |
+
$category->setData('store',$store);
|
161 |
+
$addedCategories[] = $category;
|
162 |
+
|
163 |
+
|
164 |
+
|
165 |
+
|
166 |
+
$catUrl = str_replace($defaultStoreUrl,$baseURL,$category->getUrl());
|
167 |
+
if($catUrl == $category->getUrl())
|
168 |
+
$catUrl = str_replace($secDefaultStoreUrl,$baseURL,$category->getUrl());
|
169 |
+
$cat = new Pb_Pbgsp_Model_Catalog_Category($category,$catUrl);
|
170 |
+
if($cat->writeToFile($this->file,$this->lastDiff))
|
171 |
+
$this->uploadedCategories[] = $category;
|
172 |
+
fflush($this->file);
|
173 |
+
$catCount++;
|
174 |
+
$fileRecordCount++;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
fclose($this->file);
|
180 |
+
$this->_stripPartFromFileName($part);
|
181 |
+
//fwrite($this->file,"</CategoryList>\n<CommodityList>\n");
|
182 |
+
$fileRecordCount=0;
|
183 |
+
$part=1;
|
184 |
+
$this->_createNewCommoditiyFile($part);
|
185 |
+
$part++;
|
186 |
+
$addedProducts = array();
|
187 |
+
foreach($addedCategories as $category) {
|
188 |
+
//Mage::app()->setCurrentStore($category->getStoreId());
|
189 |
+
|
190 |
+
$count = Mage::getModel('catalog/product')->getCollection()
|
191 |
+
->addCategoryFilter($category)
|
192 |
+
->count();
|
193 |
+
$pageSize = 400;
|
194 |
+
$currIndex = 0;
|
195 |
+
while($currIndex < $count) {
|
196 |
+
$productCollection = Mage::getModel('catalog/product')->getCollection()
|
197 |
+
|
198 |
+
->addCategoryFilter($category)
|
199 |
+
|
200 |
+
->addAttributeToSelect('name')
|
201 |
+
->addAttributeToSelect('sku')
|
202 |
+
->addAttributeToSelect('country_of_manufacture')
|
203 |
+
->addAttributeToSelect('description')
|
204 |
+
->addAttributeToSelect('product_url')
|
205 |
+
->addAttributeToSelect('type_id')
|
206 |
+
->addAttributeToSelect('pb_pbgsp_upload')
|
207 |
+
// ->addUrlRewrite($category->getId()) //this will add the url rewrite.
|
208 |
+
->addAttributeToSelect('price')
|
209 |
+
->addAttributeToSelect('weight');
|
210 |
+
|
211 |
+
$baseURL = Mage::app()->getStore($category->getStoreId())->getBaseUrl();
|
212 |
+
$productUrlFormat = $baseURL ."catalog/product/view/id/%d/";
|
213 |
+
foreach($productCollection as $product) {
|
214 |
+
/* @var $product Mage_Catalog_Model_Product */
|
215 |
+
if($product->getTypeId() == 'virtual')
|
216 |
+
continue;
|
217 |
+
$cateIds = $product->getCategoryIds();
|
218 |
+
$cateId = 0;
|
219 |
+
foreach($cateIds as $cId) {
|
220 |
+
$cateId = $cId;//get lower level of category
|
221 |
+
}
|
222 |
+
$prodCat = $this->_getSelectedCategory($addedCategories,$cateId);
|
223 |
+
if(!$prodCat)
|
224 |
+
$prodCat = $category;
|
225 |
+
$cIds = explode('/',$prodCat->getPath());
|
226 |
+
$cIds = array_slice($cIds,1);//remove root category
|
227 |
+
$prodCat->setData('id_path',implode(':',$cIds));
|
228 |
+
$prodCat->setData('name_path',$this->_getCatNamePath($addedCategories,$cIds));
|
229 |
+
if($product->getTypeId() == 'configurable' ) {
|
230 |
+
$productType = $product->getTypeInstance(true);
|
231 |
+
$allowedProducts = $productType->getUsedProducts(null, $product);
|
232 |
+
/** @var $childProduct Mage_Catalog_Model_Product */
|
233 |
+
|
234 |
+
foreach($allowedProducts as $childProduct) {
|
235 |
+
if(!array_key_exists($childProduct->getSku(),$addedProducts)) {
|
236 |
+
if( $fileRecordCount > $maxRecordsCount)
|
237 |
+
{
|
238 |
+
$this->_createNewCommoditiyFile($part);
|
239 |
+
$fileRecordCount=0;
|
240 |
+
$part++;
|
241 |
+
}
|
242 |
+
$pbChildProduct = new Pb_Pbgsp_Model_Catalog_Product($childProduct->getId(),sprintf($productUrlFormat,$product->getId()));
|
243 |
+
$this->writeProduct($pbChildProduct,$cateId,$product->getSku(),$prodCat);
|
244 |
+
$addedProducts[$childProduct->getSku()] = "added";
|
245 |
+
$prodCount++;
|
246 |
+
$fileRecordCount++;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
else {
|
251 |
+
if(!array_key_exists($product->getSku(),$addedProducts)) {
|
252 |
+
$pbProduct = new Pb_Pbgsp_Model_Catalog_Product($product,sprintf($productUrlFormat,$product->getId()));
|
253 |
+
if( $fileRecordCount > $maxRecordsCount)
|
254 |
+
{
|
255 |
+
$this->_createNewCommoditiyFile();
|
256 |
+
$fileRecordCount=0;
|
257 |
+
$part++;
|
258 |
+
}
|
259 |
+
$this->writeProduct($pbProduct,$cateId,null,$prodCat);
|
260 |
+
$prodCount++;
|
261 |
+
$fileRecordCount++;
|
262 |
+
$addedProducts[$product->getSku()] = "added";
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
+
}
|
271 |
+
$currIndex += $pageSize;
|
272 |
+
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
|
278 |
+
// fwrite($this->file,"</CommodityList>\n</Catalog>\n");
|
279 |
+
fflush($this->file);
|
280 |
+
|
281 |
+
$this->_stripPartFromFileName($part);
|
282 |
+
}
|
283 |
+
|
284 |
+
private function _getCatNamePath($categories,$cateIds) {
|
285 |
+
|
286 |
+
$names = array();
|
287 |
+
foreach($cateIds as $id) {
|
288 |
+
foreach($categories as $cat) {
|
289 |
+
if($cat->getId() == $id) {
|
290 |
+
array_push($names, $cat->getName());
|
291 |
+
break;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
// Pb_Pbgsp_Model_Util::log($names);
|
296 |
+
return implode('|',$names);
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Updates the pb_pbgsp_upload time in all uploaded products
|
301 |
+
*/
|
302 |
+
public function updateLastProductUpload() {
|
303 |
+
|
304 |
+
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'pb_pbgsp_upload');
|
305 |
+
if(!$attribute->getAttributeId()) {
|
306 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
307 |
+
$setup->addAttribute('catalog_product', 'pb_pbgsp_upload', array(
|
308 |
+
'label' => 'Last Pb upload timestampt',
|
309 |
+
'type' => 'datetime',
|
310 |
+
'input' => 'datetime',
|
311 |
+
'visible' => false,
|
312 |
+
'required' => false,
|
313 |
+
'position' => 1,
|
314 |
+
));
|
315 |
+
}
|
316 |
+
|
317 |
+
$productIds = array_unique($this->productIds);
|
318 |
+
Pb_Pbgsp_Model_Util::log('Uploaded products' . count($productIds));
|
319 |
+
$updated = 0;
|
320 |
+
foreach ($productIds as $prodId) {
|
321 |
+
$product = Mage::getModel("catalog/product")->load($prodId);
|
322 |
+
//Pb_Pbgsp_Model_Util::log('Updating product '. $product->getSKU());
|
323 |
+
$product->unlockAttribute('pb_pbgsp_upload');
|
324 |
+
$product->setPbPbgspUpload(time());
|
325 |
+
try{
|
326 |
+
$product->save();
|
327 |
+
$updated++;
|
328 |
+
}catch(Exception $e){
|
329 |
+
Pb_Pbgsp_Model_Util::log("There was a problem saving the product with sku ". $product->getSku() ." Error Message \n" . $e->getMessage());
|
330 |
+
}
|
331 |
+
|
332 |
+
//Pb_Pbgsp_Model_Util::log($product->getId()." ".$product->getName()." ".$product->getPbPbgspUpload());
|
333 |
+
}
|
334 |
+
Pb_Pbgsp_Model_Util::log("$updated products' pb_pbgsp_upload updated");
|
335 |
+
}
|
336 |
+
|
337 |
+
public function updateLastCategoryUpload() {
|
338 |
+
|
339 |
+
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_category', 'pb_pbgsp_upload');
|
340 |
+
if(!$attribute->getAttributeId()) {
|
341 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
342 |
+
$setup->addAttribute('catalog_category', 'pb_pbgsp_upload', array(
|
343 |
+
'label' => 'Last Pb upload timestampt',
|
344 |
+
'type' => 'datetime',
|
345 |
+
'input' => 'datetime',
|
346 |
+
'visible' => false,
|
347 |
+
'required' => false,
|
348 |
+
'position' => 1,
|
349 |
+
));
|
350 |
+
}
|
351 |
+
|
352 |
+
|
353 |
+
Pb_Pbgsp_Model_Util::log('Uploaded categories' . count($this->uploadedCategories));
|
354 |
+
$updated = 0;
|
355 |
+
foreach ($this->uploadedCategories as $category) {
|
356 |
+
$category->unlockAttribute('pb_pbgsp_upload');
|
357 |
+
$category->setPbPbgspUpload(time());
|
358 |
+
try{
|
359 |
+
$category->save();
|
360 |
+
$updated++;
|
361 |
+
}catch(Exception $e){
|
362 |
+
Pb_Pbgsp_Model_Util::log("There was a problem saving the category ". $category->getName() ." Error Message \n" . $e->getMessage());
|
363 |
+
}
|
364 |
+
|
365 |
+
//Pb_Pbgsp_Model_Util::log($product->getId()." ".$product->getName()." ".$product->getPbPbgspUpload());
|
366 |
+
}
|
367 |
+
Pb_Pbgsp_Model_Util::log("$updated categories' pb_pbgsp_upload updated");
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Uploads the xml file to clearpath SFTP server
|
372 |
+
*/
|
373 |
+
|
374 |
+
private function _getNotificationDir() {
|
375 |
+
$tmpDir = $this->_getTempDir();
|
376 |
+
$configOptions = Mage::getModel('core/config_options');
|
377 |
+
$notificationDir = $tmpDir . 'notifications';
|
378 |
+
$configOptions->createDirIfNotExists( $notificationDir);
|
379 |
+
chmod($notificationDir, 0777);
|
380 |
+
return $notificationDir;
|
381 |
+
}
|
382 |
+
|
383 |
+
public function processStatusNotifications() {
|
384 |
+
try {
|
385 |
+
|
386 |
+
$adminEmail = Pb_Pbgsp_Model_Credentials::getAdminEmail();
|
387 |
+
if(!isset($adminEmail) || $adminEmail=='')
|
388 |
+
return;
|
389 |
+
$notificationDir = $this->_getNotificationDir();
|
390 |
+
$this->_downloadStatusNotifications($notificationDir);
|
391 |
+
$notificationFiles = array_diff(scandir($notificationDir), array('..', '.'));
|
392 |
+
if(count($notificationFiles) > 0) {
|
393 |
+
$mail = new Zend_Mail();
|
394 |
+
$mail->setFrom('no-reply@pb.com','Pitney Bowes');
|
395 |
+
$mail->addTo($adminEmail)
|
396 |
+
->setSubject('Catalog Export Error')
|
397 |
+
->setBodyText('Catalog Export Error. Please see attached files.');
|
398 |
+
$fileCount = 0;
|
399 |
+
foreach($notificationFiles as $notificationFile) {
|
400 |
+
if($this->_endsWith($notificationFile,'.err') || $this->_endsWith($notificationFile,'.log') ) {
|
401 |
+
$file = $notificationDir.'/'. $notificationFile;
|
402 |
+
$at = new Zend_Mime_Part(file_get_contents($file));
|
403 |
+
$at->filename = basename($file);
|
404 |
+
$at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
|
405 |
+
$at->encoding = Zend_Mime::ENCODING_8BIT;
|
406 |
+
|
407 |
+
$mail->addAttachment($at);
|
408 |
+
$fileCount++;
|
409 |
+
}
|
410 |
+
|
411 |
+
}
|
412 |
+
if($fileCount > 0) {
|
413 |
+
$mail->send();
|
414 |
+
Pb_Pbgsp_Model_Util::log("Email sent with error files.");
|
415 |
+
}
|
416 |
+
|
417 |
+
else {
|
418 |
+
Pb_Pbgsp_Model_Util::log(" No error files found.");
|
419 |
+
}
|
420 |
+
//keep these files until next upload and delete files from old upload
|
421 |
+
$this->_cleanNotificationFiles();
|
422 |
+
}
|
423 |
+
}
|
424 |
+
catch (Exception $e) {
|
425 |
+
Pb_Pbgsp_Model_Util::log("Error in processStatusNotifications:". $e->getMessage());
|
426 |
+
Pb_Pbgsp_Model_Util::log($e->getTraceAsString());
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
}
|
431 |
+
private function _cleanNotificationFiles() {
|
432 |
+
//keep resent files until next upload and delete files from old upload
|
433 |
+
$lastExportedFiles = $this->_getLastExportedFileNames();
|
434 |
+
if(!$lastExportedFiles)
|
435 |
+
return;
|
436 |
+
$notificationDir = $this->_getNotificationDir();
|
437 |
+
$notificationFiles = array_diff(scandir($notificationDir), array('..', '.'));
|
438 |
+
|
439 |
+
foreach($notificationFiles as $notificationFile) {
|
440 |
+
$path_parts = pathinfo($notificationFile);
|
441 |
+
$localFileNameWithoutExt = $path_parts['filename'];
|
442 |
+
$isOldFile = true;
|
443 |
+
foreach($lastExportedFiles as $lastExportedFile) {
|
444 |
+
$lastExportedFileNameWithoutExt = str_replace('.gpg','',str_replace('.csv','',$lastExportedFile));
|
445 |
+
if($lastExportedFileNameWithoutExt == $localFileNameWithoutExt) {
|
446 |
+
$isOldFile = false;
|
447 |
+
break;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
if($isOldFile) {
|
451 |
+
//this is from 2nd last upload, remove it from disk
|
452 |
+
unlink($notificationDir.'/'.$notificationFile);
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
$exportedFilesVariable = $this->_getExportedFilesVariable();
|
457 |
+
if(!isset($exportedFilesVariable))
|
458 |
+
{
|
459 |
+
$exportedFilesVariable = Mage::getModel("pb_pbgsp/variable");
|
460 |
+
$exportedFilesVariable->setName("exportedFiles");
|
461 |
+
}
|
462 |
+
|
463 |
+
$exportedFilesVariable->setValue('');
|
464 |
+
$exportedFilesVariable->save();
|
465 |
+
}
|
466 |
+
private function _downloadStatusNotifications($notificationDir) {
|
467 |
+
|
468 |
+
$credentials = $this->_getSftpCredentials();
|
469 |
+
try {
|
470 |
+
$sftpDumpFile = new Varien_Io_Sftp();
|
471 |
+
$sftpDumpFile->open(
|
472 |
+
$credentials
|
473 |
+
);
|
474 |
+
$rootDir = Pb_Pbgsp_Model_Credentials::getSftpCatalogDirectory();
|
475 |
+
if(!$this->_endsWith($rootDir,'/'))
|
476 |
+
$rootDir = $rootDir.'/';
|
477 |
+
$processedDir = $rootDir.'outbound';
|
478 |
+
$sftpDumpFile->cd($processedDir);
|
479 |
+
$files = $sftpDumpFile->ls();
|
480 |
+
|
481 |
+
//Pb_Pbgsp_Model_Util::log($files);
|
482 |
+
|
483 |
+
$exportedFiles = $this->_getLastExportedFileNames();
|
484 |
+
if(!$exportedFiles)
|
485 |
+
return;
|
486 |
+
foreach($files as $file) {
|
487 |
+
foreach($exportedFiles as $exportedFile) {
|
488 |
+
if($exportedFile == '')
|
489 |
+
continue;
|
490 |
+
$fileNameWithoutExtension = str_replace(".gpg","",str_replace(".csv","",$exportedFile));
|
491 |
+
if($this->_startsWith($file['text'],$fileNameWithoutExtension)) {
|
492 |
+
$dest = $notificationDir.'/'.$file['text'];
|
493 |
+
$sftpDumpFile->read($file['text'],$dest);
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
}
|
498 |
+
$sftpDumpFile->close();
|
499 |
+
}
|
500 |
+
catch (Exception $e) {
|
501 |
+
Pb_Pbgsp_Model_Util::log($e->getTraceAsString());
|
502 |
+
Pb_Pbgsp_Model_Util::log("Pb Module could not connect to sftp server: ".$credentials['host']." Wrong username/password. Postponing catalog upload.");
|
503 |
+
return;
|
504 |
+
}
|
505 |
+
|
506 |
+
}
|
507 |
+
|
508 |
+
private function _encryptExportedFiles($exportedFiles) {
|
509 |
+
$encryptedFiles = array();
|
510 |
+
$publicKey = Pb_Pbgsp_Model_Credentials::getPublicKey();
|
511 |
+
if(!isset($publicKey) || $publicKey=='') {
|
512 |
+
Pb_Pbgsp_Model_Util::log('Public key is not set cannot encrypt catalog files.');
|
513 |
+
return $exportedFiles;
|
514 |
+
}
|
515 |
+
try {
|
516 |
+
$gnupg = new gnupg();
|
517 |
+
$keyInfo = $gnupg->import($publicKey);
|
518 |
+
$gnupg->addencryptkey($keyInfo['fingerprint']);
|
519 |
+
$tmpDir = $this->_getTempDir();
|
520 |
+
Pb_Pbgsp_Model_Util::log('Encrypting the files.');
|
521 |
+
foreach($exportedFiles as $exportedFile) {
|
522 |
+
$fileName = $tmpDir . $exportedFile;
|
523 |
+
if(is_dir($fileName))
|
524 |
+
continue;
|
525 |
+
$encryptedFileName = $exportedFile.'.gpg';
|
526 |
+
Pb_Pbgsp_Model_Util::log("Encrypted file $encryptedFileName");
|
527 |
+
file_put_contents($tmpDir.$encryptedFileName,$gnupg->encrypt(file_get_contents($fileName)));
|
528 |
+
$encryptedFiles[] = $encryptedFileName;
|
529 |
+
}
|
530 |
+
return $encryptedFiles;
|
531 |
+
}
|
532 |
+
catch (Exception $e) {
|
533 |
+
Pb_Pbgsp_Model_Util::log($e->getTraceAsString());
|
534 |
+
Pb_Pbgsp_Model_Util::log("Error in encryption.");
|
535 |
+
return $encryptedFiles;
|
536 |
+
}
|
537 |
+
|
538 |
+
|
539 |
+
}
|
540 |
+
public function upload() {
|
541 |
+
|
542 |
+
$tmpDir = $this->_getTempDir();
|
543 |
+
$exportedFiles = array_diff(scandir($tmpDir), array('..', '.'));
|
544 |
+
if (count($this->productIds) == 0) {
|
545 |
+
// No new products to send, don't send anything.
|
546 |
+
$this->_removeExportedFiles($exportedFiles);
|
547 |
+
|
548 |
+
return;
|
549 |
+
}
|
550 |
+
|
551 |
+
Pb_Pbgsp_Model_Util::log("Pb catalog file upload started");
|
552 |
+
try {
|
553 |
+
|
554 |
+
if(Pb_Pbgsp_Model_Credentials::isEncryptionEnabled()) {
|
555 |
+
$exportedFiles = $this->_encryptExportedFiles($exportedFiles);
|
556 |
+
}
|
557 |
+
else {
|
558 |
+
Pb_Pbgsp_Model_Util::log('Encryption is not enabled.'.Pb_Pbgsp_Model_Credentials::isEncryptionEnabled());
|
559 |
+
}
|
560 |
+
$sftpDumpFile = new Varien_Io_Sftp();
|
561 |
+
$credentials = $this->_getSftpCredentials();
|
562 |
+
|
563 |
+
Pb_Pbgsp_Model_Util::log($credentials);
|
564 |
+
|
565 |
+
$sftpDumpFile->open(
|
566 |
+
$credentials
|
567 |
+
);
|
568 |
+
//Upload to SFTP
|
569 |
+
$rootDir = Pb_Pbgsp_Model_Credentials::getSftpCatalogDirectory();
|
570 |
+
if(!$this->_endsWith($rootDir,'/'))
|
571 |
+
$rootDir = $rootDir.'/';
|
572 |
+
$tmpSFTPDir = $rootDir.'tmp';
|
573 |
+
$inboundDir = $rootDir.'inbound';
|
574 |
+
$uploadedFiles = array();
|
575 |
+
foreach($exportedFiles as $exportedFile) {
|
576 |
+
$fileName = $tmpDir . $exportedFile;
|
577 |
+
if(is_dir($fileName))
|
578 |
+
continue;
|
579 |
+
|
580 |
+
Pb_Pbgsp_Model_Util::log("CD to $tmpSFTPDir");
|
581 |
+
$sftpDumpFile->cd($tmpSFTPDir);
|
582 |
+
Pb_Pbgsp_Model_Util::log("Uploading $fileName");
|
583 |
+
$sftpDumpFile->write($exportedFile, file_get_contents($fileName));
|
584 |
+
Pb_Pbgsp_Model_Util::log("Moving ".$tmpSFTPDir."/$exportedFile"." to ".$inboundDir."/$exportedFile");
|
585 |
+
$sftpDumpFile->mv($tmpSFTPDir."/$exportedFile",$inboundDir."/$exportedFile");
|
586 |
+
$uploadedFiles[] = $exportedFile;
|
587 |
+
}
|
588 |
+
$sftpDumpFile->close();
|
589 |
+
|
590 |
+
} catch (Exception $e) {
|
591 |
+
Pb_Pbgsp_Model_Util::log($e->getTraceAsString());
|
592 |
+
Pb_Pbgsp_Model_Util::log("Pb Module could not connect to sftp server: ".$credentials['host']." Wrong username/password. Postponing catalog upload.");
|
593 |
+
return;
|
594 |
+
}
|
595 |
+
|
596 |
+
Pb_Pbgsp_Model_Util::log("Pb catalog file upload ended");
|
597 |
+
|
598 |
+
$this->_removeExportedFiles($exportedFiles);
|
599 |
+
$this->updateLastCategoryUpload();
|
600 |
+
$this->updateLastProductUpload();
|
601 |
+
$this->_logExportedFileInDB($uploadedFiles);
|
602 |
+
}
|
603 |
+
|
604 |
+
private function _getExportedFilesVariable() {
|
605 |
+
$collection = Mage::getModel("pb_pbgsp/variable")->getCollection();
|
606 |
+
$exportedFilesVariable = null;
|
607 |
+
foreach ($collection as $variable) {
|
608 |
+
|
609 |
+
if ($variable->getName() == "exportedFiles") {
|
610 |
+
$exportedFilesVariable = $variable;
|
611 |
+
break;
|
612 |
+
}
|
613 |
+
|
614 |
+
}
|
615 |
+
return $exportedFilesVariable;
|
616 |
+
}
|
617 |
+
private function _getLastExportedFileNames() {
|
618 |
+
$exportedFilesVariable = $this->_getExportedFilesVariable();
|
619 |
+
if(!isset($exportedFilesVariable) && $exportedFilesVariable->getValue() != '')
|
620 |
+
return false;
|
621 |
+
$exportedFiles = explode('|',$exportedFilesVariable->getValue());
|
622 |
+
return $exportedFiles;
|
623 |
+
}
|
624 |
+
private function _logExportedFileInDB($exportedFiles) {
|
625 |
+
$strExportedFiles = implode('|',$exportedFiles);
|
626 |
+
$exportedFilesVariable = $this->_getExportedFilesVariable();
|
627 |
+
if(!isset($exportedFilesVariable))
|
628 |
+
{
|
629 |
+
$exportedFilesVariable = Mage::getModel("pb_pbgsp/variable");
|
630 |
+
$exportedFilesVariable->setName("exportedFiles");
|
631 |
+
}
|
632 |
+
|
633 |
+
$exportedFilesVariable->setValue($strExportedFiles);
|
634 |
+
$exportedFilesVariable->save();
|
635 |
+
}
|
636 |
+
private function _startsWith($haystack, $needle) {
|
637 |
+
// search backwards starting from haystack length characters from the end
|
638 |
+
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
|
639 |
+
}
|
640 |
+
private function _endsWith($haystack, $needle) {
|
641 |
+
// search forward starting from end minus needle length characters
|
642 |
+
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
|
643 |
+
}
|
644 |
+
private function _removeExportedFiles($exportedFiles) {
|
645 |
+
$tmpDir = $this->_getTempDir();
|
646 |
+
foreach($exportedFiles as $exportedFile) {
|
647 |
+
$fileName = $tmpDir . $exportedFile;
|
648 |
+
if(is_dir($fileName))
|
649 |
+
continue;
|
650 |
+
unlink($fileName);
|
651 |
+
$fileName = str_replace(".gpg","",$fileName);//remove unencrypted file
|
652 |
+
if(is_file($fileName))
|
653 |
+
unlink($fileName);
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
|
658 |
+
|
659 |
+
|
660 |
+
|
661 |
+
|
662 |
+
/**
|
663 |
+
* @param Pb_Pbgsp_Model_Catalog_Product $product
|
664 |
+
* @param string $categoryCode
|
665 |
+
*/
|
666 |
+
private function writeProduct($product,$categoryCode,$parentSku,$category)
|
667 |
+
{
|
668 |
+
if ($product->shouldUpload($this->lastDiff)) {
|
669 |
+
array_push($this->productIds,$product->getMageProduct()->getId());
|
670 |
+
// Pb_Pbgsp_Model_Util::log("Product SKU:" . $product->getSKU());
|
671 |
+
$product->writeToFile($this->file,$categoryCode,$parentSku,$category);
|
672 |
+
fflush($this->file);
|
673 |
+
}
|
674 |
+
}
|
675 |
+
|
676 |
+
public static function stripHtml($text) {
|
677 |
+
return preg_replace("/<\s*\/\s*\w\s*.*?>|<\s*br\s*>/",'',preg_replace("/<\s*\w.*?>/", '', $text));
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Loads products without categories and logs them in log file
|
682 |
+
*/
|
683 |
+
public function logProdWithoutCategories() {
|
684 |
+
$productCollection = Mage::getResourceModel('catalog/product_collection')
|
685 |
+
->setStoreId(0)
|
686 |
+
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
|
687 |
+
->addAttributeToFilter('category_id', array('null' => true))
|
688 |
+
->addAttributeToSelect('*');
|
689 |
+
|
690 |
+
|
691 |
+
$productCollection->getSelect()->group('product_id')->distinct(true);
|
692 |
+
|
693 |
+
$productCollection->load();
|
694 |
+
$skus = '';
|
695 |
+
foreach($productCollection as $product) {
|
696 |
+
$skus = $skus . $product->getSku() . ",";
|
697 |
+
|
698 |
+
}
|
699 |
+
Pb_Pbgsp_Model_Util::log("Products without categories:" . $skus);
|
700 |
+
}
|
701 |
+
|
702 |
+
/**
|
703 |
+
* @return array
|
704 |
+
*/
|
705 |
+
private function _getSftpCredentials()
|
706 |
+
{
|
707 |
+
$credentials = array(
|
708 |
+
'host' => Pb_Pbgsp_Model_Credentials::getSftpHostname(),
|
709 |
+
"port" => Pb_Pbgsp_Model_Credentials::getSftpPort(),
|
710 |
+
'username' => Pb_Pbgsp_Model_Credentials::getSftpUsername(),
|
711 |
+
'password' => Pb_Pbgsp_Model_Credentials::getSftpPassword(),
|
712 |
+
'timeout' => '10'
|
713 |
+
);
|
714 |
+
return $credentials;
|
715 |
+
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* @param $part
|
719 |
+
*/
|
720 |
+
private function _stripPartFromFileName($part)
|
721 |
+
{
|
722 |
+
if ($part == 2) {
|
723 |
+
//there is only one part remove part1 from filename
|
724 |
+
rename($this->filename, str_replace('_part1', '', $this->filename));
|
725 |
+
}
|
726 |
+
}
|
727 |
+
}
|
728 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Catalog/Product.php
CHANGED
@@ -1,198 +1,204 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
public function
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
public function
|
94 |
-
return utf8_encode($this -> product ->
|
95 |
-
}
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
$
|
120 |
-
$
|
121 |
-
$
|
122 |
-
$
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
$
|
135 |
-
$
|
136 |
-
|
137 |
-
|
138 |
-
$
|
139 |
-
}
|
140 |
-
$string .= "
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
//
|
148 |
-
// '
|
149 |
-
// '
|
150 |
-
// '
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
'','','','','',
|
156 |
-
'',''
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
$
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Catalog/Product.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
/**
|
10 |
+
* Class Pb_Pbgsp_Model_Catalog_Product
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class Pb_Pbgsp_Model_Catalog_Product {
|
14 |
+
/*@var $product Mage_Catalog_Model_Product */
|
15 |
+
protected $product;
|
16 |
+
protected $_productUrl;
|
17 |
+
|
18 |
+
|
19 |
+
public function __construct($product,$url=null) {
|
20 |
+
$id = $product;
|
21 |
+
if (gettype($product) == "object" && get_class($id) == "Mage_Catalog_Model_Product") {
|
22 |
+
$this -> product = $product;
|
23 |
+
}
|
24 |
+
else
|
25 |
+
$this -> product = Mage::getModel('catalog/product') -> load($id);
|
26 |
+
$this->_productUrl = $url;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Created by BigPixel 6/15/2012
|
31 |
+
* @return Mage_Catalog_Model_Product
|
32 |
+
*/
|
33 |
+
public function getMageProduct() {
|
34 |
+
return $this->product;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getSKU() {
|
41 |
+
return $this -> product -> getSku();
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getPrice() {
|
45 |
+
return $this->product->getPrice();
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getUPC() {
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function getURL() {
|
55 |
+
if($this->_productUrl)
|
56 |
+
return $this->_productUrl;
|
57 |
+
return $this -> product -> getProductUrl();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return int
|
62 |
+
* Gets the id of the category that is direct parent of the product
|
63 |
+
*/
|
64 |
+
public function getCategoryCode() {
|
65 |
+
$categories = $this -> product -> getCategoryCollection();
|
66 |
+
|
67 |
+
$maxDepth = -1;
|
68 |
+
$finalCategory = null;
|
69 |
+
foreach ($categories as $category) {
|
70 |
+
$pathComponents = explode("/",$category->getPath());
|
71 |
+
if (count($pathComponents) > $maxDepth) {
|
72 |
+
$finalCategory = $category;
|
73 |
+
$maxDepth = count($pathComponents);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return $finalCategory->getId();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return string
|
81 |
+
*
|
82 |
+
*/
|
83 |
+
public function getCountryOfOrigin() {
|
84 |
+
return $this->product->getCountryOfManufacture(); //added by kamran,1/14/2012
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return string
|
89 |
+
*/
|
90 |
+
public function getDescription() {
|
91 |
+
return utf8_encode($this -> product -> getDescription());
|
92 |
+
}
|
93 |
+
public function getShortDescription() {
|
94 |
+
return utf8_encode($this -> product -> getShortDescription());
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* @return string
|
98 |
+
*/
|
99 |
+
public function getName() {
|
100 |
+
return utf8_encode($this -> product -> getName());
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return flaot
|
105 |
+
*/
|
106 |
+
public function getWeight() {
|
107 |
+
return $this -> product -> getWeight();
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getSize() {
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @param $file
|
115 |
+
* @param $categoryCode
|
116 |
+
* Write this product into the xml file
|
117 |
+
*/
|
118 |
+
public function writeToFile($file,$categoryCode,$parentSku,$category) {
|
119 |
+
/** $categoryCode is passed in method because we don't have categoryCode for child products. BigPixel 6/11/2012 */
|
120 |
+
$name = Pb_Pbgsp_Model_Catalog_File::stripHtml($this -> getName());
|
121 |
+
$name = preg_replace("/[^A-Za-z0-9 ,.\-\+=;:\\(){}\[\]@?%$#]/", '', $name);
|
122 |
+
$string = "<Commodity>\n";
|
123 |
+
$string .= "<CategoryCode><![CDATA[" . htmlentities($categoryCode) . "]]></CategoryCode>\n";
|
124 |
+
$string .= "<SKU><![CDATA[" . htmlentities($this -> getSKU()) . "]]></SKU>\n";
|
125 |
+
$string .= "<Name><![CDATA[" . htmlentities($name) . "]]></Name>\n";
|
126 |
+
$string .= "<CountryOfOrigin><![CDATA[" . htmlentities(preg_replace("/[^A-Za-z0-9]/",'',$this -> getCountryOfOrigin())) . "]]></CountryOfOrigin>\n"; //added by kamran,1/14/2012
|
127 |
+
$description = Pb_Pbgsp_Model_Catalog_File::stripHtml($this -> getDescription());
|
128 |
+
$description = preg_replace("/[^A-Za-z0-9 ,.\-\+=;:\\(){}\[\]@?%$#]/", '', $description);
|
129 |
+
if (strlen($description) >= 2000) {
|
130 |
+
|
131 |
+
$description = $this -> chopString($description, 1999);
|
132 |
+
}
|
133 |
+
|
134 |
+
$shortDescription = Pb_Pbgsp_Model_Catalog_File::stripHtml($this -> getShortDescription());
|
135 |
+
$shortDescription = preg_replace("/[^A-Za-z0-9 ,.\-\+=;:\\(){}\[\]@?%$#]/", '', $shortDescription);
|
136 |
+
if (strlen($shortDescription) >= 2000) {
|
137 |
+
|
138 |
+
$shortDescription = $this -> chopString($shortDescription, 1999);
|
139 |
+
}
|
140 |
+
$string .= "<Description><![CDATA[" . $description . "]]></Description>\n";
|
141 |
+
$string .= "<URL><![CDATA[" . htmlentities($this -> getURL()) . "]]></URL>\n";
|
142 |
+
|
143 |
+
if ($this->getWeight() != null) {
|
144 |
+
$string .= "<Size><Weight><![CDATA[" . $this -> getWeight() . "]]></Weight><Source><![CDATA[" . Pb_Pbgsp_Model_Credentials::getMerchantCode() . "]]></Source></Size>\n";
|
145 |
+
}
|
146 |
+
$string .= "</Commodity>\n";
|
147 |
+
// fputcsv($this->file,array('MERCHANT_COMMODITY_REF_ID','COMMODITY_NAME_TITLE','SHORT_DESCRIPTION',
|
148 |
+
// 'LONG_DESCRIPTION','RETAILER_ID','COMMODITY_URL','RETAILER_UNIQUE_ID','PCH_CATEGORY_ID',
|
149 |
+
// 'RH_CATEGORY_ID','STANDARD_PRICE','WEIGHT_UNIT','DISTANCE_UNIT','COO','IMAGE_URL','PARENT_SKU',
|
150 |
+
// 'CHILD_SKU','PARCELS_PER_SKU','UPC','UPC_CHECK_DIGIT','GTIN','MPN','ISBN','BRAND','MANUFACTURER',
|
151 |
+
// 'MODEL_NUMBER','MANUFACTURER_STOCK_NUMBER','COMMODITY_CONDITION','COMMODITY_HEIGHT',
|
152 |
+
// 'COMMODITY_WIDTH','COMMODITY_LENGTH','PACKAGE_WEIGHT','PACKAGE_HEIGHT','PACKAGE_WIDTH',
|
153 |
+
// 'PACKAGE_LENGTH','HAZMAT','ORMD','CHEMICAL_INDICATOR','PESTICIDE_INDICATOR','AEROSOL_INDICATOR',
|
154 |
+
// 'RPPC_INDICATOR','BATTERY_TYPE','NON_SPILLABLE_BATTERY','FUEL_RESTRICTION','SHIP_ALONE',
|
155 |
+
// 'RH_CATEGORY_ID_PATH','RH_CATEGORY_NAME_PATH','RH_CATEGORY_URL_PATH','GPC','COMMODITY_WEIGHT',
|
156 |
+
// 'HS_CODE','CURRENCY'));
|
157 |
+
$merchantCode = Pb_Pbgsp_Model_Credentials::getMerchantCode();
|
158 |
+
fputcsv($file,array($this -> getSKU(),$name,$shortDescription,
|
159 |
+
$description,$merchantCode,$this -> getURL(),$merchantCode,'',
|
160 |
+
$categoryCode,$this->getPrice(),'lb','',$this->getCountryOfOrigin(),'','',
|
161 |
+
'','','','','','','','','',
|
162 |
+
'','','','',
|
163 |
+
'','',$this -> getWeight(),'','',
|
164 |
+
'','','','','','',
|
165 |
+
'','','','','',
|
166 |
+
strval($category->getData('id_path')),$category->getData('name_path')
|
167 |
+
//,'','','','',$category->getData('store')->getCurrentCurrencyCode()
|
168 |
+
));
|
169 |
+
//fwrite($file, $string);
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @param $lastDiff
|
174 |
+
* @return bool
|
175 |
+
* Checks whether we need to upload this product or not
|
176 |
+
*/
|
177 |
+
public function shouldUpload($lastDiff) {
|
178 |
+
|
179 |
+
$lastUpload = $this -> product -> getPbPbgspUpload();
|
180 |
+
//Pb_Pbgsp_Model_Util::log('Product '. $this -> getSKU() . ' lastUpload='. $lastUpload . ' '. date('m-d-Y H:i:s',$lastUpload));
|
181 |
+
if (!$lastUpload) {
|
182 |
+
// First upload.
|
183 |
+
return true;
|
184 |
+
} else if ($lastDiff <= $lastUpload - (30 * 60)) {
|
185 |
+
// Added after the last diff
|
186 |
+
return true;
|
187 |
+
} else {
|
188 |
+
return false;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
public function chopString($str, $len) {
|
193 |
+
$end = $len;
|
194 |
+
$lastFour = substr($str,$end - strlen("&"),strlen("&"));
|
195 |
+
$pos = strpos($lastFour,"&");
|
196 |
+
if (!($pos === FALSE)) {
|
197 |
+
$end = $end - strlen("&") + $pos;
|
198 |
+
}
|
199 |
+
$ret = substr($str,0,$end);
|
200 |
+
return $ret;
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Credentials.php
CHANGED
@@ -1,114 +1,128 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
public static function
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
return self::
|
41 |
-
}
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
public static function
|
99 |
-
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
}
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Credentials.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Credentials {
|
10 |
+
|
11 |
+
public static function decrypt($string) {
|
12 |
+
if (!empty($string)) {
|
13 |
+
return Mage::helper('core')->decrypt($string);
|
14 |
+
}
|
15 |
+
return "";
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function getCheckoutUrl() {
|
19 |
+
return Mage::getStoreConfig('carriers/pbgsp/checkout_endpoint');
|
20 |
+
}
|
21 |
+
public static function getAuthorizationUrl() {
|
22 |
+
return Mage::getStoreConfig('carriers/pbgsp/authorization_endpoint');
|
23 |
+
}
|
24 |
+
public static function getOrderMgmtAPIUrl() {
|
25 |
+
return Mage::getStoreConfig('carriers/pbgsp/order_mgmt_api');
|
26 |
+
}
|
27 |
+
public static function getMaxRecordsCount() {
|
28 |
+
return Mage::getStoreConfig('carriers/pbgsp/catalog_size');
|
29 |
+
}
|
30 |
+
public static function getAdminEmail() {
|
31 |
+
return Mage::getStoreConfig('carriers/pbgsp/admin_email');
|
32 |
+
}
|
33 |
+
public static function getCatalogSenderID() {
|
34 |
+
return Mage::getStoreConfig('carriers/pbgsp/catalog_sender_id');
|
35 |
+
}
|
36 |
+
public static function getDeliveryAdjustmentMinDays() {
|
37 |
+
return self::_getIntValue(Mage::getStoreConfig('carriers/pbgsp/delivery_adjustment_min_days'));
|
38 |
+
}
|
39 |
+
public static function getDeliveryAdjustmentMaxDays() {
|
40 |
+
return self::_getIntValue(Mage::getStoreConfig('carriers/pbgsp/delivery_adjustment_max_days'));
|
41 |
+
}
|
42 |
+
public static function getDomesticShippingFee() {
|
43 |
+
return self::_getFloatValue(Mage::getStoreConfig('carriers/pbgsp/domestic_shipping_fee'));
|
44 |
+
}
|
45 |
+
public static function getDomesticShippingOption() {
|
46 |
+
return Mage::getStoreConfig('carriers/pbgsp/domestic_shipping_option');
|
47 |
+
}
|
48 |
+
public static function isASNGenerationEnabled() {
|
49 |
+
return Mage::getStoreConfig('carriers/pbgsp/asn_generation_enabled');
|
50 |
+
}
|
51 |
+
public static function isFreeTaxEnabled() {
|
52 |
+
return Mage::getStoreConfig('carriers/pbgsp/free_tax_enable');
|
53 |
+
}
|
54 |
+
public static function getHandlingFee() {
|
55 |
+
|
56 |
+
return self::_getFloatValue(Mage::getStoreConfig('carriers/pbgsp/handlingfee'));
|
57 |
+
}
|
58 |
+
private static function _getIntValue($value) {
|
59 |
+
$number = 0;
|
60 |
+
|
61 |
+
if(isset($value)) {
|
62 |
+
if(is_numeric($value)) {
|
63 |
+
$number = intval($value);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
return $number;
|
67 |
+
}
|
68 |
+
private static function _getFloatValue($value) {
|
69 |
+
$number = 0;
|
70 |
+
|
71 |
+
if(isset($value)) {
|
72 |
+
if(is_numeric($value)) {
|
73 |
+
$number = floatval($value);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return $number;
|
77 |
+
}
|
78 |
+
public static function getHandlingOption() {
|
79 |
+
return Mage::getStoreConfig('carriers/pbgsp/handlingoption');
|
80 |
+
}
|
81 |
+
/* public static function getWSDL() {
|
82 |
+
if(Mage::getStoreConfig('carriers/pbgsp/environment') == 1) {
|
83 |
+
// Production
|
84 |
+
} else {
|
85 |
+
// Staging
|
86 |
+
return "./app/code/local/Pb/Pbgsp/etc/cpAPI.wsdl.xml";
|
87 |
+
}
|
88 |
+
}*/
|
89 |
+
|
90 |
+
public static function getUsername() {
|
91 |
+
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/apiuser'));
|
92 |
+
}
|
93 |
+
|
94 |
+
public static function getPassword() {
|
95 |
+
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/apipass'));
|
96 |
+
}
|
97 |
+
|
98 |
+
public static function getMerchantCode() {
|
99 |
+
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/merchantcode'));
|
100 |
+
}
|
101 |
+
|
102 |
+
public static function getSftpUsername() {
|
103 |
+
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/ftpuser'));
|
104 |
+
}
|
105 |
+
public static function getSftpPassword() {
|
106 |
+
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/ftppass'));
|
107 |
+
}
|
108 |
+
public static function getSftpHostname() {
|
109 |
+
return Mage::getStoreConfig('carriers/pbgsp/ftphost');
|
110 |
+
}
|
111 |
+
public static function getSftpPort() {
|
112 |
+
return Mage::getStoreConfig('carriers/pbgsp/ftpport');
|
113 |
+
}
|
114 |
+
public static function getSftpCatalogDirectory() {
|
115 |
+
return self::decrypt(Mage::getStoreConfig('carriers/pbgsp/ftpdir'));
|
116 |
+
}
|
117 |
+
public static function isEncryptionEnabled() {
|
118 |
+
return Mage::getStoreConfig('carriers/pbgsp/catalog_encryption_enabled');
|
119 |
+
}
|
120 |
+
public static function getPublicKey() {
|
121 |
+
return Mage::getStoreConfig('carriers/pbgsp/encryption_public_key');
|
122 |
+
}
|
123 |
+
|
124 |
+
public static function getPBID() {
|
125 |
+
return "16061";
|
126 |
+
}
|
127 |
+
}
|
128 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Creditmemo/Duty.php
CHANGED
@@ -1,31 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
$
|
21 |
-
$
|
22 |
-
$
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Creditmemo/Duty.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Creditmemo_Duty extends Mage_Sales_Model_Order_Creditmemo_Total_Tax
|
10 |
+
{
|
11 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
12 |
+
{
|
13 |
+
Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Creditmemo_Duty.collect');
|
14 |
+
$len = strlen("pbgsp_");
|
15 |
+
$order = $creditmemo->getOrder();
|
16 |
+
$shipMethod = $order->getShippingMethod();
|
17 |
+
if (strlen($shipMethod) > $len && substr($shipMethod, 0, $len) == "pbgsp_") {
|
18 |
+
$totalTax = 0;
|
19 |
+
$baseTotalTax = 0;
|
20 |
+
$totalHiddenTax = 0;
|
21 |
+
$baseTotalHiddenTax = 0;
|
22 |
+
if ($order->getTaxAmount()) {
|
23 |
+
$totalTax = $order->getTaxAmount();
|
24 |
+
$baseTotalTax = $totalTax;
|
25 |
+
}
|
26 |
+
$creditmemo->setTaxAmount($totalTax);
|
27 |
+
$creditmemo->setBaseTaxAmount($baseTotalTax);
|
28 |
+
$creditmemo->setHiddenTaxAmount($totalHiddenTax);
|
29 |
+
$creditmemo->setBaseHiddenTaxAmount($baseTotalHiddenTax);
|
30 |
+
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax + $totalHiddenTax);
|
31 |
+
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax + $baseTotalHiddenTax);
|
32 |
+
} else {
|
33 |
+
parent::collect($creditmemo);
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
}
|
app/code/local/Pb/Pbgsp/Model/Handlingoptions.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class Pb_Pbgsp_Model_Handlingoptions {
|
10 |
-
public function toOptionArray()
|
11 |
-
{
|
12 |
-
return array(
|
13 |
-
array('value'=>1, 'label'=>'Per Order'),
|
14 |
-
array('value'=>2, 'label'=>'Per Item'),
|
15 |
-
|
16 |
-
);
|
17 |
-
}
|
18 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Handlingoptions.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Handlingoptions {
|
10 |
+
public function toOptionArray()
|
11 |
+
{
|
12 |
+
return array(
|
13 |
+
array('value'=>1, 'label'=>'Per Order'),
|
14 |
+
array('value'=>2, 'label'=>'Per Item'),
|
15 |
+
|
16 |
+
);
|
17 |
+
}
|
18 |
}
|
app/code/local/Pb/Pbgsp/Model/Helper.php
CHANGED
@@ -1,11 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Helper.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Helper {
|
10 |
+
public static function displayInfo($var) {
|
11 |
+
echo "<hr/>Class type: ".get_class($var)."<br/>Methods:<br/>";
|
12 |
+
$methods = get_class_methods($var);
|
13 |
+
foreach ($methods as $method) {
|
14 |
+
echo $method."<br/>";
|
15 |
+
}
|
16 |
+
}
|
17 |
+
}
|
18 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Inboundparcel.php
CHANGED
@@ -1,11 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Inboundparcel.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Inboundparcel extends Mage_Core_Model_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('pb_pbgsp/inboundparcel');
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Invoice/Duty.php
CHANGED
@@ -1,32 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
$
|
21 |
-
$
|
22 |
-
$
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Invoice/Duty.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Pb_Pbgsp_Model_Invoice_Duty extends Mage_Sales_Model_Order_Invoice_Total_Tax
|
11 |
+
{
|
12 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
|
13 |
+
{
|
14 |
+
Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Invoice_Duty.collect');
|
15 |
+
$len = strlen("pbgsp_");
|
16 |
+
$order = $invoice->getOrder();
|
17 |
+
$shipMethod = $order->getShippingMethod();
|
18 |
+
if (strlen($shipMethod) > $len && substr($shipMethod, 0, $len) == "pbgsp_") {
|
19 |
+
$totalTax = 0;
|
20 |
+
$baseTotalTax = 0;
|
21 |
+
$totalHiddenTax = 0;
|
22 |
+
$baseTotalHiddenTax = 0;
|
23 |
+
if ($order->getTaxAmount()) {
|
24 |
+
$totalTax = $order->getTaxAmount();
|
25 |
+
$baseTotalTax = $totalTax;
|
26 |
+
}
|
27 |
+
$invoice->setTaxAmount($totalTax);
|
28 |
+
$invoice->setBaseTaxAmount($baseTotalTax);
|
29 |
+
$invoice->setHiddenTaxAmount($totalHiddenTax);
|
30 |
+
$invoice->setBaseHiddenTaxAmount($baseTotalHiddenTax);
|
31 |
+
|
32 |
+
$invoice->setGrandTotal($invoice->getGrandTotal() + $totalTax + $totalHiddenTax);
|
33 |
+
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseTotalTax + $baseTotalHiddenTax);
|
34 |
+
} else {
|
35 |
+
parent::collect($invoice);
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
}
|
app/code/local/Pb/Pbgsp/Model/Messages.php
CHANGED
@@ -1,121 +1,127 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
//
|
11 |
-
//
|
12 |
-
// "
|
13 |
-
//
|
14 |
-
// "
|
15 |
-
//
|
16 |
-
// "
|
17 |
-
//
|
18 |
-
// "
|
19 |
-
//
|
20 |
-
// "
|
21 |
-
//
|
22 |
-
// "
|
23 |
-
//
|
24 |
-
// "
|
25 |
-
//
|
26 |
-
// "
|
27 |
-
//
|
28 |
-
// "
|
29 |
-
//
|
30 |
-
// "
|
31 |
-
//
|
32 |
-
// "
|
33 |
-
//
|
34 |
-
// "
|
35 |
-
//
|
36 |
-
// "
|
37 |
-
//
|
38 |
-
// "
|
39 |
-
//
|
40 |
-
// "
|
41 |
-
//
|
42 |
-
// "
|
43 |
-
//
|
44 |
-
// "
|
45 |
-
//
|
46 |
-
// "
|
47 |
-
//
|
48 |
-
// "
|
49 |
-
//
|
50 |
-
// "
|
51 |
-
//
|
52 |
-
// "
|
53 |
-
//
|
54 |
-
// "
|
55 |
-
//
|
56 |
-
// "
|
57 |
-
//
|
58 |
-
// "
|
59 |
-
//
|
60 |
-
// "
|
61 |
-
//
|
62 |
-
// "
|
63 |
-
//
|
64 |
-
// "
|
65 |
-
//
|
66 |
-
// "
|
67 |
-
//
|
68 |
-
// "
|
69 |
-
//
|
70 |
-
// "
|
71 |
-
//
|
72 |
-
// "
|
73 |
-
//
|
74 |
-
// "
|
75 |
-
//
|
76 |
-
// "
|
77 |
-
//
|
78 |
-
// "
|
79 |
-
//
|
80 |
-
// "
|
81 |
-
//
|
82 |
-
// "
|
83 |
-
//
|
84 |
-
// "
|
85 |
-
//
|
86 |
-
// "
|
87 |
-
//
|
88 |
-
// "
|
89 |
-
//
|
90 |
-
// "
|
91 |
-
//
|
92 |
-
// "
|
93 |
-
//
|
94 |
-
// "
|
95 |
-
//
|
96 |
-
// "
|
97 |
-
//
|
98 |
-
// "
|
99 |
-
//
|
100 |
-
// "
|
101 |
-
//
|
102 |
-
// "
|
103 |
-
//
|
104 |
-
// "
|
105 |
-
//
|
106 |
-
//
|
107 |
-
|
108 |
-
//
|
109 |
-
//
|
110 |
-
//
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Messages.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Messages {
|
10 |
+
// protected $messages = array(
|
11 |
+
// 101 => array(
|
12 |
+
// "code" => "INTERNAL_ERROR",
|
13 |
+
// "original" => "Internal Error.",
|
14 |
+
// "display" => "Error 101: An error has occurred. Please contact the merchant for assistance."),
|
15 |
+
// 102 => array(
|
16 |
+
// "code" => "NULL_VALUE",
|
17 |
+
// "original" => "Null value.",
|
18 |
+
// "display" => "A required field is missing, please select a Province."),
|
19 |
+
// 103 => array(
|
20 |
+
// "code" => "INVALID_VALUE",
|
21 |
+
// "original" => "Invalid value.",
|
22 |
+
// "display" => "Error 103: An invalid value for a required non-null field has been submitted"),
|
23 |
+
// 105 => array(
|
24 |
+
// "code" => "MISSING_RECORD",
|
25 |
+
// "original" => "Missing record.",
|
26 |
+
// "display" => "Error 105: One or more items have not yet been prepared for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
27 |
+
// 108 => array(
|
28 |
+
// "code" => "CLASSIFICATION_NOT_AVAILABLE",
|
29 |
+
// "original" => "Item cannot be classified.",
|
30 |
+
// "display" => "Error 108: One or more items have not yet been prepared for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
31 |
+
// 109 => array(
|
32 |
+
// "code" => "QUANTITY_EXCEEDED",
|
33 |
+
// "original" => "Quantity exceeded.",
|
34 |
+
// "display" => "Error 109: The quantity of one or more selected items exceeds international shipping regulations. <IDENTIFY SKU>"),
|
35 |
+
// 131 => array(
|
36 |
+
// "code" => "SHIPPING_METHODS_NOT_AVAILABLE ",
|
37 |
+
// "original" => "No shipping methods available. ",
|
38 |
+
// "display" => "Error 131: No international shipping methods are available for the selected items."),
|
39 |
+
// 139 => array(
|
40 |
+
// "code" => "DUTY_NOT_AVAILABLE",
|
41 |
+
// "original" => "Duties are not available.",
|
42 |
+
// "display" => "Error 139: International duty items are not available for one or more items. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
43 |
+
// 141 => array(
|
44 |
+
// "code" => "MISSING_DUTIABLE_PRICE",
|
45 |
+
// "original" => "Missing dutiable price.",
|
46 |
+
// "display" => "Error 141: One or more selected items do not have a valid dutiable price for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
47 |
+
// 142 => array(
|
48 |
+
// "code" => "INVALID_DUTIABLE_PRICE",
|
49 |
+
// "original" => "Invalid dutiable price.",
|
50 |
+
// "display" => "Error 142: One or more selected items do not have a valid dutiable price for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
51 |
+
// 144 => array(
|
52 |
+
// "code" => "INVALID_SALE_PRICE",
|
53 |
+
// "original" => "Invalid sale price.",
|
54 |
+
// "display" => "Error 144: One or more items do not have a valid sale price for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
55 |
+
// 145 => array(
|
56 |
+
// "code" => "TAX_NOT_AVAILABLE",
|
57 |
+
// "original" => "Fail to retrieve taxes.",
|
58 |
+
// "display" => "Error 145: One or more items does not have tax information for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
59 |
+
// 154 => array(
|
60 |
+
// "code" => "SHIPPING_CANNOT_BE_CALCULATED",
|
61 |
+
// "original" => "Shipping cannot be calculated.",
|
62 |
+
// "display" => "Error 154: The selected address is not valid for international delivery. Please note that FedEx cannot deliver to PO Boxes."),
|
63 |
+
// 155 => array(
|
64 |
+
// "code" => "SHIPPING_TARIFF_NOT_FOUND",
|
65 |
+
// "original" => "Shipping tariff not found.",
|
66 |
+
// "display" => "Error 155: The current basket of items exceeds international shipping guidelines. Please remove some items and try again."),
|
67 |
+
// 161 => array(
|
68 |
+
// "code" => "QUANTITY_SHIPPING_RESTRICTION",
|
69 |
+
// "original" => "HS quantity shipping restriction.",
|
70 |
+
// "display" => "Error 161: One or more items is restricted from international sale to the selected destination. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
71 |
+
// 162 => array(
|
72 |
+
// "code" => "QUANTITY_SHIPPING_RESTRICTION",
|
73 |
+
// "original" => "HS quantity shipping restriction.",
|
74 |
+
// "display" => "Error 161: One or more items exceed maximum value guidelines for international sale to the selected destination. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
75 |
+
// 168 => array(
|
76 |
+
// "code" => "SHIPPING_TARIFF_NOT_AVAILABLE",
|
77 |
+
// "original" => "The weight of the item is exceeding the maximum accepted by tariffs.",
|
78 |
+
// "display" => "Error 168: The weight of the basket exceeds international shipping guidelines. Please remove one or more items and try again."),
|
79 |
+
// 174 => array(
|
80 |
+
// "code" => "SHIPPING_SIZE_RESTRICTIONS",
|
81 |
+
// "original" => "Item (commodity or merchant box) didn’t pass shipping size restrictions",
|
82 |
+
// "display" => "Error 174: One or more selected items exceed dimensional limits for international sale. Please remove the item(s) from your basket and try again. <IDENTIFY SKU>"),
|
83 |
+
// 175 => array(
|
84 |
+
// "code" => "INVALID_PROVINCE_POSTALCODE_PAIR",
|
85 |
+
// "original" => "Canada address validation failed (postal code does not match the province).",
|
86 |
+
// "display" => "Error 175: The postal code and province entered do not match. Please check the postal code and province to ensure that they are entered correctly and try again."),
|
87 |
+
// 176 => array(
|
88 |
+
// "code" => "INVALID_POSTALCODE_FORMAT",
|
89 |
+
// "original" => "Invalid Canadian Postal Code format (should be ldldld, where l=letter and d=digit).",
|
90 |
+
// "display" => "Error 176: The postal code entered is invalid. Please check the postal code and try again."),
|
91 |
+
// 177 => array(
|
92 |
+
// "code" => "SHIPPING_VALUE_RESTRICTIONS",
|
93 |
+
// "original" => "The order value exceeds Shipping Value Restrictions.",
|
94 |
+
// "display" => "Error 177: The basket total exceeds maximum order value guidelines for international sale. Please remove items from the basket and try again."),
|
95 |
+
// 1001 => array(
|
96 |
+
// "code" => "LICENSE",
|
97 |
+
// "original" => "Item is restricted for shipping due to license requirements.",
|
98 |
+
// "display" => "Error 1001: One or more items is license restricted for international sale. Please remove the item(s) and try again. <IDENTIFY SKU>"),
|
99 |
+
// 1002 => array(
|
100 |
+
// "code" => "SIZE",
|
101 |
+
// "original" => "Item is restricted for shipping due to its size.",
|
102 |
+
// "display" => "Error 1002: One or more items exceed size limits for international sale. Please remove the item(s) and try again. <IDENTIFY SKU>"),
|
103 |
+
// 1003 => array(
|
104 |
+
// "code" => "PROHIBITED",
|
105 |
+
// "original" => "Item is restricted for shipping.",
|
106 |
+
// "display" => "Error 1003: One or more items is restricted for international sale. Please remove the item(s) and try again. <IDENTIFY SKU>"),
|
107 |
+
// 1004 => array(
|
108 |
+
// "code" => "CARRIER",
|
109 |
+
// "original" => "Item is restricted for shipping due to a carrier restriction. The logistics carrier will not ship this product ",
|
110 |
+
// "display" => "Error 1004: One or more items is restricted for international sale. Please remove the item(s) and try again. <IDENTIFY SKU>"),
|
111 |
+
// );
|
112 |
+
//
|
113 |
+
public function getDisplayMessage($code,$message) {
|
114 |
+
// if (array_key_exists($code,$this->messages)) {
|
115 |
+
// return $this->messages[$code]["display"];
|
116 |
+
// }
|
117 |
+
|
118 |
+
// moved to config
|
119 |
+
|
120 |
+
$config_data = Mage::getStoreConfig('carriers/pbgsp/error_messages');
|
121 |
+
|
122 |
+
if(isset($config_data["_$code"]['display']))
|
123 |
+
return $config_data["_$code"]['display'];
|
124 |
+
|
125 |
+
return $message;
|
126 |
+
}
|
127 |
+
}
|
app/code/local/Pb/Pbgsp/Model/Mysql4/Inboundparcel.php
CHANGED
@@ -1,9 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Mysql4/Inboundparcel.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Mysql4_Inboundparcel extends Mage_Core_Model_Mysql4_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('pb_pbgsp/inboundparcel', 'inbound_parcel_id');
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Mysql4/Inboundparcel/Collection.php
CHANGED
@@ -1,8 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Mysql4/Inboundparcel/Collection.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Pb_Pbgsp_Model_Mysql4_Inboundparcel_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
11 |
+
public function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('pb_pbgsp/inboundparcel');
|
14 |
+
}
|
15 |
+
}
|
16 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Mysql4/Ordernumber.php
CHANGED
@@ -1,9 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Mysql4/Ordernumber.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Mysql4_Ordernumber extends Mage_Core_Model_Mysql4_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('pb_pbgsp/ordernumber', 'ordernumber_id');
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Mysql4/Ordernumber/Collection.php
CHANGED
@@ -1,8 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Mysql4/Ordernumber/Collection.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Mysql4_Ordernumber_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('pb_pbgsp/ordernumber');
|
13 |
+
}
|
14 |
+
}
|
15 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Mysql4/Variable.php
CHANGED
@@ -1,9 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Mysql4/Variable.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Mysql4_Variable extends Mage_Core_Model_Mysql4_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('pb_pbgsp/variable', 'variable_id');
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Mysql4/Variable/Collection.php
CHANGED
@@ -1,8 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Mysql4/Variable/Collection.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Mysql4_Variable_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('pb_pbgsp/variable');
|
13 |
+
}
|
14 |
+
}
|
15 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Observer.php
CHANGED
@@ -1,318 +1,340 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
$
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
//
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
$
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
$
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
if(
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
$
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
$
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
$
|
271 |
-
if(
|
272 |
-
$
|
273 |
-
|
274 |
-
|
275 |
-
$
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
//
|
285 |
-
//
|
286 |
-
//
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
}
|
318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Observer.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Observer {
|
10 |
+
const MODULE_NAME = 'Pb_Pbgsp';
|
11 |
+
public function __construct() {
|
12 |
+
}
|
13 |
+
|
14 |
+
public function isPbOrder($address) {
|
15 |
+
$shipMethod = $address->getShippingMethod();
|
16 |
+
$len = strlen("pbgsp_");
|
17 |
+
if (strlen($shipMethod) > $len && substr($shipMethod,0,$len) == "pbgsp_") {
|
18 |
+
return true;
|
19 |
+
}
|
20 |
+
Pb_Pbgsp_Model_Util::log("Shipping method". $shipMethod);
|
21 |
+
return false;
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
public function productLoadAfter($observer) {
|
26 |
+
$event = $observer->getEvent();
|
27 |
+
$product = $event->getProduct();
|
28 |
+
$product->lockAttribute('pb_pbgsp_upload');
|
29 |
+
}
|
30 |
+
public function categoryLoadAfter($observer) {
|
31 |
+
$event = $observer->getEvent();
|
32 |
+
$category = $event->getCategory();
|
33 |
+
$category->lockAttribute('pb_pbgsp_upload');
|
34 |
+
}
|
35 |
+
public function getShipMethod($observer) {
|
36 |
+
Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Observer.getShipMethod');
|
37 |
+
$shipMethod = $observer->getQuote()->getShippingAddress()->getShippingMethod();
|
38 |
+
|
39 |
+
return substr($shipMethod,strlen("pbgsp_"));
|
40 |
+
}
|
41 |
+
|
42 |
+
public function generateInboundParcelPreAdvice($observer) {
|
43 |
+
|
44 |
+
if(Pb_Pbgsp_Model_Credentials::isASNGenerationEnabled() == '1') {
|
45 |
+
try {
|
46 |
+
$shipment = $observer->getEvent()->getShipment();
|
47 |
+
$order = $shipment->getOrder();
|
48 |
+
/* @var $order Mage_Sales_Model_Order */
|
49 |
+
|
50 |
+
if(!$this->isPbOrder($order))
|
51 |
+
return;
|
52 |
+
//check if ASN already generated or not
|
53 |
+
$parcel = Mage::getModel("pb_pbgsp/inboundparcel")-> getCollection();
|
54 |
+
$parcel -> addFieldToFilter('mage_order_number', $order -> getRealOrderId());
|
55 |
+
if(count($parcel) > 0)
|
56 |
+
return;
|
57 |
+
Pb_Pbgsp_Model_Util::log("Generting ASN.");
|
58 |
+
$clearPathOrders = Mage::getModel("pb_pbgsp/ordernumber")-> getCollection();
|
59 |
+
$clearPathOrders -> addFieldToFilter('mage_order_number', $order -> getRealOrderId());
|
60 |
+
foreach ($clearPathOrders as $cpOrder) {
|
61 |
+
$cpOrderNumber = $cpOrder -> getCpOrderNumber();
|
62 |
+
$tracks = array();
|
63 |
+
$items = array();
|
64 |
+
foreach($shipment->getTracksCollection() as $track) {
|
65 |
+
$tracks[] = $track;
|
66 |
+
}
|
67 |
+
foreach($shipment->getItemsCollection() as $item) {
|
68 |
+
|
69 |
+
$items[] = $item;
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
$parcelResponse = Pb_Pbgsp_Model_Api::generateInboundParcelNumber($shipment,$items,$order -> getRealOrderId(),$cpOrderNumber);
|
74 |
+
if(array_key_exists('errors',$parcelResponse)) {
|
75 |
+
Pb_Pbgsp_Model_Util::log("Error generating inbound parcel");
|
76 |
+
Pb_Pbgsp_Model_Util::log($parcelResponse);
|
77 |
+
}
|
78 |
+
else {
|
79 |
+
$cpParcel = Mage::getModel('pb_pbgsp/inboundparcel');
|
80 |
+
$cpParcel->setInboundParcel($parcelResponse['parcelIdentifier']);
|
81 |
+
$cpParcel->setMageOrderNumber( $order->getRealOrderId());
|
82 |
+
$cpParcel->setPbOrderNumber( $cpOrderNumber);
|
83 |
+
$cpParcel->save();
|
84 |
+
Pb_Pbgsp_Model_Util::log('Inbound Parcel Number Saved');
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
}
|
91 |
+
catch(Exception $e) {
|
92 |
+
Pb_Pbgsp_Model_Util::log("Error creating inbound parcel. ");
|
93 |
+
Pb_Pbgsp_Model_Util::logException($e);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
public function createPbOrder($observer) {
|
99 |
+
// Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Observer.createPbOrder');
|
100 |
+
Mage::getSingleton("customer/session")->setPbDutyAndTax(0);
|
101 |
+
$mageOrderNumber = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
102 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($mageOrderNumber);
|
103 |
+
Pb_Pbgsp_Model_Util::log(" createPbOrder");
|
104 |
+
if ($this->isPbOrder($order)) {
|
105 |
+
$orderNumber = Mage::getSingleton("customer/session")->getPbOrderNumber();
|
106 |
+
|
107 |
+
// Save in DB
|
108 |
+
|
109 |
+
$orderNumber->setMageOrderNumber($mageOrderNumber);
|
110 |
+
//$orderNumber->setCpOrderNumber($cpOrderNumber);
|
111 |
+
Pb_Pbgsp_Model_Util::log($orderNumber->getHubId());
|
112 |
+
Pb_Pbgsp_Model_Util::log($orderNumber->getHubCountry());
|
113 |
+
$orderNumber->setConfirmed(false);
|
114 |
+
$orderNumber->setReferenced(false);
|
115 |
+
$orderNumber->save();
|
116 |
+
Pb_Pbgsp_Model_Util::log("calling PB confirm order for $mageOrderNumber");
|
117 |
+
if (Pb_Pbgsp_Model_Api::confirmOrder($orderNumber->getCpOrderNumber(),$order)) {
|
118 |
+
$orderNumber->setConfirmed(true);
|
119 |
+
$orderNumber->setReferenced(true);
|
120 |
+
$orderNumber->save();
|
121 |
+
Pb_Pbgsp_Model_Util::log(" $mageOrderNumber order is confirmed in PB");
|
122 |
+
}
|
123 |
+
// if (Pb_Pbgsp_Model_Api::setOrderReference($cpOrderNumber,$mageOrderNumber)) {
|
124 |
+
// $orderNumber->setReferenced(true);
|
125 |
+
// $orderNumber->save();
|
126 |
+
// }
|
127 |
+
}
|
128 |
+
else {
|
129 |
+
Pb_Pbgsp_Model_Util::log("$mageOrderNumber not PB order");
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
public function saveShippingMethod($observer) {
|
135 |
+
// Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Observer.saveShippingMethod');
|
136 |
+
//TODO: If anything fails here I need to fail the checkout process.
|
137 |
+
$address = $observer->getQuote()->getShippingAddress();
|
138 |
+
if ($this->isPbOrder($address)) {
|
139 |
+
Pb_Pbgsp_Model_Util::log(" PB order");
|
140 |
+
$items = Mage::getSingleton('checkout/cart')->getItems();
|
141 |
+
$shipMethod = $this->getShipMethod($observer);
|
142 |
+
$order = Pb_Pbgsp_Model_Api::createOrder($items,$shipMethod,$address);
|
143 |
+
if (!$order) {
|
144 |
+
Mage::throwException("Unable to create Pb order.");
|
145 |
+
}
|
146 |
+
|
147 |
+
$tax = $order['order']['totalImportation']['total']['value'];
|
148 |
+
if(Pb_Pbgsp_Model_Credentials::isFreeTaxEnabled())
|
149 |
+
$tax = 0;
|
150 |
+
Mage::getSingleton("customer/session")->setPbDutyAndTax($tax);
|
151 |
+
|
152 |
+
$orderNumber = Mage::getModel("pb_pbgsp/ordernumber");
|
153 |
+
|
154 |
+
$orderNumber->setCpOrderNumber($order["orderId"]);
|
155 |
+
$orderNumber->setHubId($order["shipToHub"]['hubId']);
|
156 |
+
$orderNumber->setHubStreet1($order["shipToHub"]['hubAddress']['street1']);
|
157 |
+
$orderNumber->setHubStreet2($order["shipToHub"]['hubAddress']['street2']);
|
158 |
+
$orderNumber->setHubProvinceOrState($order["shipToHub"]['hubAddress']['provinceOrState']);
|
159 |
+
$orderNumber->setHubCountry($order["shipToHub"]['hubAddress']['country']);
|
160 |
+
$orderNumber->setHubPostalCode($order["shipToHub"]['hubAddress']['postalOrZipCode']);
|
161 |
+
|
162 |
+
Mage::getSingleton("customer/session")->setPbOrderNumber($orderNumber);
|
163 |
+
} else {
|
164 |
+
Pb_Pbgsp_Model_Util::log(" not clearpath order");
|
165 |
+
Mage::getSingleton("customer/session")->setPbDutyAndTax(false);
|
166 |
+
Mage::getSingleton("customer/session")->setPbOrderNumber(false);
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
public function addDutiesOnEstimation($observer){
|
171 |
+
//Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Observer.addDutiesOnEstimation');
|
172 |
+
Mage::getSingleton("customer/session")->setPbDutyAndTax(false);//Added by BigPixel to clear previous values, 10/20/2013
|
173 |
+
$clearPathMethods = Mage::getSingleton('checkout/session')->getPbMethods();
|
174 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
175 |
+
$selectedMethod = null;
|
176 |
+
if($quote->getShippingAddress()){
|
177 |
+
$selectedMethod = $quote->getShippingAddress()->getShippingMethod();
|
178 |
+
}
|
179 |
+
|
180 |
+
if($selectedMethod){
|
181 |
+
$selectedMethod = preg_replace('/pbgsp_/', '',$selectedMethod);
|
182 |
+
foreach($clearPathMethods as $clearPathMethod){
|
183 |
+
Pb_Pbgsp_Model_Util::log('addDutiesOnEstimation method'.$clearPathMethod->getMethod().' and tax'.$clearPathMethod->getTax());
|
184 |
+
if($clearPathMethod->getMethod() == $selectedMethod){
|
185 |
+
Mage::getSingleton("customer/session")->setPbDutyAndTax($clearPathMethod->getTax());
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
public function modifyOrderView($observer = NULL) {
|
192 |
+
|
193 |
+
//return;
|
194 |
+
if (!$observer) {
|
195 |
+
return;
|
196 |
+
}
|
197 |
+
if (Mage::getStoreConfig('advanced/modules_disable_output/'.self::MODULE_NAME))
|
198 |
+
return;
|
199 |
+
$transport = $observer->getEvent()->getTransport();
|
200 |
+
$layoutName = $observer->getEvent()->getBlock()->getNameInLayout();
|
201 |
+
if ('order_info' == $layoutName) {
|
202 |
+
|
203 |
+
if (!Mage::getStoreConfig('advanced/modules_disable_output/'.self::MODULE_NAME)) {
|
204 |
+
|
205 |
+
|
206 |
+
$cpOrderNumber = $this->_getCpOrderNumber($observer->getEvent()->getBlock()->getOrder());
|
207 |
+
if($cpOrderNumber) {
|
208 |
+
$html = "<div class='entry-edit'>
|
209 |
+
<div class='entry-edit-head'>
|
210 |
+
<h4 class='icon-head '>Pitney Bowes Shipments</h4>
|
211 |
+
</div>
|
212 |
+
<fieldset>
|
213 |
+
<strong>PB Order Number</strong>
|
214 |
+
<span>".$cpOrderNumber->getCpOrderNumber()."</span><br/>
|
215 |
+
<strong>Hub ID</strong>
|
216 |
+
<span>".$cpOrderNumber->getHubId()."</span><br/>
|
217 |
+
<strong>Hub Street 1</strong>
|
218 |
+
<span>".$cpOrderNumber->getHubStreet1()."</span><br/>
|
219 |
+
<strong>Hub Street 2</strong>
|
220 |
+
<span>".$cpOrderNumber->getHubStreet2()."</span><br/>
|
221 |
+
<strong>Postal Code</strong>
|
222 |
+
<span>".$cpOrderNumber->getHubPostalCode()."</span><br/>
|
223 |
+
<strong>Hub Province/State</strong>
|
224 |
+
<span>".$cpOrderNumber->getHubProvinceOrState()."</span><br/>
|
225 |
+
<strong>Hub Country</strong>
|
226 |
+
<span>".$cpOrderNumber->getHubCountry()."</span><br/>
|
227 |
+
</fieldset>
|
228 |
+
</div>";
|
229 |
+
$transport['html'] = $transport['html'] . $html;
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
}
|
234 |
+
}
|
235 |
+
else if('email/order/shipment/track.phtml' == $observer->getEvent()->getBlock()->getTemplate()) {
|
236 |
+
if(!Mage::getStoreConfig('carriers/pbgsp/trackinglink'))
|
237 |
+
return;
|
238 |
+
|
239 |
+
$cpord = $this->_getCPORD($observer->getEvent()->getBlock()->getOrder());
|
240 |
+
if($cpord) {
|
241 |
+
$staging = 0;
|
242 |
+
if(strpos(Pb_Pbgsp_Model_Credentials::getCheckoutUrl(),'cpsandbox') >=0)
|
243 |
+
$staging = 1;
|
244 |
+
$transport['html'] = "<a href='http://tracking.ecommerce.pb.com/track/$cpord?staging=$staging'>Track your order</a>";
|
245 |
+
}
|
246 |
+
|
247 |
+
}
|
248 |
+
else if('shipping.tracking.popup' == $layoutName) {
|
249 |
+
if(!Mage::getStoreConfig('carriers/pbgsp/trackinglink'))
|
250 |
+
return;
|
251 |
+
|
252 |
+
$helper = Mage::helper('shipping');
|
253 |
+
$data = $helper->decodeTrackingHash($observer->getEvent()->getBlock()->getRequest()->getParam('hash'));
|
254 |
+
|
255 |
+
$orderId = null;
|
256 |
+
if($data['key'] == 'order_id')
|
257 |
+
$orderId = $data['id'];
|
258 |
+
else if($data['key'] == 'ship_id') {
|
259 |
+
/* @var $model Mage_Sales_Model_Order_Shipment */
|
260 |
+
$model = Mage::getModel('sales/order_shipment');
|
261 |
+
$ship = $model->load($data['id']);
|
262 |
+
$orderId = $model->getOrderId();
|
263 |
+
}
|
264 |
+
else if($data['key'] == 'track_id') {
|
265 |
+
$track = Mage::getModel('sales/order_shipment_track')->load($data['id']);
|
266 |
+
$orderId = $track->getOrderId();
|
267 |
+
}
|
268 |
+
if(!$orderId)
|
269 |
+
return;
|
270 |
+
$cpord = $this->_getCPORD(Mage::getModel('sales/order')->load($orderId));
|
271 |
+
if($cpord) {
|
272 |
+
$staging = 0;
|
273 |
+
if(strpos(Pb_Pbgsp_Model_Credentials::getCheckoutUrl(),'cpsandbox') >=0)
|
274 |
+
$staging = 1;
|
275 |
+
$script = "<script lang='javascript'>
|
276 |
+
window.location = 'http://tracking.ecommerce.pb.com/track/$cpord?staging=$staging';
|
277 |
+
</script>
|
278 |
+
";
|
279 |
+
$transport['html'] = $script;
|
280 |
+
}
|
281 |
+
|
282 |
+
}
|
283 |
+
else
|
284 |
+
// if( 'checkout.onepage.review' == $layoutName
|
285 |
+
// || 'checkout.onepage.review.info.totals' == $layoutName
|
286 |
+
// || 'checkout.cart.totals' == $layoutName)
|
287 |
+
{
|
288 |
+
//replace "Shipping & Handling" to "Transportation Charges" and "Duty & Taxes" to "Importation Charges"
|
289 |
+
$html = $transport['html'];
|
290 |
+
$pbTitle = Mage::getStoreConfig('carriers/pbgsp/title');
|
291 |
+
if(strpos($html,$pbTitle) !== false) {
|
292 |
+
$html = str_replace("Shipping & Handling","Transportation Charges",$html);
|
293 |
+
$html = str_replace("Shipping & Handling","Transportation Charges",$html);
|
294 |
+
$html = str_replace("Duty & Taxes","Importation Charges",$html);
|
295 |
+
$html = str_replace("Duty & Taxes","Importation Charges",$html);
|
296 |
+
$transport['html'] = $html;
|
297 |
+
}
|
298 |
+
|
299 |
+
}
|
300 |
+
// else {
|
301 |
+
//
|
302 |
+
// }
|
303 |
+
// else {
|
304 |
+
// $html = $transport['html'];
|
305 |
+
// if(strpos('Shipping & Handling',$html) >= 0)
|
306 |
+
// Pb_Pbgsp_Model_Util::log("Found in $layoutName");
|
307 |
+
// }
|
308 |
+
|
309 |
+
return $this;
|
310 |
+
}
|
311 |
+
private function _getCPORD($order)
|
312 |
+
{
|
313 |
+
if($order) {
|
314 |
+
$cpOrder = $this->_getCpOrderNumber($order);
|
315 |
+
if($cpOrder) {
|
316 |
+
return $cpOrder -> getCpOrderNumber();
|
317 |
+
}
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
return false;
|
322 |
+
}
|
323 |
+
private function _getCpOrderNumber($order)
|
324 |
+
{
|
325 |
+
if($order) {
|
326 |
+
// $clearPathOrders = Mage::getModel("pb_pbgsp/ordernumber")-> getCollection();
|
327 |
+
//
|
328 |
+
// $clearPathOrders -> addFieldToFilter('mage_order_number', $order -> getRealOrderId());
|
329 |
+
// foreach ($clearPathOrders as $cpOrder) {
|
330 |
+
// return $cpOrder ;
|
331 |
+
//
|
332 |
+
// }
|
333 |
+
$cpOrder = Mage::getModel("pb_pbgsp/ordernumber")->load($order -> getRealOrderId(),'mage_order_number');
|
334 |
+
return $cpOrder;
|
335 |
+
}
|
336 |
+
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
}
|
340 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Ordernumber.php
CHANGED
@@ -1,11 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Ordernumber.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Ordernumber extends Mage_Core_Model_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('pb_pbgsp/ordernumber');
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Pdf/Tax.php
CHANGED
@@ -1,14 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Pdf/Tax.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Pb_Pbgsp_Model_Pdf_Tax extends Mage_Tax_Model_Sales_Pdf_Tax {
|
11 |
+
public function getTitle() {
|
12 |
+
$shipMethod = $this->getOrder()->getShippingMethod();
|
13 |
+
$len = strlen("pbgsp_");
|
14 |
+
if (strlen($shipMethod) > $len && substr($shipMethod,0,$len) == "pbgsp_") {
|
15 |
+
return "Importation Charges";
|
16 |
+
}
|
17 |
+
return parent::getTitle();
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Quote/Duty.php
CHANGED
@@ -1,76 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product: Pb_Pbgsp (1.0.0)
|
5 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
6 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
7 |
+
* File: app/code/local/Pb/Pbgsp/Model/Quote/Duty.php
|
8 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Pb_Pbgsp_Model_Quote_Duty extends Mage_Tax_Model_Sales_Total_Quote_Tax
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Discount calculation object
|
15 |
+
*
|
16 |
+
* @var Mage_SalesRule_Model_Validator
|
17 |
+
*/
|
18 |
+
protected $dutyCalculated = false;
|
19 |
+
protected $dutyDisplayed = false;
|
20 |
+
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct();
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getDutyAndTax() {
|
27 |
+
//Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Quote_Duty.getDutyAndTax');
|
28 |
+
return Mage::getSingleton("customer/session")->getPbDutyAndTax();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Collect address discount amount
|
33 |
+
*
|
34 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
35 |
+
* @return Mage_SalesRule_Model_Quote_Discount
|
36 |
+
*/
|
37 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
38 |
+
{
|
39 |
+
//Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Quote_Duty.collect');
|
40 |
+
parent::collect($address);
|
41 |
+
|
42 |
+
if ($this->getDutyAndTax()) {
|
43 |
+
$items = $this->_getAddressItems($address);
|
44 |
+
if (!count($items)) {
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->_addAmount($this->getDutyAndTax());
|
49 |
+
$this->_addBaseAmount($this->getDutyAndTax());
|
50 |
+
}
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add discount total information to address
|
57 |
+
*
|
58 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
59 |
+
* @return Mage_SalesRule_Model_Quote_Discount
|
60 |
+
*/
|
61 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
62 |
+
{
|
63 |
+
//Pb_Pbgsp_Model_Util::log('Pb_Pbgsp_Model_Quote_Duty.fetch');
|
64 |
+
|
65 |
+
if ($this->getDutyAndTax()) {
|
66 |
+
if($this->dutyDisplayed) {
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
$this->dutyDisplayed = true;
|
70 |
+
|
71 |
+
$amount = $address->getTaxAmount();
|
72 |
+
$title = "Duty & Taxes";
|
73 |
+
Pb_Pbgsp_Model_Util::log("Add Duty & Taxes at Duty");
|
74 |
+
$address->addTotal(array(
|
75 |
+
'code' => $this->getCode(),
|
76 |
+
'title' => $title,
|
77 |
+
'value' => $amount
|
78 |
+
));
|
79 |
+
} else {
|
80 |
+
return parent::fetch($address);
|
81 |
+
}
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
}
|
app/code/local/Pb/Pbgsp/Model/Resource/Mysql4/Setup.php
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
11 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Resource/Mysql4/Setup.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Pb_Pbgsp_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
|
11 |
+
|
12 |
}
|
app/code/local/Pb/Pbgsp/Model/Sales/Order/Shipment.php
CHANGED
@@ -1,137 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
$
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
if
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
Mage::getStoreConfig('carriers/pbgsp/
|
74 |
-
|
75 |
-
$
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
//Pb_Pbgsp_Model_Util::log('
|
80 |
-
|
81 |
-
$
|
82 |
-
$
|
83 |
-
|
84 |
-
->
|
85 |
-
->
|
86 |
-
->
|
87 |
-
->
|
88 |
-
->
|
89 |
-
->
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
$
|
94 |
-
|
95 |
-
//Pb_Pbgsp_Model_Util::log(
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
Pb_Pbgsp_Model_Util::log($error->
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
$
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
$
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
137 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Sales/Order/Shipment.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Pb_Pbgsp_Model_Sales_Order_Shipment extends Mage_Sales_Model_Order_Shipment {
|
11 |
+
|
12 |
+
public function sendEmail($notifyCustomer = true, $comment = '')
|
13 |
+
{
|
14 |
+
if(Mage::getStoreConfig('carriers/pbgsp/suppress_domestic_tracking') != '1')
|
15 |
+
return parent::sendEmail($notifyCustomer,$comment);
|
16 |
+
$order = $this->getOrder();
|
17 |
+
$storeId = $order->getStore()->getId();
|
18 |
+
|
19 |
+
if (!Mage::helper('sales')->canSendNewShipmentEmail($storeId)) {
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
// Get the destination email addresses to send copies to
|
23 |
+
$copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
|
24 |
+
$copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId);
|
25 |
+
// Check if at least one recepient is found
|
26 |
+
if (!$notifyCustomer && !$copyTo) {
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
// Start store emulation process
|
31 |
+
$appEmulation = Mage::getSingleton('core/app_emulation');
|
32 |
+
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
|
33 |
+
|
34 |
+
try {
|
35 |
+
// Retrieve specified view block from appropriate design package (depends on emulated store)
|
36 |
+
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
|
37 |
+
->setIsSecureMode(true);
|
38 |
+
$paymentBlock->getMethod()->setStore($storeId);
|
39 |
+
$paymentBlockHtml = $paymentBlock->toHtml();
|
40 |
+
} catch (Exception $exception) {
|
41 |
+
// Stop store emulation process
|
42 |
+
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
|
43 |
+
throw $exception;
|
44 |
+
}
|
45 |
+
|
46 |
+
// Stop store emulation process
|
47 |
+
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
|
48 |
+
|
49 |
+
// Retrieve corresponding email template id and customer name
|
50 |
+
if ($order->getCustomerIsGuest()) {
|
51 |
+
//$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
|
52 |
+
$customerName = $order->getBillingAddress()->getName();
|
53 |
+
} else {
|
54 |
+
//$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
|
55 |
+
$customerName = $order->getCustomerName();
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
$emailTemplateVariables = array(
|
61 |
+
'order' => $order,
|
62 |
+
'shipment' => $this,
|
63 |
+
'comment' => $comment,
|
64 |
+
'billing' => $order->getBillingAddress(),
|
65 |
+
'store' => Mage::app()->getStore($storeId),
|
66 |
+
'payment_html' => $paymentBlockHtml
|
67 |
+
|
68 |
+
|
69 |
+
);
|
70 |
+
$emailTemplate = Mage::getModel('core/email_template');
|
71 |
+
// ->loadDefault('pbgsp_shipment_new');
|
72 |
+
$emailTemplate = $this->_setTemplateBodyAndSubject($emailTemplate,
|
73 |
+
Mage::getStoreConfig('carriers/pbgsp/custom_shipment_email_template'),
|
74 |
+
Mage::getStoreConfig('carriers/pbgsp/custom_shipment_email_subject'));
|
75 |
+
$emailTemplate->setSenderEmail(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
|
76 |
+
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
|
77 |
+
//Pb_Pbgsp_Model_Util::log($processedTemplate);
|
78 |
+
//$emailTemplate->send($order->getCustomerEmail(), $customerName,$emailTemplateVariables);
|
79 |
+
//Pb_Pbgsp_Model_Util::log('Email subject'. $emailTemplate->getTemplateSubject());
|
80 |
+
//Pb_Pbgsp_Model_Util::log('Processed Email Subject is'. $emailTemplate->getProcessedTemplateSubject($emailTemplateVariables));
|
81 |
+
$fromName = Mage::getStoreConfig('trans_email/ident_' . Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId) . '/name', $storeId);
|
82 |
+
$fromEmail = Mage::getStoreConfig('trans_email/ident_' . Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId) . '/email', $storeId);
|
83 |
+
$mail = Mage::getModel('core/email')
|
84 |
+
->setToName($customerName)
|
85 |
+
->setToEmail($order->getCustomerEmail())
|
86 |
+
->setBody($processedTemplate)
|
87 |
+
->setSubject($emailTemplate->getProcessedTemplateSubject($emailTemplateVariables))
|
88 |
+
->setFromEmail($fromEmail)
|
89 |
+
->setFromName($fromName)
|
90 |
+
->setType('html');
|
91 |
+
try{
|
92 |
+
|
93 |
+
Pb_Pbgsp_Model_Util::log("Form email $fromEmail from name $fromName");
|
94 |
+
$mail->send();
|
95 |
+
//Pb_Pbgsp_Model_Util::log("Email sent to");
|
96 |
+
//Pb_Pbgsp_Model_Util::log($order->getCustomerEmail());
|
97 |
+
}
|
98 |
+
catch(Exception $error)
|
99 |
+
{
|
100 |
+
Pb_Pbgsp_Model_Util::log("Error sending shipment email". $error->getMessage());
|
101 |
+
Pb_Pbgsp_Model_Util::log($error->getTraceAsString());
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
return $this;
|
106 |
+
}
|
107 |
+
private function _setTemplateBodyAndSubject($template,$body,$subject)
|
108 |
+
{
|
109 |
+
|
110 |
+
$template->setTemplateType( Mage_Core_Model_Template::TYPE_HTML);
|
111 |
+
|
112 |
+
$templateText = $body;
|
113 |
+
$template->setTemplateSubject($subject);
|
114 |
+
|
115 |
+
|
116 |
+
if (preg_match('/<!--@vars\s*((?:.)*?)\s*@-->/us', $templateText, $matches)) {
|
117 |
+
$template->setData('orig_template_variables', str_replace("\n", '', $matches[1]));
|
118 |
+
$templateText = str_replace($matches[0], '', $templateText);
|
119 |
+
}
|
120 |
+
|
121 |
+
if (preg_match('/<!--@styles\s*(.*?)\s*@-->/s', $templateText, $matches)) {
|
122 |
+
$this->setTemplateStyles($matches[1]);
|
123 |
+
$templateText = str_replace($matches[0], '', $templateText);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Remove comment lines
|
128 |
+
*/
|
129 |
+
$templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText);
|
130 |
+
|
131 |
+
$template->setTemplateText($templateText);
|
132 |
+
// $this->setId($templateId);
|
133 |
+
|
134 |
+
return $template;
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
}
|
app/code/local/Pb/Pbgsp/Model/Util.php
CHANGED
@@ -1,23 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
public static function
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
Mage::log($
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Util.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Util {
|
10 |
+
|
11 |
+
const FILE_NAME = 'pbgsp.log';
|
12 |
+
public static function log($message) {
|
13 |
+
if( Mage::getStoreConfig('carriers/pbgsp/separate_log_file'))
|
14 |
+
Mage::log($message,null,self::FILE_NAME);
|
15 |
+
else
|
16 |
+
Mage::log($message);
|
17 |
+
}
|
18 |
+
public static function logException($e) {
|
19 |
+
/* @var Exception $e */
|
20 |
+
if( Mage::getStoreConfig('carriers/pbgsp/separate_log_file')) {
|
21 |
+
Mage::log($e->getMessage(),null,self::FILE_NAME);
|
22 |
+
Mage::log($e->getTraceAsString(),null,self::FILE_NAME);
|
23 |
+
}
|
24 |
+
else
|
25 |
+
Mage::logException($e);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
?>
|
app/code/local/Pb/Pbgsp/Model/Variable.php
CHANGED
@@ -1,11 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/Model/Variable.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
class Pb_Pbgsp_Model_Variable extends Mage_Core_Model_Abstract {
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('pb_pbgsp/variable');
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
?>
|
app/code/local/Pb/Pbgsp/data/pb_pbgsp_setup/data-install-1.0.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-05-06T18:09:31+00:00
|
5 |
+
* Last Modified: 2015-05-06T18:09:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/sql/pbgsp_setup/mysql4-install-1.0.0.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
|
12 |
+
$categories = Mage::getModel('catalog/category')
|
13 |
+
->getCollection();
|
14 |
+
foreach($categories as $category) {
|
15 |
+
$category->setPbPbgspUploadActive(1);
|
16 |
+
$category->save();
|
17 |
+
}
|
18 |
+
|
19 |
+
?>
|
app/code/local/Pb/Pbgsp/etc/config.xml
CHANGED
@@ -1,491 +1,509 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Pb_Pbgsp>
|
5 |
-
<version>1.0.0</version>
|
6 |
-
</Pb_Pbgsp>
|
7 |
-
</modules>
|
8 |
-
<global>
|
9 |
-
<!--<template>-->
|
10 |
-
<!--<email>-->
|
11 |
-
<!--<sales_email_pb_shipment_template>-->
|
12 |
-
<!--<label>Pitney Bowes Custom Shipment Email</label>-->
|
13 |
-
<!--<file>pbgsp_shipment_new.html</file>-->
|
14 |
-
<!--<type>html</type>-->
|
15 |
-
<!--</sales_email_pb_shipment_template>-->
|
16 |
-
<!--</email>-->
|
17 |
-
<!--</template>-->
|
18 |
-
<blocks>
|
19 |
-
<PB_Pbgsp>
|
20 |
-
<class>Pb_Pbgsp_Block</class>
|
21 |
-
</PB_Pbgsp>
|
22 |
-
<sales>
|
23 |
-
<rewrite>
|
24 |
-
<order_totals>Pb_Pbgsp_Block_Sales_Order_Totals</order_totals>
|
25 |
-
<order_invoice_totals>Pb_Pbgsp_Block_Sales_Order_Invoice_Totals</order_invoice_totals>
|
26 |
-
|
27 |
-
</rewrite>
|
28 |
-
</sales>
|
29 |
-
<adminhtml>
|
30 |
-
<rewrite>
|
31 |
-
<sales_order_totals>Pb_Pbgsp_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
|
32 |
-
<sales_order_invoice_totals>Pb_Pbgsp_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
|
33 |
-
|
34 |
-
</rewrite>
|
35 |
-
</adminhtml>
|
36 |
-
<checkout>
|
37 |
-
<rewrite>
|
38 |
-
<onepage_shipping_method_available>Pb_Pbgsp_Block_Checkout_Shipping_Method_Available</onepage_shipping_method_available>
|
39 |
-
</rewrite>
|
40 |
-
</checkout>
|
41 |
-
</blocks>
|
42 |
-
<models>
|
43 |
-
<pb_pbgsp>
|
44 |
-
<class>Pb_Pbgsp_Model</class>
|
45 |
-
<resourceModel>pb_pbgsp_mysql4</resourceModel>
|
46 |
-
</pb_pbgsp>
|
47 |
-
<pb_pbgsp_mysql4>
|
48 |
-
<class>Pb_Pbgsp_Model_Mysql4</class>
|
49 |
-
<entities>
|
50 |
-
<variable>
|
51 |
-
<table>pbgsp_variable</table>
|
52 |
-
</variable>
|
53 |
-
<ordernumber>
|
54 |
-
<table>pbgsp_ordernumber</table>
|
55 |
-
</ordernumber>
|
56 |
-
<inboundparcel>
|
57 |
-
<table>pbgsp_inbound_parcel</table>
|
58 |
-
</inboundparcel>
|
59 |
-
</entities>
|
60 |
-
</pb_pbgsp_mysql4>
|
61 |
-
<sales>
|
62 |
-
<rewrite>
|
63 |
-
<order_invoice_total_tax>Pb_Pbgsp_Model_Invoice_Duty</order_invoice_total_tax>
|
64 |
-
<order_creditmemo_total_tax>Pb_Pbgsp_Model_Creditmemo_Duty</order_creditmemo_total_tax>
|
65 |
-
<order_shipment>Pb_Pbgsp_Model_Sales_Order_Shipment</order_shipment>
|
66 |
-
</rewrite>
|
67 |
-
</sales>
|
68 |
-
</models>
|
69 |
-
<resources>
|
70 |
-
<pbgsp_setup>
|
71 |
-
<setup>
|
72 |
-
<module>Pb_Pbgsp</module>
|
73 |
-
<class>Pb_Pbgsp_Model_Resource_Mysql4_Setup</class>
|
74 |
-
</setup>
|
75 |
-
<connection>
|
76 |
-
<use>core_setup</use>
|
77 |
-
</connection>
|
78 |
-
</pbgsp_setup>
|
79 |
-
<pb_pbgsp_write>
|
80 |
-
<connection>
|
81 |
-
<use>core_write</use>
|
82 |
-
</connection>
|
83 |
-
</pb_pbgsp_write>
|
84 |
-
<pb_pbgsp_read>
|
85 |
-
<connection>
|
86 |
-
<use>core_read</use>
|
87 |
-
</connection>
|
88 |
-
</pb_pbgsp_read>
|
89 |
-
</resources>
|
90 |
-
<events>
|
91 |
-
<!--<checkout_submit_all_after><!– added by Kamran 7/2/2014 –>-->
|
92 |
-
<!--<observers>-->
|
93 |
-
<!--<Pb_Pbgsp_Model_CheckoutSubmitAllAfter>-->
|
94 |
-
<!--<type>model</type>-->
|
95 |
-
<!--<class>pb_pbgsp/observer</class>-->
|
96 |
-
<!--<method>createOrderAdminAfter</method>-->
|
97 |
-
<!--</Pb_Pbgsp_Model_CheckoutSubmitAllAfter>-->
|
98 |
-
<!--</observers>-->
|
99 |
-
<!--</checkout_submit_all_after>-->
|
100 |
-
<core_block_abstract_to_html_after>
|
101 |
-
<observers>
|
102 |
-
<Pb_Pbgsp_Model_OrderView>
|
103 |
-
<type>model</type>
|
104 |
-
<class>pb_pbgsp/observer</class>
|
105 |
-
<method>modifyOrderView</method>
|
106 |
-
</Pb_Pbgsp_Model_OrderView>
|
107 |
-
</observers>
|
108 |
-
</core_block_abstract_to_html_after>
|
109 |
-
<checkout_controller_onepage_save_shipping_method>
|
110 |
-
<observers>
|
111 |
-
<Pb_Pbgsp_Model_SaveShippingOne>
|
112 |
-
<type>model</type>
|
113 |
-
<class>pb_pbgsp/observer</class>
|
114 |
-
<method>saveShippingMethod</method>
|
115 |
-
</Pb_Pbgsp_Model_SaveShippingOne>
|
116 |
-
</observers>
|
117 |
-
</checkout_controller_onepage_save_shipping_method>
|
118 |
-
<checkout_onepage_controller_success_action>
|
119 |
-
<observers>
|
120 |
-
<Pb_Pbgsp_Model_CheckoutCompleteOne>
|
121 |
-
<type>model</type>
|
122 |
-
<class>pb_pbgsp/observer</class>
|
123 |
-
<method>createPbOrder</method>
|
124 |
-
</Pb_Pbgsp_Model_CheckoutCompleteOne>
|
125 |
-
</observers>
|
126 |
-
</checkout_onepage_controller_success_action>
|
127 |
-
<controller_action_postdispatch_checkout_cart_estimateUpdatePost>
|
128 |
-
<observers>
|
129 |
-
<Pb_Pbgsp_Estimated_Shipping>
|
130 |
-
<type>model</type>
|
131 |
-
<class>pb_pbgsp/observer</class>
|
132 |
-
<method>addDutiesOnEstimation</method>
|
133 |
-
</Pb_Pbgsp_Estimated_Shipping>
|
134 |
-
</observers>
|
135 |
-
</controller_action_postdispatch_checkout_cart_estimateUpdatePost>
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
<
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
</
|
234 |
-
<
|
235 |
-
|
236 |
-
<
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
<
|
304 |
-
<
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
<
|
314 |
-
</
|
315 |
-
<
|
316 |
-
<
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
<
|
322 |
-
<display>The
|
323 |
-
</
|
324 |
-
<
|
325 |
-
<display>
|
326 |
-
</
|
327 |
-
<
|
328 |
-
<display>
|
329 |
-
</
|
330 |
-
<
|
331 |
-
<display>
|
332 |
-
</
|
333 |
-
<
|
334 |
-
<display>
|
335 |
-
</
|
336 |
-
<
|
337 |
-
<display>The order
|
338 |
-
</
|
339 |
-
<
|
340 |
-
<display>The
|
341 |
-
</
|
342 |
-
<
|
343 |
-
<display>
|
344 |
-
</
|
345 |
-
<
|
346 |
-
<display>Invalid fields in
|
347 |
-
</
|
348 |
-
<
|
349 |
-
<display>
|
350 |
-
</
|
351 |
-
<
|
352 |
-
<display>
|
353 |
-
</
|
354 |
-
<
|
355 |
-
<display>
|
356 |
-
</
|
357 |
-
<
|
358 |
-
<display>
|
359 |
-
</
|
360 |
-
<
|
361 |
-
<display>Missing
|
362 |
-
</
|
363 |
-
<
|
364 |
-
<display>
|
365 |
-
</
|
366 |
-
<
|
367 |
-
<display>
|
368 |
-
</
|
369 |
-
<
|
370 |
-
<display>
|
371 |
-
</
|
372 |
-
<
|
373 |
-
<display>
|
374 |
-
</
|
375 |
-
<
|
376 |
-
<display>
|
377 |
-
</
|
378 |
-
<
|
379 |
-
<display>
|
380 |
-
</
|
381 |
-
<
|
382 |
-
<display>
|
383 |
-
</
|
384 |
-
<
|
385 |
-
<display>
|
386 |
-
</
|
387 |
-
<
|
388 |
-
<display>
|
389 |
-
</
|
390 |
-
<
|
391 |
-
<display>
|
392 |
-
</
|
393 |
-
<
|
394 |
-
<display>
|
395 |
-
</
|
396 |
-
<
|
397 |
-
<display>The
|
398 |
-
</
|
399 |
-
<
|
400 |
-
<display>
|
401 |
-
</
|
402 |
-
<
|
403 |
-
<display>
|
404 |
-
</
|
405 |
-
<
|
406 |
-
<display>
|
407 |
-
</
|
408 |
-
<
|
409 |
-
<display>
|
410 |
-
</
|
411 |
-
<
|
412 |
-
<display>
|
413 |
-
</
|
414 |
-
<
|
415 |
-
<display>
|
416 |
-
</
|
417 |
-
<
|
418 |
-
<display>
|
419 |
-
</
|
420 |
-
<
|
421 |
-
<display>
|
422 |
-
</
|
423 |
-
<
|
424 |
-
<display>
|
425 |
-
</
|
426 |
-
<
|
427 |
-
<display>
|
428 |
-
</
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
<
|
471 |
-
<
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
<!--<
|
484 |
-
<!--</
|
485 |
-
<!--</
|
486 |
-
<!--</
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
</
|
491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Pb_Pbgsp>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Pb_Pbgsp>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<!--<template>-->
|
10 |
+
<!--<email>-->
|
11 |
+
<!--<sales_email_pb_shipment_template>-->
|
12 |
+
<!--<label>Pitney Bowes Custom Shipment Email</label>-->
|
13 |
+
<!--<file>pbgsp_shipment_new.html</file>-->
|
14 |
+
<!--<type>html</type>-->
|
15 |
+
<!--</sales_email_pb_shipment_template>-->
|
16 |
+
<!--</email>-->
|
17 |
+
<!--</template>-->
|
18 |
+
<blocks>
|
19 |
+
<PB_Pbgsp>
|
20 |
+
<class>Pb_Pbgsp_Block</class>
|
21 |
+
</PB_Pbgsp>
|
22 |
+
<sales>
|
23 |
+
<rewrite>
|
24 |
+
<order_totals>Pb_Pbgsp_Block_Sales_Order_Totals</order_totals>
|
25 |
+
<order_invoice_totals>Pb_Pbgsp_Block_Sales_Order_Invoice_Totals</order_invoice_totals>
|
26 |
+
|
27 |
+
</rewrite>
|
28 |
+
</sales>
|
29 |
+
<adminhtml>
|
30 |
+
<rewrite>
|
31 |
+
<sales_order_totals>Pb_Pbgsp_Block_Adminhtml_Sales_Order_Totals</sales_order_totals>
|
32 |
+
<sales_order_invoice_totals>Pb_Pbgsp_Block_Adminhtml_Sales_Order_Invoice_Totals</sales_order_invoice_totals>
|
33 |
+
|
34 |
+
</rewrite>
|
35 |
+
</adminhtml>
|
36 |
+
<checkout>
|
37 |
+
<rewrite>
|
38 |
+
<onepage_shipping_method_available>Pb_Pbgsp_Block_Checkout_Shipping_Method_Available</onepage_shipping_method_available>
|
39 |
+
</rewrite>
|
40 |
+
</checkout>
|
41 |
+
</blocks>
|
42 |
+
<models>
|
43 |
+
<pb_pbgsp>
|
44 |
+
<class>Pb_Pbgsp_Model</class>
|
45 |
+
<resourceModel>pb_pbgsp_mysql4</resourceModel>
|
46 |
+
</pb_pbgsp>
|
47 |
+
<pb_pbgsp_mysql4>
|
48 |
+
<class>Pb_Pbgsp_Model_Mysql4</class>
|
49 |
+
<entities>
|
50 |
+
<variable>
|
51 |
+
<table>pbgsp_variable</table>
|
52 |
+
</variable>
|
53 |
+
<ordernumber>
|
54 |
+
<table>pbgsp_ordernumber</table>
|
55 |
+
</ordernumber>
|
56 |
+
<inboundparcel>
|
57 |
+
<table>pbgsp_inbound_parcel</table>
|
58 |
+
</inboundparcel>
|
59 |
+
</entities>
|
60 |
+
</pb_pbgsp_mysql4>
|
61 |
+
<sales>
|
62 |
+
<rewrite>
|
63 |
+
<order_invoice_total_tax>Pb_Pbgsp_Model_Invoice_Duty</order_invoice_total_tax>
|
64 |
+
<order_creditmemo_total_tax>Pb_Pbgsp_Model_Creditmemo_Duty</order_creditmemo_total_tax>
|
65 |
+
<order_shipment>Pb_Pbgsp_Model_Sales_Order_Shipment</order_shipment>
|
66 |
+
</rewrite>
|
67 |
+
</sales>
|
68 |
+
</models>
|
69 |
+
<resources>
|
70 |
+
<pbgsp_setup>
|
71 |
+
<setup>
|
72 |
+
<module>Pb_Pbgsp</module>
|
73 |
+
<class>Pb_Pbgsp_Model_Resource_Mysql4_Setup</class>
|
74 |
+
</setup>
|
75 |
+
<connection>
|
76 |
+
<use>core_setup</use>
|
77 |
+
</connection>
|
78 |
+
</pbgsp_setup>
|
79 |
+
<pb_pbgsp_write>
|
80 |
+
<connection>
|
81 |
+
<use>core_write</use>
|
82 |
+
</connection>
|
83 |
+
</pb_pbgsp_write>
|
84 |
+
<pb_pbgsp_read>
|
85 |
+
<connection>
|
86 |
+
<use>core_read</use>
|
87 |
+
</connection>
|
88 |
+
</pb_pbgsp_read>
|
89 |
+
</resources>
|
90 |
+
<events>
|
91 |
+
<!--<checkout_submit_all_after><!– added by Kamran 7/2/2014 –>-->
|
92 |
+
<!--<observers>-->
|
93 |
+
<!--<Pb_Pbgsp_Model_CheckoutSubmitAllAfter>-->
|
94 |
+
<!--<type>model</type>-->
|
95 |
+
<!--<class>pb_pbgsp/observer</class>-->
|
96 |
+
<!--<method>createOrderAdminAfter</method>-->
|
97 |
+
<!--</Pb_Pbgsp_Model_CheckoutSubmitAllAfter>-->
|
98 |
+
<!--</observers>-->
|
99 |
+
<!--</checkout_submit_all_after>-->
|
100 |
+
<core_block_abstract_to_html_after>
|
101 |
+
<observers>
|
102 |
+
<Pb_Pbgsp_Model_OrderView>
|
103 |
+
<type>model</type>
|
104 |
+
<class>pb_pbgsp/observer</class>
|
105 |
+
<method>modifyOrderView</method>
|
106 |
+
</Pb_Pbgsp_Model_OrderView>
|
107 |
+
</observers>
|
108 |
+
</core_block_abstract_to_html_after>
|
109 |
+
<checkout_controller_onepage_save_shipping_method>
|
110 |
+
<observers>
|
111 |
+
<Pb_Pbgsp_Model_SaveShippingOne>
|
112 |
+
<type>model</type>
|
113 |
+
<class>pb_pbgsp/observer</class>
|
114 |
+
<method>saveShippingMethod</method>
|
115 |
+
</Pb_Pbgsp_Model_SaveShippingOne>
|
116 |
+
</observers>
|
117 |
+
</checkout_controller_onepage_save_shipping_method>
|
118 |
+
<checkout_onepage_controller_success_action>
|
119 |
+
<observers>
|
120 |
+
<Pb_Pbgsp_Model_CheckoutCompleteOne>
|
121 |
+
<type>model</type>
|
122 |
+
<class>pb_pbgsp/observer</class>
|
123 |
+
<method>createPbOrder</method>
|
124 |
+
</Pb_Pbgsp_Model_CheckoutCompleteOne>
|
125 |
+
</observers>
|
126 |
+
</checkout_onepage_controller_success_action>
|
127 |
+
<controller_action_postdispatch_checkout_cart_estimateUpdatePost>
|
128 |
+
<observers>
|
129 |
+
<Pb_Pbgsp_Estimated_Shipping>
|
130 |
+
<type>model</type>
|
131 |
+
<class>pb_pbgsp/observer</class>
|
132 |
+
<method>addDutiesOnEstimation</method>
|
133 |
+
</Pb_Pbgsp_Estimated_Shipping>
|
134 |
+
</observers>
|
135 |
+
</controller_action_postdispatch_checkout_cart_estimateUpdatePost>
|
136 |
+
<catalog_product_load_after>
|
137 |
+
<observers>
|
138 |
+
<Pb_Pbgsp_Product_Last_Export>
|
139 |
+
<type>model</type>
|
140 |
+
<class>pb_pbgsp/observer</class>
|
141 |
+
<method>productLoadAfter</method>
|
142 |
+
</Pb_Pbgsp_Product_Last_Export>
|
143 |
+
</observers>
|
144 |
+
</catalog_product_load_after>
|
145 |
+
<catalog_category_load_after>
|
146 |
+
<observers>
|
147 |
+
<Pb_Pbgsp_Product_Last_Export>
|
148 |
+
<type>model</type>
|
149 |
+
<class>pb_pbgsp/observer</class>
|
150 |
+
<method>categoryLoadAfter</method>
|
151 |
+
</Pb_Pbgsp_Product_Last_Export>
|
152 |
+
</observers>
|
153 |
+
</catalog_category_load_after>
|
154 |
+
</events>
|
155 |
+
<sales>
|
156 |
+
<quote>
|
157 |
+
<totals>
|
158 |
+
<tax>
|
159 |
+
<class>Pb_Pbgsp_Model_Quote_Duty</class>
|
160 |
+
<before>grand_total</before>
|
161 |
+
<after>shipping</after>
|
162 |
+
</tax>
|
163 |
+
</totals>
|
164 |
+
</quote>
|
165 |
+
</sales>
|
166 |
+
<pdf>
|
167 |
+
<totals>
|
168 |
+
<tax translate="title">
|
169 |
+
<title>Tax</title>
|
170 |
+
<source_field>tax_amount</source_field>
|
171 |
+
<model>pb_pbgsp/pdf_tax</model>
|
172 |
+
<font_size>7</font_size>
|
173 |
+
<display_zero>0</display_zero>
|
174 |
+
<sort_order>300</sort_order>
|
175 |
+
</tax>
|
176 |
+
</totals>
|
177 |
+
</pdf>
|
178 |
+
|
179 |
+
</global>
|
180 |
+
<resources>
|
181 |
+
<sales_setup>
|
182 |
+
<setup>
|
183 |
+
<module>Pb_Pbgsp</module>
|
184 |
+
<class>Pb_Pbgsp_Model_Entity_Setup</class>
|
185 |
+
</setup>
|
186 |
+
</sales_setup>
|
187 |
+
</resources>
|
188 |
+
|
189 |
+
<!--<frontend>-->
|
190 |
+
<!--<layout>-->
|
191 |
+
<!--<updates>-->
|
192 |
+
<!--<pbcheckout>-->
|
193 |
+
<!--<file>pbcheckout.xml</file>-->
|
194 |
+
<!--</pbcheckout>-->
|
195 |
+
<!--</updates>-->
|
196 |
+
<!--</layout>-->
|
197 |
+
<!--<routers>-->
|
198 |
+
<!--<Pb_Pbgsp>-->
|
199 |
+
<!--<use>standard</use>-->
|
200 |
+
<!--<args>-->
|
201 |
+
<!--<module>Pb_Pbgsp</module>-->
|
202 |
+
<!--<frontName>pbgsp</frontName>-->
|
203 |
+
<!--<!– loads ../controller/IndexController in http://..../magento/index.php/testController –>-->
|
204 |
+
<!--</args>-->
|
205 |
+
<!--</Pb_Pbgsp>-->
|
206 |
+
<!--</routers>-->
|
207 |
+
<!--<translate>-->
|
208 |
+
<!--<modules>-->
|
209 |
+
<!--<translations>-->
|
210 |
+
<!--<files>-->
|
211 |
+
<!--<default>Pb_Pbgsp.csv</default>-->
|
212 |
+
<!--</files>-->
|
213 |
+
<!--</translations>-->
|
214 |
+
<!--</modules>-->
|
215 |
+
<!--</translate>-->
|
216 |
+
<!--</frontend>-->
|
217 |
+
|
218 |
+
<default>
|
219 |
+
<carriers>
|
220 |
+
<pbgsp>
|
221 |
+
<active>1</active>
|
222 |
+
<sallowspecific>0</sallowspecific>
|
223 |
+
<model>Pb_Pbgsp_Model_Carrier_ShippingMethod</model>
|
224 |
+
<specificerrmsg>
|
225 |
+
This shipping method is currently unavailable.
|
226 |
+
If you would like to ship using this shipping
|
227 |
+
method, please contact us.
|
228 |
+
</specificerrmsg>
|
229 |
+
<handling_type>F</handling_type>
|
230 |
+
<catalog_diff>1</catalog_diff>
|
231 |
+
<catalog_full>1</catalog_full>
|
232 |
+
<catalog_size>10000</catalog_size>
|
233 |
+
<catalog_encryption_enabled>0</catalog_encryption_enabled>
|
234 |
+
<asn_generation_enabled>1</asn_generation_enabled>
|
235 |
+
<suppress_domestic_tracking>1</suppress_domestic_tracking>
|
236 |
+
<custom_shipment_email_subject><![CDATA[{{var store.getFrontendName()}}: Shipment confirmation for Order # {{var order.increment_id}}]]>
|
237 |
+
</custom_shipment_email_subject>
|
238 |
+
<custom_shipment_email_template><![CDATA[<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Hello, {{htmlescape var=$order.getCustomerName()}}</h1>
|
239 |
+
<p style="font-size:12px; line-height:16px; margin:0;">
|
240 |
+
Thank you for your order from {{var store.getFrontendName()}}.
|
241 |
+
You can check the status of your order by <a href="{{store url="customer/account/"}}" style="color:#1E7EC8;">logging into your account</a>.
|
242 |
+
|
243 |
+
</p>
|
244 |
+
<p style="font-size:12px; line-height:16px; margin:0;">
|
245 |
+
Your shipping confirmation is below. Thank you again for your business.
|
246 |
+
</p>
|
247 |
+
|
248 |
+
<h2 style="font-size:18px; font-weight:normal; margin:0;">Your Order #{{var order.increment_id}} has been shipped from local warehouse to international shipment hub from where it will be shipped to your country.</h2>
|
249 |
+
|
250 |
+
]]>
|
251 |
+
</custom_shipment_email_template>
|
252 |
+
<separate_log_file>0</separate_log_file>
|
253 |
+
|
254 |
+
<shipping_services>
|
255 |
+
<POSTAL_PRIORITY>
|
256 |
+
<title>Standard</title>
|
257 |
+
<enabled>0</enabled>
|
258 |
+
</POSTAL_PRIORITY>
|
259 |
+
<FEDEX_ECONOMY>
|
260 |
+
<title>Express</title>
|
261 |
+
<enabled>1</enabled>
|
262 |
+
</FEDEX_ECONOMY>
|
263 |
+
<FEDEX_PRIORITY>
|
264 |
+
<title>Express Plus</title>
|
265 |
+
<enabled>1</enabled>
|
266 |
+
</FEDEX_PRIORITY>
|
267 |
+
<AE_STANDARD>
|
268 |
+
<title>Premier</title>
|
269 |
+
<enabled>1</enabled>
|
270 |
+
</AE_STANDARD>
|
271 |
+
<AU_STANDARD>
|
272 |
+
<title>Premier</title>
|
273 |
+
<enabled>1</enabled>
|
274 |
+
</AU_STANDARD>
|
275 |
+
<CN_STANDARD>
|
276 |
+
<title>Premier</title>
|
277 |
+
<enabled>1</enabled>
|
278 |
+
</CN_STANDARD>
|
279 |
+
<CPC_EXPRESS>
|
280 |
+
<title>Premier Plus</title>
|
281 |
+
<enabled>1</enabled>
|
282 |
+
</CPC_EXPRESS>
|
283 |
+
<CPC_STANDARD>
|
284 |
+
<title>Premier</title>
|
285 |
+
<enabled>1</enabled>
|
286 |
+
</CPC_STANDARD>
|
287 |
+
<EU_STANDARD>
|
288 |
+
<title>Premier</title>
|
289 |
+
<enabled>1</enabled>
|
290 |
+
</EU_STANDARD>
|
291 |
+
<HK_STANDARD>
|
292 |
+
<title>Premier</title>
|
293 |
+
<enabled>1</enabled>
|
294 |
+
</HK_STANDARD>
|
295 |
+
<KR_STANDARD>
|
296 |
+
<title>Premier</title>
|
297 |
+
<enabled>1</enabled>
|
298 |
+
</KR_STANDARD>
|
299 |
+
<NZ_STANDARD>
|
300 |
+
<title>Premier</title>
|
301 |
+
<enabled>1</enabled>
|
302 |
+
</NZ_STANDARD>
|
303 |
+
<PH_STANDARD>
|
304 |
+
<title>Premier</title>
|
305 |
+
<enabled>1</enabled>
|
306 |
+
</PH_STANDARD>
|
307 |
+
<SG_STANDARD>
|
308 |
+
<title>Premier</title>
|
309 |
+
<enabled>1</enabled>
|
310 |
+
</SG_STANDARD>
|
311 |
+
<TH_STANDARD>
|
312 |
+
<title>Premier</title>
|
313 |
+
<enabled>1</enabled>
|
314 |
+
</TH_STANDARD>
|
315 |
+
<TW_STANDARD>
|
316 |
+
<title>Premier</title>
|
317 |
+
<enabled>1</enabled>
|
318 |
+
</TW_STANDARD>
|
319 |
+
</shipping_services>
|
320 |
+
<error_messages>
|
321 |
+
<_1005001>
|
322 |
+
<display>The shipping address is invalid.</display>
|
323 |
+
</_1005001>
|
324 |
+
<_1005002>
|
325 |
+
<display>The consignee information is invalid.</display>
|
326 |
+
</_1005002>
|
327 |
+
<_1005003>
|
328 |
+
<display>The COP transportation information is invalid.</display>
|
329 |
+
</_1005003>
|
330 |
+
<_1005004>
|
331 |
+
<display>The requested return currency is invalid.</display>
|
332 |
+
</_1005004>
|
333 |
+
<_1005005>
|
334 |
+
<display>The request currency is not supported for the target country.</display>
|
335 |
+
</_1005005>
|
336 |
+
<_1005006>
|
337 |
+
<display>The order cannot be shipped by the method selected.</display>
|
338 |
+
</_1005006>
|
339 |
+
<_1005007>
|
340 |
+
<display>The order value has exceeded the allowed value.</display>
|
341 |
+
</_1005007>
|
342 |
+
<_1005008>
|
343 |
+
<display>Invalid fields in parcels.</display>
|
344 |
+
</_1005008>
|
345 |
+
<_1005009>
|
346 |
+
<display>Invalid fields in commoditySources.</display>
|
347 |
+
</_1005009>
|
348 |
+
<_1005010>
|
349 |
+
<display>This basket is over the dollar value for international shipping. Please remove some items before proceeding.</display>
|
350 |
+
</_1005010>
|
351 |
+
<_1005011>
|
352 |
+
<display>There are errors at the Quote Item Level.</display>
|
353 |
+
</_1005011>
|
354 |
+
<_1005012>
|
355 |
+
<display>The order exceeded the weight limit.</display>
|
356 |
+
</_1005012>
|
357 |
+
<_1005013>
|
358 |
+
<display>The shipping address has missing fields.</display>
|
359 |
+
</_1005013>
|
360 |
+
<_1005014>
|
361 |
+
<display>Missing fields in basket.</display>
|
362 |
+
</_1005014>
|
363 |
+
<_1005015>
|
364 |
+
<display>Invalid fields in basket.</display>
|
365 |
+
</_1005015>
|
366 |
+
<_1005016>
|
367 |
+
<display>The consignee information is missing.</display>
|
368 |
+
</_1005016>
|
369 |
+
<_1005017>
|
370 |
+
<display>The COP transportation information is missing.</display>
|
371 |
+
</_1005017>
|
372 |
+
<_1005018>
|
373 |
+
<display>Shipping Speed unavailable.</display>
|
374 |
+
</_1005018>
|
375 |
+
<_1005018>
|
376 |
+
<display>Shipping Speed unavailable.</display>
|
377 |
+
</_1005018>
|
378 |
+
<_1005019>
|
379 |
+
<display>Missing Basket.</display>
|
380 |
+
</_1005019>
|
381 |
+
<_1005020>
|
382 |
+
<display>Missing Parcel Fields.</display>
|
383 |
+
</_1005020>
|
384 |
+
<_1005021>
|
385 |
+
<display>Missing fields in the basket commodity source.</display>
|
386 |
+
</_1005021>
|
387 |
+
<_1005022>
|
388 |
+
<display>Invalid Parcel Fields.</display>
|
389 |
+
</_1005022>
|
390 |
+
<_1006001>
|
391 |
+
<display>The commodity was invalid.</display>
|
392 |
+
</_1006001>
|
393 |
+
<_1006002>
|
394 |
+
<display>The commodity is too large to ship (length, width or height).</display>
|
395 |
+
</_1006002>
|
396 |
+
<_1006003>
|
397 |
+
<display>The commodity cannot be shipped to the COD.</display>
|
398 |
+
</_1006003>
|
399 |
+
<_1006004>
|
400 |
+
<display>The commodity has a negative price.</display>
|
401 |
+
</_1006004>
|
402 |
+
<_1006005>
|
403 |
+
<display>The commodity’s price was too low and did not have a dutiable value.</display>
|
404 |
+
</_1006005>
|
405 |
+
<_1006006>
|
406 |
+
<display>The item price exceeds maximum.</display>
|
407 |
+
</_1006006>
|
408 |
+
<_1006007>
|
409 |
+
<display>Item weight exceeds maximum.</display>
|
410 |
+
</_1006007>
|
411 |
+
<_1006008>
|
412 |
+
<display>Invalid commodity rated data. Commodity cannot be shipped at this time. This is an internal error and should be raised to PB immediately. .</display>
|
413 |
+
</_1006008>
|
414 |
+
<_1006009>
|
415 |
+
<display>The Commodity is restricted for this Country of Destination.</display>
|
416 |
+
</_1006009>
|
417 |
+
<_10060010>
|
418 |
+
<display>Commodity cannot be quoted.</display>
|
419 |
+
</_10060010>
|
420 |
+
<_10060011>
|
421 |
+
<display>Commodity cannot shipped to the address specified.</display>
|
422 |
+
</_10060011>
|
423 |
+
<_1007001>
|
424 |
+
<display>Order value exceeded on this line.</display>
|
425 |
+
</_1007001>
|
426 |
+
<_1007002>
|
427 |
+
<display>Line too large to ship (length, width or height of the shipping box).</display>
|
428 |
+
</_1007002>
|
429 |
+
<_1007003>
|
430 |
+
<display>The quantity is invalid or missing.</display>
|
431 |
+
</_1007003>
|
432 |
+
<_1007004>
|
433 |
+
<display>Weight Value exceeded on this line.</display>
|
434 |
+
</_1007004>
|
435 |
+
<_1007005>
|
436 |
+
<display>Errors in the kitContents.</display>
|
437 |
+
</_1007005>
|
438 |
+
<_1007006>
|
439 |
+
<display>Missing fields in basket line.</display>
|
440 |
+
</_1007006>
|
441 |
+
<_1007007>
|
442 |
+
<display>Invalid fields in basket line.</display>
|
443 |
+
</_1007007>
|
444 |
+
<_1007008>
|
445 |
+
<display>Quantity exceeded for Country of Destination.</display>
|
446 |
+
</_1007008>
|
447 |
+
</error_messages>
|
448 |
+
</pbgsp>
|
449 |
+
</carriers>
|
450 |
+
</default>
|
451 |
+
|
452 |
+
<!-- Please modify this part for CRON JOB
|
453 |
+
For more information on Magento Cron Job, please visit the following url:
|
454 |
+
http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job#built-in_cron_jobs
|
455 |
+
-->
|
456 |
+
<crontab>
|
457 |
+
<jobs>
|
458 |
+
<pb_pbgsp>
|
459 |
+
<schedule>
|
460 |
+
<cron_expr>30 * * * *</cron_expr>
|
461 |
+
</schedule>
|
462 |
+
<run>
|
463 |
+
<model>pb_pbgsp/catalog_cron::catalogSync</model>
|
464 |
+
</run>
|
465 |
+
</pb_pbgsp>
|
466 |
+
<pb_notifications>
|
467 |
+
<schedule>
|
468 |
+
<cron_expr>20 * * * *</cron_expr>
|
469 |
+
</schedule>
|
470 |
+
<run>
|
471 |
+
<model>pb_pbgsp/catalog_cron::processStatusNotifications</model>
|
472 |
+
</run>
|
473 |
+
</pb_notifications>
|
474 |
+
</jobs>
|
475 |
+
</crontab>
|
476 |
+
<adminhtml>
|
477 |
+
<events>
|
478 |
+
<!--<sales_order_save_commit_after>-->
|
479 |
+
<!--<observers>-->
|
480 |
+
<!--<Pb_Pbgsp_CreateParcel>-->
|
481 |
+
<!--<type>model</type>-->
|
482 |
+
<!--<class>pb_pbgsp/observer</class>-->
|
483 |
+
<!--<method>generateInboundParcelPreAdvice</method>-->
|
484 |
+
<!--</Pb_Pbgsp_CreateParcel>-->
|
485 |
+
<!--</observers>-->
|
486 |
+
<!--</sales_order_save_commit_after>-->
|
487 |
+
<sales_order_shipment_save_after>
|
488 |
+
<observers>
|
489 |
+
<Pb_Pbgsp_CreateParcel>
|
490 |
+
<type>model</type>
|
491 |
+
<class>pb_pbgsp/observer</class>
|
492 |
+
<method>generateInboundParcelPreAdvice</method>
|
493 |
+
</Pb_Pbgsp_CreateParcel>
|
494 |
+
</observers>
|
495 |
+
</sales_order_shipment_save_after>
|
496 |
+
</events>
|
497 |
+
<!--<translate>-->
|
498 |
+
<!--<modules>-->
|
499 |
+
<!--<translations>-->
|
500 |
+
<!--<files>-->
|
501 |
+
<!--<default>Pb_Pbgsp.csv</default>-->
|
502 |
+
<!--</files>-->
|
503 |
+
<!--</translations>-->
|
504 |
+
<!--</modules>-->
|
505 |
+
<!--</translate>-->
|
506 |
+
</adminhtml>
|
507 |
+
|
508 |
+
</config>
|
509 |
+
|
app/code/local/Pb/Pbgsp/etc/system.xml
CHANGED
@@ -1,361 +1,379 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<carriers>
|
5 |
-
<groups>
|
6 |
-
<pbgsp translate="label" module="shipping">
|
7 |
-
<label>Pitney Bowes PBGSP</label>
|
8 |
-
<frontend_type>text</frontend_type>
|
9 |
-
<sort_order>13</sort_order>
|
10 |
-
<show_in_default>1</show_in_default>
|
11 |
-
<show_in_website>1</show_in_website>
|
12 |
-
<show_in_store>1</show_in_store>
|
13 |
-
<fields>
|
14 |
-
<active translate="label">
|
15 |
-
<label>Enabled</label>
|
16 |
-
<frontend_type>select</frontend_type>
|
17 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
-
<sort_order>1</sort_order>
|
19 |
-
<show_in_default>1</show_in_default>
|
20 |
-
<show_in_website>1</show_in_website>
|
21 |
-
<show_in_store>1</show_in_store>
|
22 |
-
</active>
|
23 |
-
<merchantcode translate="label">
|
24 |
-
<label>Merchant Code</label>
|
25 |
-
<frontend_type>text</frontend_type>
|
26 |
-
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
27 |
-
<sort_order>10</sort_order>
|
28 |
-
<show_in_default>1</show_in_default>
|
29 |
-
<show_in_website>1</show_in_website>
|
30 |
-
<show_in_store>1</show_in_store>
|
31 |
-
</merchantcode>
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
<
|
60 |
-
<
|
61 |
-
<
|
62 |
-
<
|
63 |
-
<
|
64 |
-
<
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
<
|
69 |
-
<
|
70 |
-
<
|
71 |
-
<
|
72 |
-
<
|
73 |
-
<
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
<
|
78 |
-
<
|
79 |
-
<
|
80 |
-
<
|
81 |
-
<
|
82 |
-
<
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
<
|
87 |
-
<
|
88 |
-
<sort_order>
|
89 |
-
<show_in_default>1</show_in_default>
|
90 |
-
<show_in_website>1</show_in_website>
|
91 |
-
<show_in_store>1</show_in_store>
|
92 |
-
</
|
93 |
-
<
|
94 |
-
<label>SFTP
|
95 |
-
<frontend_type>text</frontend_type>
|
96 |
-
<sort_order>
|
97 |
-
<show_in_default>1</show_in_default>
|
98 |
-
<show_in_website>1</show_in_website>
|
99 |
-
<show_in_store>1</show_in_store>
|
100 |
-
</
|
101 |
-
<
|
102 |
-
<label>SFTP
|
103 |
-
<frontend_type>text</frontend_type>
|
104 |
-
<
|
105 |
-
<
|
106 |
-
<
|
107 |
-
<
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
<
|
112 |
-
<
|
113 |
-
<sort_order>
|
114 |
-
<show_in_default>1</show_in_default>
|
115 |
-
<show_in_website>1</show_in_website>
|
116 |
-
<show_in_store>1</show_in_store>
|
117 |
-
|
118 |
-
<
|
119 |
-
<label>
|
120 |
-
<frontend_type>text</frontend_type>
|
121 |
-
|
122 |
-
<show_in_default>1</show_in_default>
|
123 |
-
<show_in_website>1</show_in_website>
|
124 |
-
<show_in_store>1</show_in_store>
|
125 |
-
</
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
<
|
137 |
-
<
|
138 |
-
|
139 |
-
<
|
140 |
-
<
|
141 |
-
<
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
<
|
146 |
-
|
147 |
-
<
|
148 |
-
<
|
149 |
-
<
|
150 |
-
<
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
<
|
155 |
-
<
|
156 |
-
<
|
157 |
-
<
|
158 |
-
<
|
159 |
-
<
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
<
|
164 |
-
<
|
165 |
-
|
166 |
-
<show_in_default>1</show_in_default>
|
167 |
-
<show_in_website>1</show_in_website>
|
168 |
-
<show_in_store>1</show_in_store>
|
169 |
-
</
|
170 |
-
<
|
171 |
-
<label>
|
172 |
-
<frontend_type>
|
173 |
-
|
174 |
-
<
|
175 |
-
<
|
176 |
-
<
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
<
|
195 |
-
<
|
196 |
-
<sort_order>
|
197 |
-
<show_in_default>1</show_in_default>
|
198 |
-
<show_in_website>1</show_in_website>
|
199 |
-
<show_in_store>1</show_in_store>
|
200 |
-
</
|
201 |
-
<
|
202 |
-
<label>
|
203 |
-
<frontend_type>text</frontend_type>
|
204 |
-
<sort_order>
|
205 |
-
<show_in_default>1</show_in_default>
|
206 |
-
<show_in_website>1</show_in_website>
|
207 |
-
<show_in_store>1</show_in_store>
|
208 |
-
</
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
<
|
238 |
-
<
|
239 |
-
<
|
240 |
-
<
|
241 |
-
<
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
<
|
246 |
-
<
|
247 |
-
<
|
248 |
-
<
|
249 |
-
<
|
250 |
-
<
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
<
|
255 |
-
<
|
256 |
-
<sort_order>
|
257 |
-
<show_in_default>1</show_in_default>
|
258 |
-
<show_in_website>1</show_in_website>
|
259 |
-
<show_in_store>1</show_in_store>
|
260 |
-
</
|
261 |
-
<
|
262 |
-
<label>
|
263 |
-
<frontend_type>
|
264 |
-
<
|
265 |
-
<sort_order>
|
266 |
-
<show_in_default>1</show_in_default>
|
267 |
-
<show_in_website>1</show_in_website>
|
268 |
-
<show_in_store>1</show_in_store>
|
269 |
-
</
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
<
|
292 |
-
<
|
293 |
-
<
|
294 |
-
<
|
295 |
-
<
|
296 |
-
<
|
297 |
-
<
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
<
|
302 |
-
<
|
303 |
-
<
|
304 |
-
<show_in_default>1</show_in_default>
|
305 |
-
<show_in_website>1</show_in_website>
|
306 |
-
<show_in_store>1</show_in_store>
|
307 |
-
</
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
<
|
330 |
-
<
|
331 |
-
|
332 |
-
<
|
333 |
-
<
|
334 |
-
<
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
<
|
339 |
-
<
|
340 |
-
<
|
341 |
-
<
|
342 |
-
<
|
343 |
-
<
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
<
|
348 |
-
<
|
349 |
-
|
350 |
-
<
|
351 |
-
<show_in_default>1</show_in_default>
|
352 |
-
<show_in_website>1</show_in_website>
|
353 |
-
<show_in_store>1</show_in_store>
|
354 |
-
</
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<carriers>
|
5 |
+
<groups>
|
6 |
+
<pbgsp translate="label" module="shipping">
|
7 |
+
<label>Pitney Bowes PBGSP</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>13</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<active translate="label">
|
15 |
+
<label>Enabled</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
</active>
|
23 |
+
<merchantcode translate="label">
|
24 |
+
<label>Merchant Code</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
27 |
+
<sort_order>10</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
</merchantcode>
|
32 |
+
<authorization_endpoint translate="label">
|
33 |
+
<label>Authorization Endpoint</label>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>15</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
</authorization_endpoint>
|
40 |
+
<checkout_endpoint translate="label">
|
41 |
+
<label>Checkout Endpoint</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>16</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
</checkout_endpoint>
|
48 |
+
<order_mgmt_api translate="label">
|
49 |
+
<label>ASN Endpoint</label>
|
50 |
+
<frontend_type>text</frontend_type>
|
51 |
+
|
52 |
+
<sort_order>17</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</order_mgmt_api>
|
57 |
+
<apiuser translate="label">
|
58 |
+
<label>API username</label>
|
59 |
+
<frontend_type>text</frontend_type>
|
60 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
61 |
+
<sort_order>20</sort_order>
|
62 |
+
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>1</show_in_store>
|
65 |
+
</apiuser>
|
66 |
+
<apipass translate="label">
|
67 |
+
<label>API password</label>
|
68 |
+
<frontend_type>password</frontend_type>
|
69 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
70 |
+
<sort_order>30</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>1</show_in_store>
|
74 |
+
</apipass>
|
75 |
+
<ftpuser translate="label">
|
76 |
+
<label>SFTP username</label>
|
77 |
+
<frontend_type>text</frontend_type>
|
78 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
79 |
+
<sort_order>40</sort_order>
|
80 |
+
<show_in_default>1</show_in_default>
|
81 |
+
<show_in_website>1</show_in_website>
|
82 |
+
<show_in_store>1</show_in_store>
|
83 |
+
</ftpuser>
|
84 |
+
<ftppass translate="label">
|
85 |
+
<label>SFTP password</label>
|
86 |
+
<frontend_type>password</frontend_type>
|
87 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
88 |
+
<sort_order>50</sort_order>
|
89 |
+
<show_in_default>1</show_in_default>
|
90 |
+
<show_in_website>1</show_in_website>
|
91 |
+
<show_in_store>1</show_in_store>
|
92 |
+
</ftppass>
|
93 |
+
<ftphost translate="label">
|
94 |
+
<label>SFTP hostname</label>
|
95 |
+
<frontend_type>text</frontend_type>
|
96 |
+
<sort_order>60</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<show_in_store>1</show_in_store>
|
100 |
+
</ftphost>
|
101 |
+
<ftpport translate="label">
|
102 |
+
<label>SFTP port</label>
|
103 |
+
<frontend_type>text</frontend_type>
|
104 |
+
<sort_order>70</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
</ftpport>
|
109 |
+
<ftpdir translate="label">
|
110 |
+
<label>SFTP catalog directory</label>
|
111 |
+
<frontend_type>text</frontend_type>
|
112 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
113 |
+
<sort_order>80</sort_order>
|
114 |
+
<show_in_default>1</show_in_default>
|
115 |
+
<show_in_website>1</show_in_website>
|
116 |
+
<show_in_store>1</show_in_store>
|
117 |
+
</ftpdir>
|
118 |
+
<catalog_diff translate="label">
|
119 |
+
<label>Catalog update period (hours, min 1 hour)</label>
|
120 |
+
<frontend_type>text</frontend_type>
|
121 |
+
<sort_order>90</sort_order>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>1</show_in_store>
|
125 |
+
</catalog_diff>
|
126 |
+
<catalog_full translate="label">
|
127 |
+
<label>Full catalog upload period (days)</label>
|
128 |
+
<frontend_type>text</frontend_type>
|
129 |
+
<sort_order>100</sort_order>
|
130 |
+
<show_in_default>1</show_in_default>
|
131 |
+
<show_in_website>1</show_in_website>
|
132 |
+
<show_in_store>1</show_in_store>
|
133 |
+
</catalog_full>
|
134 |
+
<catalog_size translate="label">
|
135 |
+
<label>Maximum Records Per File</label>
|
136 |
+
<frontend_type>text</frontend_type>
|
137 |
+
<validate>validate-number</validate>
|
138 |
+
<sort_order>105</sort_order>
|
139 |
+
<show_in_default>1</show_in_default>
|
140 |
+
<show_in_website>1</show_in_website>
|
141 |
+
<show_in_store>1</show_in_store>
|
142 |
+
</catalog_size>
|
143 |
+
<catalog_sender_id translate="label">
|
144 |
+
<label>Catalog Sender ID</label>
|
145 |
+
<frontend_type>text</frontend_type>
|
146 |
+
|
147 |
+
<sort_order>106</sort_order>
|
148 |
+
<show_in_default>1</show_in_default>
|
149 |
+
<show_in_website>1</show_in_website>
|
150 |
+
<show_in_store>1</show_in_store>
|
151 |
+
</catalog_sender_id>
|
152 |
+
<admin_email translate="label">
|
153 |
+
<label>Admin Email</label>
|
154 |
+
<frontend_type>text</frontend_type>
|
155 |
+
<validate>validate-email</validate>
|
156 |
+
<sort_order>110</sort_order>
|
157 |
+
<show_in_default>1</show_in_default>
|
158 |
+
<show_in_website>1</show_in_website>
|
159 |
+
<show_in_store>1</show_in_store>
|
160 |
+
</admin_email>
|
161 |
+
<catalog_encryption_enabled translate="label">
|
162 |
+
<label>Catalog Encryption Enabled</label>
|
163 |
+
<frontend_type>select</frontend_type>
|
164 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
165 |
+
<sort_order>115</sort_order>
|
166 |
+
<show_in_default>1</show_in_default>
|
167 |
+
<show_in_website>1</show_in_website>
|
168 |
+
<show_in_store>1</show_in_store>
|
169 |
+
</catalog_encryption_enabled>
|
170 |
+
<encryption_public_key translate="label">
|
171 |
+
<label>Catalog Encryption Public Key</label>
|
172 |
+
<frontend_type>textarea</frontend_type>
|
173 |
+
<sort_order>120</sort_order>
|
174 |
+
<show_in_default>1</show_in_default>
|
175 |
+
<show_in_website>1</show_in_website>
|
176 |
+
<show_in_store>1</show_in_store>
|
177 |
+
</encryption_public_key>
|
178 |
+
<asn_generation_enabled translate="label">
|
179 |
+
<label>Generate ASN</label>
|
180 |
+
<frontend_type>select</frontend_type>
|
181 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
182 |
+
<sort_order>121</sort_order>
|
183 |
+
<show_in_default>1</show_in_default>
|
184 |
+
<show_in_website>1</show_in_website>
|
185 |
+
<show_in_store>1</show_in_store>
|
186 |
+
</asn_generation_enabled>
|
187 |
+
|
188 |
+
<!--
|
189 |
+
If the free_shipping_enable flag enable, the system will check free_shipping_subtotal to give free shipping
|
190 |
+
otherwise will use shopping cart price rule behaviour
|
191 |
+
-->
|
192 |
+
<free_shipping_enable translate="label">
|
193 |
+
<label>Free shipping with minimum order amount</label>
|
194 |
+
<frontend_type>select</frontend_type>
|
195 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
196 |
+
<sort_order>160</sort_order>
|
197 |
+
<show_in_default>1</show_in_default>
|
198 |
+
<show_in_website>1</show_in_website>
|
199 |
+
<show_in_store>1</show_in_store>
|
200 |
+
</free_shipping_enable>
|
201 |
+
<free_shipping_subtotal translate="label">
|
202 |
+
<label>Minimum order amount for free shipping</label>
|
203 |
+
<frontend_type>text</frontend_type>
|
204 |
+
<sort_order>170</sort_order>
|
205 |
+
<show_in_default>1</show_in_default>
|
206 |
+
<show_in_website>1</show_in_website>
|
207 |
+
<show_in_store>1</show_in_store>
|
208 |
+
</free_shipping_subtotal>
|
209 |
+
<free_tax_enable translate="label">
|
210 |
+
<label>Enable zero tax for customer</label>
|
211 |
+
<frontend_type>select</frontend_type>
|
212 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
213 |
+
<sort_order>175</sort_order>
|
214 |
+
<show_in_default>1</show_in_default>
|
215 |
+
<show_in_website>1</show_in_website>
|
216 |
+
<show_in_store>1</show_in_store>
|
217 |
+
</free_tax_enable>
|
218 |
+
|
219 |
+
<sort_order translate="label">
|
220 |
+
<label>Sort order</label>
|
221 |
+
<frontend_type>text</frontend_type>
|
222 |
+
<sort_order>230</sort_order>
|
223 |
+
<show_in_default>1</show_in_default>
|
224 |
+
<show_in_website>1</show_in_website>
|
225 |
+
<show_in_store>1</show_in_store>
|
226 |
+
</sort_order>
|
227 |
+
<title translate="label">
|
228 |
+
<label>Title</label>
|
229 |
+
<frontend_type>text</frontend_type>
|
230 |
+
<sort_order>240</sort_order>
|
231 |
+
<show_in_default>1</show_in_default>
|
232 |
+
<show_in_website>1</show_in_website>
|
233 |
+
<show_in_store>1</show_in_store>
|
234 |
+
</title>
|
235 |
+
<!-- added by BigPixel 6/5/2012 -->
|
236 |
+
<handlingfee translate="label">
|
237 |
+
<label>Handling Fee</label>
|
238 |
+
<frontend_type>text</frontend_type>
|
239 |
+
<sort_order>241</sort_order>
|
240 |
+
<show_in_default>1</show_in_default>
|
241 |
+
<show_in_website>1</show_in_website>
|
242 |
+
<show_in_store>1</show_in_store>
|
243 |
+
</handlingfee>
|
244 |
+
<handlingoption translate="label">
|
245 |
+
<label>Handling Fee Apply As</label>
|
246 |
+
<frontend_type>select</frontend_type>
|
247 |
+
<source_model>pb_pbgsp/handlingoptions</source_model>
|
248 |
+
<sort_order>242</sort_order>
|
249 |
+
<show_in_default>1</show_in_default>
|
250 |
+
<show_in_website>1</show_in_website>
|
251 |
+
<show_in_store>1</show_in_store>
|
252 |
+
</handlingoption>
|
253 |
+
<domestic_shipping_fee translate="label">
|
254 |
+
<label>Domestic Shipping Fee</label>
|
255 |
+
<frontend_type>text</frontend_type>
|
256 |
+
<sort_order>243</sort_order>
|
257 |
+
<show_in_default>1</show_in_default>
|
258 |
+
<show_in_website>1</show_in_website>
|
259 |
+
<show_in_store>1</show_in_store>
|
260 |
+
</domestic_shipping_fee>
|
261 |
+
<domestic_shipping_option translate="label">
|
262 |
+
<label>Apply Domestic shipping fee as</label>
|
263 |
+
<frontend_type>select</frontend_type>
|
264 |
+
<source_model>pb_pbgsp/handlingoptions</source_model>
|
265 |
+
<sort_order>244</sort_order>
|
266 |
+
<show_in_default>1</show_in_default>
|
267 |
+
<show_in_website>1</show_in_website>
|
268 |
+
<show_in_store>1</show_in_store>
|
269 |
+
</domestic_shipping_option>
|
270 |
+
<delivery_adjustment_min_days translate="label">
|
271 |
+
<label>Minimum Delivery Days to PB Hub</label>
|
272 |
+
<frontend_type>text</frontend_type>
|
273 |
+
<validate>validate-number</validate>
|
274 |
+
<sort_order>245</sort_order>
|
275 |
+
<show_in_default>1</show_in_default>
|
276 |
+
<show_in_website>1</show_in_website>
|
277 |
+
<show_in_store>1</show_in_store>
|
278 |
+
</delivery_adjustment_min_days>
|
279 |
+
<delivery_adjustment_max_days translate="label">
|
280 |
+
<label>Maximum Delivery Days to PB Hub</label>
|
281 |
+
<frontend_type>text</frontend_type>
|
282 |
+
<validate>validate-number</validate>
|
283 |
+
<sort_order>246</sort_order>
|
284 |
+
<show_in_default>1</show_in_default>
|
285 |
+
<show_in_website>1</show_in_website>
|
286 |
+
<show_in_store>1</show_in_store>
|
287 |
+
</delivery_adjustment_max_days>
|
288 |
+
<!-- added by BigPixel 6/5/2012 -->
|
289 |
+
<sallowspecific translate="label">
|
290 |
+
<label>Ship to applicable countries</label>
|
291 |
+
<frontend_type>select</frontend_type>
|
292 |
+
<sort_order>250</sort_order>
|
293 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
294 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
295 |
+
<show_in_default>1</show_in_default>
|
296 |
+
<show_in_website>1</show_in_website>
|
297 |
+
<show_in_store>1</show_in_store>
|
298 |
+
</sallowspecific>
|
299 |
+
<specificcountry translate="label">
|
300 |
+
<label>Ship to Specific countries</label>
|
301 |
+
<frontend_type>multiselect</frontend_type>
|
302 |
+
<sort_order>251</sort_order>
|
303 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
304 |
+
<show_in_default>1</show_in_default>
|
305 |
+
<show_in_website>1</show_in_website>
|
306 |
+
<show_in_store>1</show_in_store>
|
307 |
+
</specificcountry>
|
308 |
+
<showmethod translate="label">
|
309 |
+
<label>Show Method if Not Applicable</label>
|
310 |
+
<frontend_type>select</frontend_type>
|
311 |
+
<sort_order>260</sort_order>
|
312 |
+
<frontend_class>shipping-skip-hide</frontend_class>
|
313 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
314 |
+
<show_in_default>1</show_in_default>
|
315 |
+
<show_in_website>1</show_in_website>
|
316 |
+
<show_in_store>0</show_in_store>
|
317 |
+
</showmethod>
|
318 |
+
<specificerrmsg translate="label">
|
319 |
+
<label>Displayed Error Message</label>
|
320 |
+
<frontend_type>textarea</frontend_type>
|
321 |
+
<sort_order>270</sort_order>
|
322 |
+
<show_in_default>1</show_in_default>
|
323 |
+
<show_in_website>1</show_in_website>
|
324 |
+
<show_in_store>1</show_in_store>
|
325 |
+
</specificerrmsg>
|
326 |
+
<!-- test comments -->
|
327 |
+
<trackinglink translate="label">
|
328 |
+
<label>Enable Tracking Links</label>
|
329 |
+
<frontend_type>select</frontend_type>
|
330 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
331 |
+
<sort_order>271</sort_order>
|
332 |
+
<show_in_default>1</show_in_default>
|
333 |
+
<show_in_website>1</show_in_website>
|
334 |
+
<show_in_store>1</show_in_store>
|
335 |
+
</trackinglink>
|
336 |
+
<suppress_domestic_tracking translate="label">
|
337 |
+
<label>Suppress Domestic Leg Tracking</label>
|
338 |
+
<frontend_type>select</frontend_type>
|
339 |
+
<sort_order>280</sort_order>
|
340 |
+
<frontend_class>shipping-skip-hide</frontend_class>
|
341 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
342 |
+
<show_in_default>1</show_in_default>
|
343 |
+
<show_in_website>1</show_in_website>
|
344 |
+
<show_in_store>1</show_in_store>
|
345 |
+
</suppress_domestic_tracking>
|
346 |
+
<custom_shipment_email_subject translate="label">
|
347 |
+
<label>Custom Shipment Email Subject</label>
|
348 |
+
<frontend_type>text</frontend_type>
|
349 |
+
|
350 |
+
<sort_order>281</sort_order>
|
351 |
+
<show_in_default>1</show_in_default>
|
352 |
+
<show_in_website>1</show_in_website>
|
353 |
+
<show_in_store>1</show_in_store>
|
354 |
+
</custom_shipment_email_subject>
|
355 |
+
<custom_shipment_email_template>
|
356 |
+
<label>Custom Shipment Email</label>
|
357 |
+
<frontend_type>textarea</frontend_type>
|
358 |
+
<sort_order>282</sort_order>
|
359 |
+
<show_in_default>1</show_in_default>
|
360 |
+
<show_in_website>1</show_in_website>
|
361 |
+
<show_in_store>1</show_in_store>
|
362 |
+
</custom_shipment_email_template>
|
363 |
+
<separate_log_file translate="label">
|
364 |
+
<label>Log in separate file</label>
|
365 |
+
<frontend_type>select</frontend_type>
|
366 |
+
<sort_order>283</sort_order>
|
367 |
+
<frontend_class>shipping-skip-hide</frontend_class>
|
368 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
369 |
+
<show_in_default>1</show_in_default>
|
370 |
+
<show_in_website>1</show_in_website>
|
371 |
+
<show_in_store>1</show_in_store>
|
372 |
+
</separate_log_file>
|
373 |
+
</fields>
|
374 |
+
</pbgsp>
|
375 |
+
</groups>
|
376 |
+
</carriers>
|
377 |
+
|
378 |
+
</sections>
|
379 |
+
</config>
|
app/code/local/Pb/Pbgsp/sql/pbgsp_setup/mysql4-install-1.0.0.php
CHANGED
@@ -1,60 +1,96 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
`
|
22 |
-
`
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
`
|
28 |
-
`
|
29 |
-
`
|
30 |
-
`
|
31 |
-
|
32 |
-
)
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
`
|
37 |
-
`
|
38 |
-
`
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
'
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Product: Pb_Pbgsp (1.0.0)
|
4 |
+
* Packaged: 2015-06-04T15:09:31+00:00
|
5 |
+
* Last Modified: 2015-06-04T15:00:31+00:00
|
6 |
+
* File: app/code/local/Pb/Pbgsp/sql/pbgsp_setup/mysql4-install-1.0.0.php
|
7 |
+
* Copyright: Copyright (c) 2015 Pitney Bowes <info@pb.com> / All rights reserved.
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
$installer = $this;
|
12 |
+
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->run("
|
16 |
+
|
17 |
+
DROP TABLE IF EXISTS {$this->getTable('pb_pbgsp/variable')};
|
18 |
+
CREATE TABLE {$this->getTable('pb_pbgsp/variable')} (
|
19 |
+
`variable_id` int(11) unsigned NOT NULL auto_increment,
|
20 |
+
`name` varchar(255) NOT NULL default '',
|
21 |
+
`value` varchar(255) NOT NULL default '',
|
22 |
+
PRIMARY KEY (`variable_id`)
|
23 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
24 |
+
|
25 |
+
DROP TABLE IF EXISTS {$this->getTable('pb_pbgsp/ordernumber')};
|
26 |
+
CREATE TABLE {$this->getTable('pb_pbgsp/ordernumber')} (
|
27 |
+
`ordernumber_id` int(11) unsigned NOT NULL auto_increment,
|
28 |
+
`cp_order_number` varchar(255) NOT NULL default '',
|
29 |
+
`mage_order_number` varchar(255) NOT NULL default '',
|
30 |
+
`confirmed` tinyint NOT NULL default 0,
|
31 |
+
`referenced` tinyint NOT NULL default 0,
|
32 |
+
`hub_id` varchar(50) null,
|
33 |
+
`hub_street1` varchar(50) null,
|
34 |
+
`hub_street2` varchar(50) null,
|
35 |
+
`hub_province_or_state` varchar(50) null,
|
36 |
+
`hub_country` varchar(50) null,
|
37 |
+
`hub_postal_code` varchar(50) null,
|
38 |
+
PRIMARY KEY (`ordernumber_id`)
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
40 |
+
|
41 |
+
DROP TABLE IF EXISTS {$this->getTable('pb_pbgsp/inboundparcel')};
|
42 |
+
CREATE TABLE {$this->getTable('pb_pbgsp/inboundparcel')} (
|
43 |
+
`inbound_parcel_id` int(11) unsigned NOT NULL auto_increment,
|
44 |
+
`inbound_parcel` varchar(255) NOT NULL default '',
|
45 |
+
`mage_order_number` varchar(255) NOT NULL default '',
|
46 |
+
`pb_order_number` varchar(255) NOT NULL default '',
|
47 |
+
PRIMARY KEY (`inbound_parcel_id`)
|
48 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
49 |
+
|
50 |
+
");
|
51 |
+
|
52 |
+
$eav = Mage::getResourceModel('catalog/setup', 'catalog_setup');//new Mage_Eav_Model_Entity_Setup('catalog_setup');
|
53 |
+
$eav->removeAttribute('catalog_product','pb_pbgsp_upload');
|
54 |
+
$eav->addAttribute('catalog_product', 'pb_pbgsp_upload', array(
|
55 |
+
'type' => 'datetime',
|
56 |
+
'input' => 'datetime',
|
57 |
+
'label' => 'Last PBGSP upload timestampt',
|
58 |
+
'global' => 2,
|
59 |
+
'user_defined' => 0,
|
60 |
+
'required' => 0,
|
61 |
+
'visible' => 1,
|
62 |
+
'default' => 0
|
63 |
+
|
64 |
+
));
|
65 |
+
$eav->removeAttribute('catalog_category','pb_pbgsp_upload');
|
66 |
+
$eav->addAttribute('catalog_category', 'pb_pbgsp_upload', array(
|
67 |
+
'type' => 'datetime',
|
68 |
+
'input' => 'datetime',
|
69 |
+
'label' => 'Last PBGSP upload timestampt',
|
70 |
+
'global' => 2,
|
71 |
+
'user_defined' => 0,
|
72 |
+
'required' => 0,
|
73 |
+
'visible' => 1,
|
74 |
+
'default' => 0,
|
75 |
+
'group' => 'PBGSP'
|
76 |
+
|
77 |
+
));
|
78 |
+
|
79 |
+
$eav->removeAttribute('catalog_category','pb_pbgsp_upload_active');
|
80 |
+
$eav->addAttribute('catalog_category', 'pb_pbgsp_upload_active', array(
|
81 |
+
'type' => 'int',
|
82 |
+
'input' => 'select',
|
83 |
+
'label' => 'Export to PBGSP',
|
84 |
+
'source' => 'eav/entity_attribute_source_boolean',
|
85 |
+
'global' => 2,
|
86 |
+
'user_defined' => 0,
|
87 |
+
'required' => 0,
|
88 |
+
'visible' => 1,
|
89 |
+
'default' => 1,
|
90 |
+
'group' => 'PBGSP'
|
91 |
+
|
92 |
+
));
|
93 |
+
|
94 |
+
|
95 |
+
$installer->endSetup();
|
96 |
+
?>
|
package.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>pitneybowes_gsp</name>
|
4 |
-
<version>0.
|
5 |
-
<stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
@@ -24,9 +24,9 @@ To learn more, go to <a href="http://www.pb.com/ecom">http://www.pb.com/ec
|
|
24 |
</description>
|
25 |
<notes>Initial Stable GSP release for Magento Connect.</notes>
|
26 |
<authors><author><name>Raymond Lai</name><user>r3lai</user><email>raymond.lai@pb.com</email></author></authors>
|
27 |
-
<date>2015-04
|
28 |
-
<time>
|
29 |
-
<contents><target name="magelocal"><dir name="Pb"><dir name="Pbgsp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Invoice"><file name="Totals.php" hash="
|
30 |
<compatible/>
|
31 |
<dependencies><required><php><min>5.1.0</min><max>5.3.3</max></php><extension><name>gnupg</name><min>1.3.5</min><max>1.3.6</max></extension></required></dependencies>
|
32 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>pitneybowes_gsp</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
24 |
</description>
|
25 |
<notes>Initial Stable GSP release for Magento Connect.</notes>
|
26 |
<authors><author><name>Raymond Lai</name><user>r3lai</user><email>raymond.lai@pb.com</email></author></authors>
|
27 |
+
<date>2015-06-04</date>
|
28 |
+
<time>14:15:41</time>
|
29 |
+
<contents><target name="magelocal"><dir name="Pb"><dir name="Pbgsp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Invoice"><file name="Totals.php" hash="4d860488518cd57f776c3d2fe423437a"/></dir><file name="Totals.php" hash="cf0e69cb9d436ccf2aafb99bd0fc272c"/></dir></dir></dir><dir name="Checkout"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="a8ba337dd2cb0281f95f548a8f69c47a"/></dir></dir></dir><file name="Form.php" hash="82c8f0e9b90991f393d7e04919f8d2f8"/><dir name="Sales"><dir name="Order"><dir name="Invoice"><file name="Totals.php" hash="f2b39fe7a2a19e96edd934c05bac50b1"/></dir><file name="Totals.php" hash="d9dfa66b18a79d1ef5e31607de445207"/></dir></dir></dir><dir name="Model"><file name="Api.php" hash="fa5ee4bb423ddf60c097fb61d12bc43b"/><dir name="Carrier"><file name="ShippingMethod.php" hash="06b0c62606456ec1b9dcd4ea413e6bc4"/></dir><dir name="Catalog"><file name="Category.php" hash="002f69dea2c831e04399600c15885964"/><file name="Cron.php" hash="f6992f831ee453b15a95cffed9332a1f"/><file name="File.php" hash="779960aa2d2ab50382127890c7a0ad87"/><file name="Product.php" hash="d09b2f56cb76a693ef87a8452834e96e"/></dir><file name="Credentials.php" hash="946390c588ec28db30343250e23f988b"/><dir name="Creditmemo"><file name="Duty.php" hash="b123de9cdcaac1de04cdcf94d4d1fc06"/></dir><file name="Handlingoptions.php" hash="36aeb268f7ecb615854039b9981ccf9f"/><file name="Helper.php" hash="18781bf68a57a8c416c1a37f041ac412"/><file name="Inboundparcel.php" hash="8ead6048c8ecb66327e2b83d2af3dcc4"/><dir name="Invoice"><file name="Duty.php" hash="1d531b8c6de4345481caff2cd916f836"/></dir><file name="Messages.php" hash="728b54383aafa7f4e6a7e57202bb813f"/><dir name="Mysql4"><dir name="Inboundparcel"><file name="Collection.php" hash="e1c99046f446067d67b9163151644886"/></dir><file name="Inboundparcel.php" hash="fd0e3e6f43740107583e1ad20c384aea"/><dir name="Ordernumber"><file name="Collection.php" hash="a57c9def45246f684886a89222ff7130"/></dir><file name="Ordernumber.php" hash="bf03953bfcc552fafc142ade3c02fc47"/><dir name="Variable"><file name="Collection.php" hash="230ed58bde61c41735ae9641b5309d2c"/></dir><file name="Variable.php" hash="978acaba585304135920a747e0dbeaaf"/></dir><file name="Observer.php" hash="9ef19992c6015cb6e187802a9307b572"/><file name="Ordernumber.php" hash="14709487c0af7b66f281a50cc9d1b7db"/><dir name="Pdf"><file name="Tax.php" hash="707cc6e01dfd325229c5831ce4cfc4e5"/></dir><dir name="Quote"><file name="Duty.php" hash="8d6d1951ef8e5782c7fa524ea8100764"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="4da3fcbfbbaef186a630cd0d83309af5"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Shipment.php" hash="0d65ba103b988bdade20f087a50cefc9"/></dir></dir><file name="Util.php" hash="7b417bc17989eb5ac8cf6d2de0af9f4f"/><file name="Variable.php" hash="16eea17bd4a8f87d06b879c2ce5f8248"/></dir><file name="README" hash="5baea7c4c231d8cda23465a1abd5427e"/><dir name="data"><dir name="pb_pbgsp_setup"><file name="data-install-1.0.0.php" hash="157ad9a71ff8a03526729ddae484c9dc"/></dir></dir><dir name="etc"><file name="config.xml" hash="93ae6a04d17083ede60045350c8cdd95"/><file name="system.xml" hash="75bf1ced1440e4dce3f7d1b2f2ec7494"/></dir><dir name="sql"><dir name="pbgsp_setup"><file name="mysql4-install-1.0.0.php" hash="c4cd1f91694e74f08fe512534cfbf20c"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Pb_Pbgsp.xml" hash="dc3ea1c2b33fc8e526486c17a24965a4"/></dir></target></contents>
|
30 |
<compatible/>
|
31 |
<dependencies><required><php><min>5.1.0</min><max>5.3.3</max></php><extension><name>gnupg</name><min>1.3.5</min><max>1.3.6</max></extension></required></dependencies>
|
32 |
</package>
|