shipperhq_shipperhq - Version 2.151.0

Version Notes

Fixed issue with inside delivery and limited delivery not being able to be deselected

Download this release

Release Info

Developer Karen Baker
Extension shipperhq_shipperhq
Version 2.151.0
Comparing to
See all releases


Code changes from version 2.52.0 to 2.151.0

Files changed (104) hide show
  1. app/code/community/Shipperhq/Frontend/Block/Checkout/AbstractBlock.php +7 -0
  2. app/code/community/Shipperhq/Frontend/Block/Checkout/Helper.php +107 -27
  3. app/code/community/Shipperhq/Frontend/Block/Checkout/Onepage/Shipping/Method/Available.php +19 -7
  4. app/code/community/Shipperhq/{Pbint/Model/Inboundparcel.php → Frontend/Block/Checkout/Onepage/Shipping/Method/Comments.php} +42 -40
  5. app/code/community/Shipperhq/Paypalexpress/Model/Express/Checkout.php +0 -126
  6. app/code/community/Shipperhq/Paypalexpress/etc/config.xml +0 -47
  7. app/code/community/Shipperhq/Pbint/Block/Adminhtml/System/Upload.php +0 -73
  8. app/code/community/Shipperhq/Pbint/Helper/Data.php +0 -64
  9. app/code/community/Shipperhq/Pbint/Model/Catalog/Category.php +0 -180
  10. app/code/community/Shipperhq/Pbint/Model/Catalog/Cron.php +0 -151
  11. app/code/community/Shipperhq/Pbint/Model/Catalog/File.php +0 -862
  12. app/code/community/Shipperhq/Pbint/Model/Catalog/Product.php +0 -244
  13. app/code/community/Shipperhq/Pbint/Model/Credentials.php +0 -78
  14. app/code/community/Shipperhq/Pbint/Model/Creditmemo/Duty.php +0 -75
  15. app/code/community/Shipperhq/Pbint/Model/Helper.php +0 -224
  16. app/code/community/Shipperhq/Pbint/Model/Invoice/Duty.php +0 -79
  17. app/code/community/Shipperhq/Pbint/Model/Mysql4/Inboundparcel/Collection.php +0 -39
  18. app/code/community/Shipperhq/Pbint/Model/Mysql4/Ordernumber.php +0 -39
  19. app/code/community/Shipperhq/Pbint/Model/Mysql4/Ordernumber/Collection.php +0 -39
  20. app/code/community/Shipperhq/Pbint/Model/Mysql4/Variable.php +0 -39
  21. app/code/community/Shipperhq/Pbint/Model/Mysql4/Variable/Collection.php +0 -39
  22. app/code/community/Shipperhq/Pbint/Model/Observer.php +0 -171
  23. app/code/community/Shipperhq/Pbint/Model/Ordernumber.php +0 -40
  24. app/code/community/Shipperhq/Pbint/Model/Pdf/Duty.php +0 -41
  25. app/code/community/Shipperhq/Pbint/Model/Quote/Duty.php +0 -90
  26. app/code/community/Shipperhq/Pbint/Model/Resource/Mysql4/Setup.php +0 -33
  27. app/code/community/Shipperhq/Pbint/Model/Variable.php +0 -40
  28. app/code/community/Shipperhq/Pbint/README +0 -2
  29. app/code/community/Shipperhq/Pbint/changelog.txt +0 -0
  30. app/code/community/Shipperhq/Pbint/controllers/Adminhtml/ShqpitneyController.php +0 -66
  31. app/code/community/Shipperhq/Pbint/etc/config.xml +0 -248
  32. app/code/community/Shipperhq/Pbint/etc/system.xml +0 -162
  33. app/code/community/Shipperhq/Pbint/sql/shqpbint_setup/mysql4-install-1.0.0.php +0 -72
  34. app/code/community/Shipperhq/Pbint/sql/shqpbint_setup/mysql4-install-1.0.1.php +0 -73
  35. app/code/community/Shipperhq/Pbint/sql/shqpbint_setup/mysql4-upgrade-1.0.0-1.0.1.php +0 -29
  36. app/code/community/Shipperhq/{Pbint/Block/Sales/Order/Duty.php → Shipper/Block/Adminhtml/Carrier/Aboutblank.php} +23 -20
  37. app/code/community/Shipperhq/Shipper/Block/Adminhtml/Carrier/Notify.php +65 -0
  38. app/code/community/Shipperhq/Shipper/Block/Adminhtml/Synchronize/Notify.php +4 -2
  39. app/code/community/Shipperhq/Shipper/Helper/Data.php +299 -73
  40. app/code/community/Shipperhq/Shipper/Model/Adminhtml/System/Config/Source/Shipping/Allmethods.php +74 -0
  41. app/code/community/Shipperhq/Shipper/Model/Carrier/Backup.php +30 -22
  42. app/code/community/Shipperhq/Shipper/Model/Carrier/Convert/AddressMapper.php +8 -2
  43. app/code/community/Shipperhq/Shipper/Model/Carrier/Convert/OrderMapper.php +1 -1
  44. app/code/community/Shipperhq/Shipper/Model/Carrier/Convert/ShipmentMapper.php +1 -1
  45. app/code/community/Shipperhq/Shipper/Model/Carrier/Convert/ShipperMapper.php +52 -18
  46. app/code/community/Shipperhq/Shipper/Model/Carrier/Shipper.php +185 -97
  47. app/code/community/Shipperhq/Shipper/Model/Checkout/Helper.php +9 -3
  48. app/code/community/Shipperhq/Shipper/Model/Observer.php +152 -61
  49. app/code/community/Shipperhq/Shipper/Model/Observer/Order.php +12 -12
  50. app/code/community/Shipperhq/Shipper/Model/Resource/Order/Packages.php +3 -2
  51. app/code/community/Shipperhq/Shipper/Model/Resource/Quote/Packages.php +4 -3
  52. app/code/community/Shipperhq/Shipper/Model/Sales/Quote/Address/Rate.php +2 -4
  53. app/code/community/Shipperhq/Shipper/Model/Source/Freight/Freightclass.php +20 -0
  54. app/code/community/Shipperhq/Shipper/Model/Synchronize.php +17 -16
  55. app/code/community/Shipperhq/Shipper/changelog.txt +93 -0
  56. app/code/community/Shipperhq/Shipper/controllers/Adminhtml/ShqajaxController.php +1 -1
  57. app/code/community/Shipperhq/Shipper/etc/config.xml +38 -3
  58. app/code/community/Shipperhq/Shipper/etc/system.xml +59 -12
  59. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-install-0.0.31.php +911 -0
  60. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-install-0.0.32.php +911 -0
  61. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-install-0.0.33.php +925 -0
  62. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-install-0.0.34.php +932 -0
  63. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-upgrade-0.0.30-0.0.31.php +27 -0
  64. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-upgrade-0.0.31-0.0.32.php +18 -0
  65. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-upgrade-0.0.32-0.0.33.php +20 -0
  66. app/code/community/Shipperhq/Shipper/sql/shipperhq_shipper_setup/mysql4-upgrade-0.0.33-0.0.34.php +19 -0
  67. app/code/community/Webshopapps/Adminshortcut/Helper/Data.php +0 -35
  68. app/code/community/Webshopapps/Adminshortcut/changelog.txt +0 -1
  69. app/code/community/Webshopapps/Adminshortcut/etc/adminhtml.xml +0 -88
  70. app/code/community/Webshopapps/Adminshortcut/etc/config.xml +0 -44
  71. app/design/adminhtml/default/default/layout/shipperhq/pbint.xml +0 -42
  72. app/design/adminhtml/default/default/layout/shipperhq/shipper.xml +1 -0
  73. app/design/adminhtml/default/default/template/shipperhq/frontend/sales/order/create/shipping_method/available.phtml +12 -5
  74. app/design/adminhtml/default/default/template/shipperhq/migrate_extension.phtml +0 -1
  75. app/{code/community/Shipperhq/Pbint/Model/Mysql4/Inboundparcel.php → design/adminhtml/default/default/template/shipperhq/shipper/carrier/notify.phtml} +38 -39
  76. app/design/adminhtml/default/default/template/shipperhq/shipper/synchronize/notify.phtml +1 -1
  77. app/design/adminhtml/default/default/template/shipperhq/upload.phtml +0 -71
  78. app/design/frontend/base/default/layout/shipperhq/pbint.xml +0 -65
  79. app/design/frontend/base/default/template/shipperhq/checkout/cart/rwd/shipping.phtml +15 -1
  80. app/design/frontend/base/default/template/shipperhq/checkout/cart/shipping.phtml +16 -2
  81. app/design/frontend/base/default/template/shipperhq/checkout/multishipping/shipping.phtml +10 -3
  82. app/design/frontend/base/default/template/shipperhq/checkout/onepage/shipping_method/available.phtml +27 -7
  83. app/design/frontend/base/default/template/shipperhq/checkout/onepage/shipping_method/comments.phtml +30 -0
  84. app/design/frontend/base/default/template/shipperhq/checkout/onestepcheckout/pickup_review.phtml +0 -1
  85. app/design/frontend/base/default/template/shipperhq/checkout/onestepcheckout/shipping_method_osc_shq.phtml +25 -8
  86. app/design/frontend/base/default/template/shipperhq/checkout/onestepcheckout/shipping_method_osc_shq_radio.phtml +19 -4
  87. app/etc/modules/Shipperhq_Paypalexpress.xml +0 -12
  88. app/etc/modules/Shipperhq_Pbint.xml +0 -12
  89. app/locale/en_US/template/email/sales/shipperhq_pitney_shipment_new.html +0 -100
  90. js/shipperhq/jquery-loader.js +9 -8
  91. lib/ShipperHQ/Checkout/Cart.php +0 -53
  92. lib/ShipperHQ/Checkout/Item.php +1 -20
  93. lib/ShipperHQ/WS/Client/WebServiceClient.php +8 -3
  94. package.xml +38 -39
  95. skin/adminhtml/default/default/shipperhq/css/calendarbase.css +133 -0
  96. skin/adminhtml/default/default/shipperhq/css/storepickup.css +252 -0
  97. skin/frontend/base/default/css/shipperhq/calendarbase.css +117 -12
  98. skin/frontend/base/default/css/shipperhq/storepickup.css +179 -77
  99. skin/frontend/base/default/images/shipperhq/calendar-blk.svg +25 -0
  100. skin/frontend/base/default/images/shipperhq/calendar-wht.svg +29 -0
  101. skin/frontend/base/default/images/shipperhq/clock-blk.svg +8 -0
  102. skin/frontend/base/default/images/shipperhq/clock-wht.svg +11 -0
  103. skin/frontend/base/default/images/shipperhq/location-blk.svg +11 -0
  104. skin/frontend/base/default/images/shipperhq/location-wht.svg +14 -0
app/code/community/Shipperhq/Frontend/Block/Checkout/AbstractBlock.php CHANGED
@@ -48,5 +48,12 @@ abstract class Shipperhq_Frontend_Block_Checkout_AbstractBlock
48
  {
49
  return $this->_quote;
50
  }
 
 
 
 
 
 
 
51
 
52
  }
48
  {
49
  return $this->_quote;
50
  }
51
+
52
+ public function getStandardErrorMessage()
53
+ {
54
+ $errorString = $this->__("Sorry, no quotes are available for this order at this time.");
55
+ $error = str_replace("'", ''',$errorString);
56
+ return $error;
57
+ }
58
 
59
  }
app/code/community/Shipperhq/Frontend/Block/Checkout/Helper.php CHANGED
@@ -10,11 +10,12 @@ class Shipperhq_Frontend_Block_Checkout_Helper
10
  protected $_calendar;
11
  protected $_rates;
12
  protected $_accessorial;
 
13
 
14
 
15
  /**
16
  * Calendar block name
17
- *
18
  * @var string
19
  */
20
  protected $_calendarBlockType;
@@ -28,7 +29,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
28
 
29
  /**
30
  * Store pickup block name
31
- *
32
  * @var string
33
  */
34
  protected $_storePickupBlockType;
@@ -54,6 +55,20 @@ class Shipperhq_Frontend_Block_Checkout_Helper
54
  */
55
  protected $_freightAccessorialsBlockTemplate;
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  /**
58
  * Sets debug flag
59
  */
@@ -66,7 +81,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
66
 
67
  /**
68
  * Sets up block properties
69
- *
70
  * @param array $options
71
  * @return $this
72
  */
@@ -90,13 +105,19 @@ class Shipperhq_Frontend_Block_Checkout_Helper
90
  if (isset($options['accessorials_template'])) {
91
  $this->setFreightAccessorialsBlockTemplate($options['accessorials_template']);
92
  }
 
 
 
 
 
 
93
  if (isset($options['quote'])) {
94
  $this->setQuote($options['quote']);
95
- }
96
  if (isset($options['address'])) {
97
  $this->setAddress($options['address']);
98
  }
99
-
100
  return $this;
101
  }
102
 
@@ -166,6 +187,10 @@ class Shipperhq_Frontend_Block_Checkout_Helper
166
  $itemsGrouped[$carriergroup]);
167
  $carrierGroupRates[$carriergroup]['plain_item_list']= $itemsGrouped[$carriergroup];
168
  }
 
 
 
 
169
  if(array_key_exists($carriergroup, $carrierGroupErrors)) {
170
  $carrierGroupRates[$carriergroup]['error']= $carrierGroupErrors[$carriergroup];
171
  }
@@ -333,12 +358,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
333
 
334
  public function getMethodTitle($methodTitle, $methodDescription, $includeContainer)
335
  {
336
- $title = $methodTitle;
337
- if($includeContainer) {
338
- $truncatedTitle = str_replace($methodDescription, '', $methodTitle);
339
- $title = '<span class="method-title">'.$truncatedTitle.'</span> <span class="method-extra">'.$methodDescription.'</span>';
340
- }
341
- return $title;
342
  }
343
 
344
  public function showToolTips() {
@@ -478,6 +498,14 @@ class Shipperhq_Frontend_Block_Checkout_Helper
478
  ->toHtml();
479
  }
480
 
 
 
 
 
 
 
 
 
481
  public function isPickupCarrier($rate)
482
  {
483
  if(!Mage::helper('shipperhq_shipper')->isModuleEnabled('Shipperhq_Pickup')) {
@@ -490,10 +518,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
490
  }
491
  return true;
492
  }
493
- if (self::$_debug) {
494
- Mage::helper('wsalogger/log')->postDebug('ShipperHQ Pickup','This carrier is not pickup enabled ',
495
- 'Carrier: ' .$rate->getCode() .', Type : ' .$rate->getCarrierType());
496
- }
497
  return false;
498
  }
499
 
@@ -510,11 +535,6 @@ class Shipperhq_Frontend_Block_Checkout_Helper
510
  }
511
  return true;
512
  }
513
- if (self::$_debug) {
514
- Mage::helper('wsalogger/log')->postDebug('ShipperHQ Freight','Carrier is NOT freight enabled',
515
- 'Carrier : ' . $rate->getCode() .', Is freight rate : ' .$rate->getFreightRate()
516
- );
517
- }
518
  return false;
519
  }
520
 
@@ -525,6 +545,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
525
  return $this->_getAccessorial('freight_'.$carrierCode)
526
  ->setCarriergroupId($carrierGroup)
527
  ->setCarrierCode($carrierCode)
 
528
  ->setName('accessorial_'.$carrierCode)
529
  ->setTemplate($this->getFreightAccessorialsBlockTemplate())
530
  ->toHtml();
@@ -560,9 +581,20 @@ class Shipperhq_Frontend_Block_Checkout_Helper
560
  return $this->_accessorial;
561
  }
562
 
 
 
 
 
 
 
 
 
 
 
 
563
  /**
564
  * Returns a block type, that should be used for a calendar
565
- *
566
  * @return string
567
  */
568
  public function getStorePickUpBlockType()
@@ -572,7 +604,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
572
 
573
  /**
574
  * Sets store pickup block type
575
- *
576
  * @param $blockType
577
  * @return $this
578
  */
@@ -584,7 +616,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
584
 
585
  /**
586
  * Returns calendar block type
587
- *
588
  * @return string
589
  */
590
  public function getCalendarBlockType()
@@ -594,7 +626,7 @@ class Shipperhq_Frontend_Block_Checkout_Helper
594
 
595
  /**
596
  * Sets calendar block type
597
- *
598
  * @param string $blockType
599
  * @return $this
600
  */
@@ -604,6 +636,51 @@ class Shipperhq_Frontend_Block_Checkout_Helper
604
  return $this;
605
  }
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  /**
608
  * Returns a block type, that should be used for a calendar
609
  *
@@ -679,15 +756,13 @@ class Shipperhq_Frontend_Block_Checkout_Helper
679
  {
680
  return $this->_freightAccessorialsBlockType;
681
  }
682
-
683
-
684
 
685
  public function getCarrierName($carrierCode)
686
  {
687
  if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title', $this->getQuote()->getStoreId())) {
688
  return $name;
689
  }
690
-
691
  return $carrierCode;
692
  }
693
 
@@ -695,4 +770,9 @@ class Shipperhq_Frontend_Block_Checkout_Helper
695
  {
696
  return $this->getAddress()->getShippingMethod();
697
  }
 
 
 
 
 
698
  }
10
  protected $_calendar;
11
  protected $_rates;
12
  protected $_accessorial;
13
+ protected $_deliveryComments;
14
 
15
 
16
  /**
17
  * Calendar block name
18
+ *
19
  * @var string
20
  */
21
  protected $_calendarBlockType;
29
 
30
  /**
31
  * Store pickup block name
32
+ *
33
  * @var string
34
  */
35
  protected $_storePickupBlockType;
55
  */
56
  protected $_freightAccessorialsBlockTemplate;
57
 
58
+ /**
59
+ * comments block name
60
+ *
61
+ * @var string
62
+ */
63
+ protected $_deliveryCommentsBlockType;
64
+
65
+ /*
66
+ * comments block template
67
+ *
68
+ * @var string
69
+ */
70
+ protected $_deliveryCommentsBlockTemplate;
71
+
72
  /**
73
  * Sets debug flag
74
  */
81
 
82
  /**
83
  * Sets up block properties
84
+ *
85
  * @param array $options
86
  * @return $this
87
  */
105
  if (isset($options['accessorials_template'])) {
106
  $this->setFreightAccessorialsBlockTemplate($options['accessorials_template']);
107
  }
108
+ if (isset($options['delivery_comments_block'])) {
109
+ $this->setDeliveryCommentsBlockType($options['delivery_comments_block']);
110
+ }
111
+ if (isset($options['delivery_comments_template'])) {
112
+ $this->setDeliveryCommentsBlockTemplate($options['delivery_comments_template']);
113
+ }
114
  if (isset($options['quote'])) {
115
  $this->setQuote($options['quote']);
116
+ }
117
  if (isset($options['address'])) {
118
  $this->setAddress($options['address']);
119
  }
120
+
121
  return $this;
122
  }
123
 
187
  $itemsGrouped[$carriergroup]);
188
  $carrierGroupRates[$carriergroup]['plain_item_list']= $itemsGrouped[$carriergroup];
189
  }
190
+ if($displayMerged && $carriergroup == '') {
191
+ $carrierGroupRates[$carriergroup]['item_list']= $this->getFormattedItemList($address->getAllItems());
192
+ $carrierGroupRates[$carriergroup]['plain_item_list']= $address->getAllItems();
193
+ }
194
  if(array_key_exists($carriergroup, $carrierGroupErrors)) {
195
  $carrierGroupRates[$carriergroup]['error']= $carrierGroupErrors[$carriergroup];
196
  }
358
 
359
  public function getMethodTitle($methodTitle, $methodDescription, $includeContainer)
360
  {
361
+ return Mage::helper('shipperhq_shipper')->getMethodTitle($methodTitle, $methodDescription, $includeContainer);
 
 
 
 
 
362
  }
363
 
364
  public function showToolTips() {
498
  ->toHtml();
499
  }
500
 
501
+ public function getDeliveryCommentsHtml()
502
+ {
503
+ return $this->_getDeliveryComments()
504
+ ->setName('delivery_comments')
505
+ ->setTemplate($this->getDeliveryCommentsBlockTemplate())
506
+ ->toHtml();
507
+ }
508
+
509
  public function isPickupCarrier($rate)
510
  {
511
  if(!Mage::helper('shipperhq_shipper')->isModuleEnabled('Shipperhq_Pickup')) {
518
  }
519
  return true;
520
  }
521
+
 
 
 
522
  return false;
523
  }
524
 
535
  }
536
  return true;
537
  }
 
 
 
 
 
538
  return false;
539
  }
540
 
545
  return $this->_getAccessorial('freight_'.$carrierCode)
546
  ->setCarriergroupId($carrierGroup)
547
  ->setCarrierCode($carrierCode)
548
+ ->setCarrierType($carrierType)
549
  ->setName('accessorial_'.$carrierCode)
550
  ->setTemplate($this->getFreightAccessorialsBlockTemplate())
551
  ->toHtml();
581
  return $this->_accessorial;
582
  }
583
 
584
+ protected function _getDeliveryComments($name = '')
585
+ {
586
+ if (!$this->_deliveryComments) {
587
+ $this->_deliveryComments = $this->getLayout()->createBlock($this->getDeliveryCommentsBlockType(), $name);
588
+ $this->_deliveryComments->setQuote($this->getQuote());
589
+ $this->_deliveryComments->setAddress($this->getAddress());
590
+ }
591
+
592
+ return $this->_deliveryComments;
593
+ }
594
+
595
  /**
596
  * Returns a block type, that should be used for a calendar
597
+ *
598
  * @return string
599
  */
600
  public function getStorePickUpBlockType()
604
 
605
  /**
606
  * Sets store pickup block type
607
+ *
608
  * @param $blockType
609
  * @return $this
610
  */
616
 
617
  /**
618
  * Returns calendar block type
619
+ *
620
  * @return string
621
  */
622
  public function getCalendarBlockType()
626
 
627
  /**
628
  * Sets calendar block type
629
+ *
630
  * @param string $blockType
631
  * @return $this
632
  */
636
  return $this;
637
  }
638
 
639
+ /**
640
+ * Returns comments block type
641
+ *
642
+ * @return string
643
+ */
644
+ public function getDeliveryCommentsBlockType()
645
+ {
646
+ return $this->_deliveryCommentsBlockType;
647
+ }
648
+
649
+ /**
650
+ * Sets comments block type
651
+ *
652
+ * @param string $blockType
653
+ * @return $this
654
+ */
655
+ public function setDeliveryCommentsBlockType($blockType)
656
+ {
657
+ $this->_deliveryCommentsBlockType = $blockType;
658
+ return $this;
659
+ }
660
+
661
+ /**
662
+ * Returns a block type, that should be used for a comments
663
+ *
664
+ * @return string
665
+ */
666
+ public function getDeliveryCommentsBlockTemplate()
667
+ {
668
+ return $this->_deliveryCommentsBlockTemplate;
669
+ }
670
+
671
+
672
+ /**
673
+ * Sets calendar block type
674
+ *
675
+ * @param string $blockType
676
+ * @return $this
677
+ */
678
+ public function setDeliveryCommentsBlockTemplate($template)
679
+ {
680
+ $this->_deliveryCommentsBlockTemplate = $template;
681
+ return $this;
682
+ }
683
+
684
  /**
685
  * Returns a block type, that should be used for a calendar
686
  *
756
  {
757
  return $this->_freightAccessorialsBlockType;
758
  }
 
 
759
 
760
  public function getCarrierName($carrierCode)
761
  {
762
  if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title', $this->getQuote()->getStoreId())) {
763
  return $name;
764
  }
765
+
766
  return $carrierCode;
767
  }
768
 
770
  {
771
  return $this->getAddress()->getShippingMethod();
772
  }
773
+
774
+ public function showDeliveryComments()
775
+ {
776
+ return Mage::getStoreConfig('carriers/shipper/delivery_comments');
777
+ }
778
  }
app/code/community/Shipperhq/Frontend/Block/Checkout/Onepage/Shipping/Method/Available.php CHANGED
@@ -30,14 +30,14 @@
30
 
31
  /**
32
  * Provides proxy methods for helper block
33
- *
34
- * Supplies helper block with render information
35
  */
36
  class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
37
  {
38
  /**
39
  * Returns a helper block, that is used to retrieve all data
40
- *
41
  * @return Shipperhq_Frontend_Block_Checkout_Helper
42
  */
43
  public function getHelperBlock()
@@ -55,12 +55,14 @@ class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Available extend
55
  'pickup_template' => 'shipperhq/pickup/checkout/onepage/shipping_method/storepickup.phtml',
56
  'accessorials_block' => 'shipperhq_freight/checkout_onepage_shipping_method_accessorials',
57
  'accessorials_template' => 'shipperhq/freight/checkout/onepage/shipping_method/accessorials.phtml',
 
 
58
  'quote' => $this->getQuote(),
59
  'address' => $this->getAddress()
60
  ));
61
  }
62
-
63
-
64
  return $this->_helperBlock;
65
  }
66
 
@@ -91,7 +93,7 @@ class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Available extend
91
  return $this->getHelperBlock()->getShippingMethodsSelect($name, $id, $value, $rates, $sole);
92
  }
93
 
94
-
95
  public function isShippingMethodSelected($rates)
96
  {
97
  return $this->getHelperBlock()->isShippingMethodSelected($rates);
@@ -135,7 +137,7 @@ class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Available extend
135
  {
136
  return $this->getHelperBlock()->getStorepickupHtml($carrierCode, $carrierType, $carriergroup);
137
  }
138
-
139
  public function getCalendarHtml($carriergroup, $code, $soleMethod = false)
140
  {
141
  return $this->getHelperBlock()->getCalendarHtml($carriergroup, $code, $soleMethod);
@@ -155,4 +157,14 @@ class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Available extend
155
  {
156
  return $this->getHelperBlock()->getFreightAccessorialsHtml($carrerigroup, $carrierCode, $carrierType);
157
  }
 
 
 
 
 
 
 
 
 
 
158
  }
30
 
31
  /**
32
  * Provides proxy methods for helper block
33
+ *
34
+ * Supplies helper block with render information
35
  */
36
  class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
37
  {
38
  /**
39
  * Returns a helper block, that is used to retrieve all data
40
+ *
41
  * @return Shipperhq_Frontend_Block_Checkout_Helper
42
  */
43
  public function getHelperBlock()
55
  'pickup_template' => 'shipperhq/pickup/checkout/onepage/shipping_method/storepickup.phtml',
56
  'accessorials_block' => 'shipperhq_freight/checkout_onepage_shipping_method_accessorials',
57
  'accessorials_template' => 'shipperhq/freight/checkout/onepage/shipping_method/accessorials.phtml',
58
+ 'delivery_comments_block' => 'shipperhq_frontend/checkout_onepage_shipping_method_comments',
59
+ 'delivery_comments_template' => 'shipperhq/checkout/onepage/shipping_method/comments.phtml',
60
  'quote' => $this->getQuote(),
61
  'address' => $this->getAddress()
62
  ));
63
  }
64
+
65
+
66
  return $this->_helperBlock;
67
  }
68
 
93
  return $this->getHelperBlock()->getShippingMethodsSelect($name, $id, $value, $rates, $sole);
94
  }
95
 
96
+
97
  public function isShippingMethodSelected($rates)
98
  {
99
  return $this->getHelperBlock()->isShippingMethodSelected($rates);
137
  {
138
  return $this->getHelperBlock()->getStorepickupHtml($carrierCode, $carrierType, $carriergroup);
139
  }
140
+
141
  public function getCalendarHtml($carriergroup, $code, $soleMethod = false)
142
  {
143
  return $this->getHelperBlock()->getCalendarHtml($carriergroup, $code, $soleMethod);
157
  {
158
  return $this->getHelperBlock()->getFreightAccessorialsHtml($carrerigroup, $carrierCode, $carrierType);
159
  }
160
+
161
+ public function showDeliveryComments()
162
+ {
163
+ return $this->getHelperBlock()->showDeliveryComments();
164
+ }
165
+
166
+ public function getDeliveryCommentsHtml()
167
+ {
168
+ return $this->getHelperBlock()->getDeliveryCommentsHtml();
169
+ }
170
  }
app/code/community/Shipperhq/{Pbint/Model/Inboundparcel.php → Frontend/Block/Checkout/Onepage/Shipping/Method/Comments.php} RENAMED
@@ -1,40 +1,42 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * Webshopapps Shipping Module
6
- *
7
- * NOTICE OF LICENSE
8
- *
9
- * This source file is subject to the Open Software License (OSL 3.0)
10
- * that is bundled with this package in the file LICENSE.txt.
11
- * It is also available through the world-wide-web at this URL:
12
- * http://opensource.org/licenses/osl-3.0.php
13
- * If you did not receive a copy of the license and are unable to
14
- * obtain it through the world-wide-web, please send an email
15
- * to license@magentocommerce.com so we can send you a copy immediately.
16
- *
17
- * DISCLAIMER
18
- *
19
- * Do not edit or add to this file if you wish to upgrade Magento to newer
20
- * versions in the future. If you wish to customize Magento for your
21
- * needs please refer to http://www.magentocommerce.com for more information.
22
- *
23
- * Shipper HQ Pitney Bowes International
24
- *
25
- * @category ShipperHQ
26
- * @package ShipperHQ_Shipping_Carrier
27
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
28
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
- * @author ShipperHQ Team sales@shipperhq.com
30
- */
31
- class Shipperhq_Pbint_Model_Inboundparcel extends Mage_Core_Model_Abstract
32
- {
33
- public function _construct()
34
- {
35
- parent::_construct();
36
- $this->_init('shipperhq_pbint/inboundparcel');
37
- }
38
- }
39
-
40
- ?>
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Webshopapps Shipping Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * Shipper HQ Shipping
23
+ *
24
+ * @category ShipperHQ
25
+ * @package ShipperHQ_Shipping_Carrier
26
+ * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @author ShipperHQ Team sales@shipperhq.com
29
+ */
30
+
31
+ /**
32
+ * Provides proxy methods for helper block
33
+ *
34
+ * Supplies helper block with render information
35
+ */
36
+ class Shipperhq_Frontend_Block_Checkout_Onepage_Shipping_Method_Comments extends Shipperhq_Frontend_Block_Checkout_AbstractBlock
37
+ {
38
+ public function getDeliveryCommentsInitialText()
39
+ {
40
+ return Mage::getStoreConfig('carriers/shipper/delivery_comments_text');
41
+ }
42
+ }
app/code/community/Shipperhq/Paypalexpress/Model/Express/Checkout.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Webshopapps Shipping Module
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * DISCLAIMER
17
- *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
- *
22
- * Shipper HQ Shipping
23
- *
24
- * @category ShipperHQ
25
- * @package ShipperHQ_Shipping_Carrier
26
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
27
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
- * @author ShipperHQ Team sales@shipperhq.com
29
- *
30
- * ST_Core_Model_Resource_Iterator_Batched : Kalen Jordan
31
- */
32
- class Shipperhq_Paypalexpress_Model_Express_Checkout extends Mage_Paypal_Model_Express_Checkout
33
- {
34
-
35
- /*
36
- * Resolve bug where PayPal displays the code instead of the name
37
- */
38
- protected function _prepareShippingOptions(
39
- Mage_Sales_Model_Quote_Address $address,
40
- $mayReturnEmpty = false, $calculateTax = false
41
- ) {
42
- $options = array(); $i = 0; $iMin = false; $min = false;
43
- $userSelectedOption = null;
44
-
45
- foreach ($address->getGroupedAllShippingRates() as $group) {
46
- foreach ($group as $rate) {
47
- $amount = (float)$rate->getPrice();
48
- if ($rate->getErrorMessage()) {
49
- continue;
50
- }
51
- $isDefault = $address->getShippingMethod() === $rate->getCode();
52
- $amountExclTax = Mage::helper('tax')->getShippingPrice($amount, false, $address);
53
- $amountInclTax = Mage::helper('tax')->getShippingPrice($amount, true, $address);
54
-
55
- $options[$i] = new Varien_Object(array(
56
- 'is_default' => $isDefault,
57
- 'name' => $rate->getCode(),
58
- 'code' => trim("{$rate->getCarrierTitle()} - {$rate->getMethodTitle()}", ' -'),
59
- 'amount' => $amountExclTax,
60
- ));
61
- if ($calculateTax) {
62
- $options[$i]->setTaxAmount(
63
- $amountInclTax - $amountExclTax
64
- + $address->getTaxAmount() - $address->getShippingTaxAmount()
65
- );
66
- }
67
- if ($isDefault) {
68
- $userSelectedOption = $options[$i];
69
- }
70
- if (false === $min || $amountInclTax < $min) {
71
- $min = $amountInclTax;
72
- $iMin = $i;
73
- }
74
- $i++;
75
- }
76
- }
77
-
78
- if ($mayReturnEmpty && is_null($userSelectedOption)) {
79
- $options[] = new Varien_Object(array(
80
- 'is_default' => true,
81
- 'code' => Mage::helper('paypal')->__('N/A'),
82
- 'name' => 'no_rate',
83
- 'amount' => 0.00,
84
- ));
85
- if ($calculateTax) {
86
- $options[$i]->setTaxAmount($address->getTaxAmount());
87
- }
88
- } elseif (is_null($userSelectedOption) && isset($options[$iMin])) {
89
- $options[$iMin]->setIsDefault(true);
90
- }
91
-
92
- // Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
93
- if (count($options) > 10) {
94
- usort($options, array(get_class($this),'cmpShippingOptions'));
95
- array_splice($options, 10);
96
- // User selected option will be always included in options list
97
- if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) {
98
- $options[9] = $userSelectedOption;
99
- }
100
- }
101
-
102
- return $options;
103
- }
104
-
105
-
106
- /*
107
- * Reverse code and name in option matching to encompass fix above
108
- *
109
- */
110
- protected function _matchShippingMethodCode(Mage_Sales_Model_Quote_Address $address, $selectedCode)
111
- {
112
- $options = $this->_prepareShippingOptions($address, false);
113
- foreach ($options as $option) {
114
- if ($selectedCode === $option['code'] // the proper case as outlined in documentation
115
- || $selectedCode === $option['name'] // workaround: PayPal may return name instead of the code
116
- // workaround: PayPal may concatenate code and name, and return it instead of the code:
117
- || $selectedCode === "{$option['code']} {$option['name']}"
118
- ) {
119
- return $option['name'];
120
- }
121
- }
122
- return '';
123
- }
124
-
125
-
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Shipperhq/Paypalexpress/etc/config.xml DELETED
@@ -1,47 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- *
5
- * Webshopapps Shipping Module
6
- *
7
- * NOTICE OF LICENSE
8
- *
9
- * This source file is subject to the Open Software License (OSL 3.0)
10
- * that is bundled with this package in the file LICENSE.txt.
11
- * It is also available through the world-wide-web at this URL:
12
- * http://opensource.org/licenses/osl-3.0.php
13
- * If you did not receive a copy of the license and are unable to
14
- * obtain it through the world-wide-web, please send an email
15
- * to license@magentocommerce.com so we can send you a copy immediately.
16
- *
17
- * DISCLAIMER
18
- *
19
- * Do not edit or add to this file if you wish to upgrade Magento to newer
20
- * versions in the future. If you wish to customize Magento for your
21
- * needs please refer to http://www.magentocommerce.com for more information.
22
- *
23
- * Shipper HQ Shipping
24
- *
25
- * @category ShipperHQ
26
- * @package ShipperHQ_Shipping_Carrier
27
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
28
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
- * @author ShipperHQ Team sales@shipperhq.com
30
- */
31
- -->
32
- <config>
33
- <modules>
34
- <Shipperhq_Paypalexpress>
35
- <version>0.0.1</version>
36
- </Shipperhq_Paypalexpress>
37
- </modules>
38
- <global>
39
- <models>
40
- <paypal>
41
- <rewrite>
42
- <express_checkout>Shipperhq_Paypalexpress_Model_Express_Checkout</express_checkout>
43
- </rewrite>
44
- </paypal>
45
- </models>
46
- </global>
47
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Shipperhq/Pbint/Block/Adminhtml/System/Upload.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * Webshopapps Shipping Module
6
- *
7
- * NOTICE OF LICENSE
8
- *
9
- * This source file is subject to the Open Software License (OSL 3.0)
10
- * that is bundled with this package in the file LICENSE.txt.
11
- * It is also available through the world-wide-web at this URL:
12
- * http://opensource.org/licenses/osl-3.0.php
13
- * If you did not receive a copy of the license and are unable to
14
- * obtain it through the world-wide-web, please send an email
15
- * to license@magentocommerce.com so we can send you a copy immediately.
16
- *
17
- * DISCLAIMER
18
- *
19
- * Do not edit or add to this file if you wish to upgrade Magento to newer
20
- * versions in the future. If you wish to customize Magento for your
21
- * needs please refer to http://www.magentocommerce.com for more information.
22
- *
23
- * Shipper HQ Pitney Bowes International
24
- *
25
- * @category ShipperHQ
26
- * @package ShipperHQ
27
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
28
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
- * @author ShipperHQ Team sales@shipperhq.com
30
- */
31
- class Shipperhq_Pbint_Block_Adminhtml_System_Upload extends Mage_Adminhtml_Block_System_Config_Form_Field
32
- {
33
-
34
- protected function _prepareLayout()
35
- {
36
- parent::_prepareLayout();
37
- if (!$this->getTemplate()) {
38
- $this->setTemplate('shipperhq/upload.phtml');
39
- }
40
- return $this;
41
- }
42
-
43
- /**
44
- * Unset some non-related element parameters
45
- *
46
- * @param Varien_Data_Form_Element_Abstract $element
47
- * @return string
48
- */
49
- public function render(Varien_Data_Form_Element_Abstract $element)
50
- {
51
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
52
- return parent::render($element);
53
- }
54
-
55
- /**
56
- * Get the button and scripts contents
57
- *
58
- * @param Varien_Data_Form_Element_Abstract $element
59
- * @return string
60
- */
61
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
62
- {
63
- $originalData = $element->getOriginalData();
64
- $this->addData(array(
65
- 'button_label' => Mage::helper('customer')->__($originalData['button_label']),
66
- 'html_id' => $element->getHtmlId(),
67
- 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/Shqpitney/uploadcatalog')
68
- ));
69
-
70
- return $this->_toHtml();
71
- }
72
-
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Shipperhq/Pbint/Helper/Data.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Webshopapps Shipping Module
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * DISCLAIMER
17
- *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
- *
22
- * Shipper HQ Pitney Bowes International
23
- *
24
- * @category ShipperHQ
25
- * @package ShipperHQ
26
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
27
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
- * @author ShipperHQ Team sales@shipperhq.com
29
- */
30
-
31
- class Shipperhq_Pbint_Helper_Data extends Mage_Core_Helper_Abstract
32
- {
33
- protected static $_debug;
34
- protected static $code = 'pitney';
35
- /**
36
- * Retrieve debug configuration
37
- * @return boolean
38
- */
39
- public function isDebug()
40
- {
41
- if (self::$_debug == NULL) {
42
- self::$_debug = Mage::helper('wsalogger')->isDebug('Shipperhq_Pbint');
43
- }
44
- return self::$_debug;
45
- }
46
-
47
- public function isPbOrder($carrierType)
48
- {
49
- if($carrierType == self::$code) {
50
- if ($this->isDebug()) {
51
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
52
- 'Carrier type is Pitney Bowes International via ShipperHQ', $carrierType);
53
- }
54
- return true;
55
- }
56
- if ($this->isDebug()) {
57
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
58
- 'Carrier type is not Pitney Bowes International via ShipperHQ', $carrierType);
59
-
60
- }
61
- return false;
62
-
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Shipperhq/Pbint/Model/Catalog/Category.php DELETED
@@ -1,180 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * Webshopapps Shipping Module
6
- *
7
- * NOTICE OF LICENSE
8
- *
9
- * This source file is subject to the Open Software License (OSL 3.0)
10
- * that is bundled with this package in the file LICENSE.txt.
11
- * It is also available through the world-wide-web at this URL:
12
- * http://opensource.org/licenses/osl-3.0.php
13
- * If you did not receive a copy of the license and are unable to
14
- * obtain it through the world-wide-web, please send an email
15
- * to license@magentocommerce.com so we can send you a copy immediately.
16
- *
17
- * DISCLAIMER
18
- *
19
- * Do not edit or add to this file if you wish to upgrade Magento to newer
20
- * versions in the future. If you wish to customize Magento for your
21
- * needs please refer to http://www.magentocommerce.com for more information.
22
- *
23
- * Shipper HQ Pitney Bowes International
24
- *
25
- * @category ShipperHQ
26
- * @package ShipperHQ_Shipping_Carrier
27
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
28
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
- * @author ShipperHQ Team sales@shipperhq.com
30
- */
31
- class Shipperhq_Pbint_Model_Catalog_Category
32
- {
33
- protected $category;
34
- private static $roots;
35
- protected $url;
36
- protected $_debug;
37
-
38
- public function __construct($id, $url = null)
39
- {
40
-
41
- $this->_debug = Mage::helper('shipperhq_pbint')->isDebug();
42
- if (gettype($id) == "object" && $id instanceOf Mage_Catalog_Model_Category) {
43
- $this->category = $id;
44
- } else {
45
- $this->category = Mage::getModel('catalog/category')->load($id);
46
- }
47
- $this->url = $url;
48
- }
49
-
50
- public function getCategory()
51
- {
52
- return $this->category;
53
- }
54
-
55
- public function getName()
56
- {
57
- return $this->category->getName();
58
- }
59
-
60
- public function getCode()
61
- {
62
- return $this->category->getId();
63
- }
64
-
65
- public function getUrl()
66
- {
67
- if ($this->_debug) {
68
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
69
- 'Category processing, url is ', $this->category->getUrl() );
70
- }
71
- if ($this->url)
72
- return $this->url;
73
- return $this->category->getUrl();
74
- }
75
-
76
- public function isRoot()
77
- {
78
- if (!$this->category->getParentId()) {
79
- return true;
80
- }
81
- if (!self::$roots) {
82
- $categoryOp = new Mage_Adminhtml_Block_Catalog_Category_Abstract();
83
- self::$roots = $categoryOp->getRootIds();
84
- }
85
- foreach (self::$roots as $rootId) {
86
- if ($this->getCode() == $rootId) {
87
- return true;
88
- }
89
- }
90
- return false;
91
- }
92
-
93
- public function getParentCode()
94
- {
95
- return $this->category->getParentId();
96
- }
97
-
98
- public function writeToFile($file)
99
- {
100
- $name = Shipperhq_Pbint_Model_Catalog_File::stripHtml($this->getName());
101
- $name = preg_replace("/[,.\-\+=;:\\(){}\[\]@?%$#]/", '', $name);
102
- $parentCateID = '';
103
- if ($this->getParentCode() != 1 && !$this->isRoot()) {
104
- $parentCateID = $this->getParentCode();
105
- }
106
- fputcsv($file, array($this->getCode(), $parentCateID, $name, '', $this->getUrl()));
107
- }
108
-
109
- public function upload()
110
- {
111
- if ($this->_debug) {
112
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
113
- 'Uploading category: ', $this->category->getName() . "... " );
114
- }
115
-
116
- if (Shipperhq_Pbint_Model_Api::addCategory($this)) {
117
- if ($this->_debug) {
118
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
119
- 'Uploading category result: ', 'OK');
120
- }
121
- } else {
122
- if ($this->_debug) {
123
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
124
- 'Uploading category result: ', 'Failed');
125
- }
126
- }
127
- $products = $this->category->getProductCollection();
128
-
129
- foreach ($products as $product) {
130
- $clearPathProduct = new Shipperhq_Pbint_Model_Catalog_Product($product);
131
- if ($this->_debug) {
132
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
133
- 'Uploading product: ',$clearPathProduct->getName() . "... ");
134
- }
135
- if (Shipperhq_Pbint_Model_Api::addCommodity($clearPathProduct)) {
136
- if ($this->_debug) {
137
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
138
- 'Uploading product: ',$clearPathProduct->getName() . " - OK");
139
- }
140
- } else {
141
- if ($this->_debug) {
142
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
143
- 'Uploading product: ',$clearPathProduct->getName() . " - Failed");
144
- }
145
- }
146
- }
147
-
148
-
149
- $children = $this->category->getChildrenCategories();
150
-
151
- // TODO: this code will run out of memory if there are a lot of categories....
152
- // Need to convert the recursive call to a loop at some point.
153
- foreach ($children as $child) {
154
- $childCategory = new Shipperhq_Pbint_Model_Catalog_Category($child);
155
- $childCategory->upload();
156
- }
157
- }
158
-
159
- // TODO This fuction starts at the Magento root and its not very efficient... see isRoot for proper implementation.
160
- // This function is only used by the API upload.
161
- public static function getAllRootCategories()
162
- {
163
- $roots = array();
164
-
165
- $categories = Mage::getModel('catalog/category')->getCollection(); //->getSelect()->order(array('IF(`id`>0, `id`, 9999) ASC'));
166
- $categories = $categories->getIterator();
167
-
168
- foreach ($categories as $category) {
169
- $parents = $category->getParentId();
170
- if (!$parents) {
171
- $rootCategory = new Shipperhq_Pbint_Model_Catalog_Category($category->getId());
172
- array_push($roots, $rootCategory);
173
- }
174
- }
175
- return $roots;
176
- }
177
-
178
- }
179
-
180
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Shipperhq/Pbint/Model/Catalog/Cron.php DELETED
@@ -1,151 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * Webshopapps Shipping Module
6
- *
7
- * NOTICE OF LICENSE
8
- *
9
- * This source file is subject to the Open Software License (OSL 3.0)
10
- * that is bundled with this package in the file LICENSE.txt.
11
- * It is also available through the world-wide-web at this URL:
12
- * http://opensource.org/licenses/osl-3.0.php
13
- * If you did not receive a copy of the license and are unable to
14
- * obtain it through the world-wide-web, please send an email
15
- * to license@magentocommerce.com so we can send you a copy immediately.
16
- *
17
- * DISCLAIMER
18
- *
19
- * Do not edit or add to this file if you wish to upgrade Magento to newer
20
- * versions in the future. If you wish to customize Magento for your
21
- * needs please refer to http://www.magentocommerce.com for more information.
22
- *
23
- * Shipper HQ Pitney Bowes International
24
- *
25
- * @category ShipperHQ
26
- * @package ShipperHQ_Shipping_Carrier
27
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
28
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
- * @author ShipperHQ Team sales@shipperhq.com
30
- */
31
- class Shipperhq_Pbint_Model_Catalog_Cron
32
- {
33
-
34
- private $lastDiff;
35
- private $lastFull;
36
-
37
- protected $_debug;
38
-
39
- public function catalogSync()
40
- {
41
- $this->_debug = Mage::helper('shipperhq_pbint')->isDebug();
42
- if ($this->_debug) {
43
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
44
- 'Catalog synch', 'Synchronization starting');
45
- }
46
- $diffPeriod = Mage::getStoreConfig('shipperhqpitney/shqpbint/catalog_diff');
47
- $fullPeriod = Mage::getStoreConfig('shipperhqpitney/shqpbint/catalog_full');
48
-
49
- $collection = Mage::getModel("shipperhq_pbint/variable")->getCollection();
50
- foreach ($collection as $variable) {
51
- if ($this->_debug) {
52
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
53
- 'Processing: ', $variable->getName() . " -> " . $variable->getValue());
54
- }
55
- if ($variable->getName() == "lastFull") {
56
- $this->lastFull = $variable;
57
- }
58
- if ($variable->getName() == "lastDiff") {
59
- $this->lastDiff = $variable;
60
- }
61
- }
62
-
63
-
64
- $appRoot = Mage::getRoot();
65
- $mageRoot = dirname($appRoot);
66
- $configOptions = Mage::getModel('core/config_options');
67
- $configOptions->createDirIfNotExists($mageRoot . '/var/pbint');
68
- chmod($mageRoot . '/var/pbint/', 0777);
69
-
70
- if (!isset($this->lastFull) || $this->lastFull->getValue() < time() - $fullPeriod * 24 * 3600) {
71
- // Full catalog upload needed
72
- $this->uploadCatalog();
73
- } else if (!isset($this->lastDiff) && $this->lastFull->getValue() < time() - $diffPeriod * 3600) {
74
- // First catalog diff upload
75
- $this->uploadCatalog($this->lastFull);
76
- } else if (isset($this->lastDiff) && ($this->lastDiff->getValue() < time() - $diffPeriod * 3600 &&
77
- $this->lastFull->getValue() < time() - $diffPeriod * 3600)
78
- ) {
79
- // Catalog diff upload
80
- $this->uploadCatalog($this->lastDiff);
81
- } else {
82
- if ($this->_debug) {
83
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
84
- 'PB Export cron.', 'Do not export catalog');
85
- }
86
- }
87
-
88
- }
89
-
90
- public function uploadCatalog($lastDiff = false)
91
- {
92
- $this->_debug = Mage::helper('shipperhq_pbint')->isDebug();
93
- if (!$lastDiff) {
94
- if ($this->_debug) {
95
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
96
- 'PB Synch', 'Full catalog upload');
97
- }
98
- $file = new Shipperhq_Pbint_Model_Catalog_File();
99
- if (isset($this->lastFull)) {
100
- $this->lastFull->setValue(time());
101
- } else {
102
- $this->lastFull = Mage::getModel("shipperhq_pbint/variable");
103
- $this->lastFull->setName("lastFull");
104
- $this->lastFull->setValue(time());
105
- }
106
- $this->lastFull->save();
107
- } else {
108
- if ($this->_debug) {
109
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
110
- 'PB Synch', 'Catalog diff');
111
- }
112
- $file = new Shipperhq_Pbint_Model_Catalog_File($lastDiff->getValue());
113
- if (isset($this->lastDiff)) {
114
- $this->lastDiff->setValue(time());
115
- } else {
116
- $this->lastDiff = Mage::getModel("shipperhq_pbint/variable");
117
- $this->lastDiff->setName("lastDiff");
118
- $this->lastDiff->setValue(time());
119
- }
120
- $this->lastDiff->save();
121
- }
122
-
123
- if ($this->_debug) {
124
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
125
- 'Catalog synch', 'Create function started');
126
- }
127
- $result = $file->createNew();
128
- if ($this->_debug) {
129
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
130
- 'Catalog synch', 'Create function complete');
131
- }
132
-
133
- $result = $file->upload();
134
- $file->logProdWithoutCategories();
135
- if ($this->_debug) {
136
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
137
- 'PB Synch', 'Upload Complete');
138
- }
139
- return $result;
140
- }
141
-
142
- public function processStatusNotifications()
143
- {
144
- $file = new Shipperhq_Pbint_Model_Catalog_File();
145
- $file->processStatusNotifications();
146
- }
147
-
148
- }
149
-
150
-
151
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Shipperhq/Pbint/Model/Catalog/File.php DELETED
@@ -1,862 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Webshopapps Shipping Module
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * DISCLAIMER
17
- *
18
- * Do not edit or add to this file if you wish to upgrade Magento to newer
19
- * versions in the future. If you wish to customize Magento for your
20
- * needs please refer to http://www.magentocommerce.com for more information.
21
- *
22
- * Shipper HQ Pitney Bowes International
23
- *
24
- * @category ShipperHQ
25
- * @package ShipperHQ_Shipping_Carrier
26
- * @copyright Copyright (c) 2014 Zowta LLC (http://www.ShipperHQ.com)
27
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
- * @author ShipperHQ Team sales@shipperhq.com
29
- */
30
- /* Creates a temporary file containing a Pb catalog xml file. Because of possible PHP timeouts the creation of the
31
- * xml file is done in concrete steps that can be resumed in case of a timeout.
32
- */
33
-
34
- class Shipperhq_Pbint_Model_Catalog_File
35
- {
36
-
37
-
38
- private $file;
39
- private $filename;
40
- private $lastDiff;
41
- private $productIds;
42
- private $lastFileName;
43
-
44
- protected $_debug;
45
-
46
- public function __construct($lastDiff = false)
47
- {
48
- $this->lastDiff = $lastDiff;
49
- $this->productIds = array();
50
- }
51
-
52
- private function _getTempDir()
53
- {
54
- $appRoot = Mage::getRoot();
55
- $mageRoot = dirname($appRoot);
56
- $configOptions = Mage::getModel('core/config_options');
57
- $tmpDir = $mageRoot . '/var/pbint/tmp/';
58
- $configOptions->createDirIfNotExists($tmpDir);
59
- chmod($tmpDir, 0777);
60
- return $tmpDir;
61
- }
62
-
63
-
64
- private function _getDataFileName($dataFeedName, $part = null)
65
- {
66
- $partName = '';
67
- if ($part)
68
- $partName = '_part' . $part;
69
- $fileName = Shipperhq_Pbint_Model_Credentials::getCatalogSenderID() . "_" . $dataFeedName . "_update_" . Shipperhq_Pbint_Model_Credentials::getPBID() . '_' . date('Ymd_His') . '_' . mt_rand(100000, 999999);
70
- if ($part == 1)
71
- $this->lastFileName = $fileName;
72
- else
73
- $fileName = $this->lastFileName;
74
- return $fileName . $partName . '.csv';
75
- }
76
-
77
- private function _createNewCommoditiyFile($part = null)
78
- {
79
- $fileName = $this->_getDataFileName('catalog', $part);
80
- if(is_resource($this->file)) {
81
- fflush($this->file);
82
-
83
- fclose($this->file);
84
-
85
- }
86
-
87
- $this->filename = $this->_getTempDir() . $fileName;
88
- if ($this->_debug) {
89
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
90
- 'Product catalog upload - creating new commodity file', $fileName);
91
- }
92
- try {
93
- $this->file = fopen($this->filename, "w+");
94
- chmod($this->filename, 0777);
95
- }
96
- catch(Exception $e) {
97
- if ($this->_debug) {
98
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
99
- 'Product catalog upload exception during file opening', $e->getMessage());
100
- }
101
- }
102
-
103
- //add header row
104
- fputcsv($this->file, array('MERCHANT_COMMODITY_REF_ID', 'COMMODITY_NAME_TITLE', 'SHORT_DESCRIPTION',
105
- 'LONG_DESCRIPTION', 'RETAILER_ID', 'COMMODITY_URL', 'RETAILER_UNIQUE_ID', 'PCH_CATEGORY_ID',
106
- 'RH_CATEGORY_ID', 'STANDARD_PRICE', 'WEIGHT_UNIT', 'DISTANCE_UNIT', 'COO', 'IMAGE_URL', 'PARENT_SKU',
107
- 'CHILD_SKU', 'PARCELS_PER_SKU', 'UPC', 'UPC_CHECK_DIGIT', 'GTIN', 'MPN', 'ISBN', 'BRAND', 'MANUFACTURER',
108
- 'MODEL_NUMBER', 'MANUFACTURER_STOCK_NUMBER', 'COMMODITY_CONDITION', 'COMMODITY_HEIGHT',
109
- 'COMMODITY_WIDTH', 'COMMODITY_LENGTH', 'PACKAGE_WEIGHT', 'PACKAGE_HEIGHT', 'PACKAGE_WIDTH',
110
- 'PACKAGE_LENGTH', 'HAZMAT', 'ORMD', 'CHEMICAL_INDICATOR', 'PESTICIDE_INDICATOR', 'AEROSOL_INDICATOR',
111
- 'RPPC_INDICATOR', 'BATTERY_TYPE', 'NON_SPILLABLE_BATTERY', 'FUEL_RESTRICTION', 'SHIP_ALONE',
112
- 'RH_CATEGORY_ID_PATH', 'RH_CATEGORY_NAME_PATH'));
113
- //,'RH_CATEGORY_URL_PATH','GPC','COMMODITY_WEIGHT','HS_CODE','CURRENCY'
114
-
115
- fflush($this->file);
116
- }
117
-
118
- private function _createNewCategoryFile($part = null)
119
- {
120
- if(is_resource($this->file)) {
121
- fflush($this->file);
122
- fclose($this->file);
123
-
124
- }
125
-
126
- $fileName = $this->_getDataFileName('category-tree', $part);
127
-
128
-
129
- $this->filename = $this->_getTempDir() . $fileName;
130
- if ($this->_debug) {
131
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
132
- 'Product catalog upload - creating new category file', $fileName);
133
- }
134
- try {
135
- $this->file = fopen($this->filename, "w+");
136
- chmod($this->filename, 0777);
137
- }
138
- catch(Exception $e) {
139
- if ($this->_debug) {
140
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
141
- 'Product catalog upload exception during file opening', $e->getMessage());
142
- }
143
- }
144
- //add header row
145
- fputcsv($this->file, array('CATEGORY_ID', 'PARENT_CATEGORY_ID', 'NAME',
146
- 'ID_PATH', 'URL'));
147
-
148
- fflush($this->file);
149
- }
150
-
151
-
152
- private function _getSelectedCategory($categories, $catId)
153
- {
154
- foreach ($categories as $cat) {
155
- if ($cat->getId() == $catId)
156
- return $cat;
157
- }
158
- return false;
159
- }
160
-
161
- /**
162
- * Extracts the categories and products and exports them into xml file.
163
- */
164
- public function createNew()
165
- {
166
- $this->_debug = Mage::helper('shipperhq_pbint')->isDebug();
167
-
168
- $maxRecordsCount = Shipperhq_Pbint_Model_Credentials::getMaxRecordsCount();
169
- if (!$maxRecordsCount) {
170
- $maxRecordsCount = 10000;
171
- }
172
-
173
- if ($this->_debug) {
174
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
175
- 'ShipperHQ Pitney product catalog upload', 'Maxium number of records: ' .$maxRecordsCount);
176
- }
177
- $prodCount = 0;
178
- $catCount = 0;
179
- $fileRecordCount = 0;
180
- //get stores which has disabled clearpath
181
- $stores = Mage::app()->getStores();
182
- $defaultStoreUrl = Mage::getBaseUrl();
183
- $secDefaultStoreUrl = str_replace("http", "https", $defaultStoreUrl);
184
- $disabledStores = array();
185
- $addedCategories = array();
186
- $part = 1;
187
- $atLeastOneStoreEnabled = false;
188
- if ($this->_debug) {
189
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
190
- 'ShipperHQ Pitney product catalog upload', 'Number of stores in Magento: ' .count($stores));
191
- }
192
- foreach ($stores as $store) {
193
-
194
- $isActive = Mage::getStoreConfig('shipperhqpitney/shqpbint/active', $store);
195
- $baseURL = $store->getBaseUrl();
196
-
197
- if (!$isActive) {
198
- $disabledStores[] = $store;
199
- if ($this->_debug) {
200
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
201
- 'Disabled store ', $store->getId() . ' ' . $store->getCode());
202
- }
203
- } else {
204
- $atLeastOneStoreEnabled = true;
205
- $rootId = Mage::app()->getStore($store->getId())->getRootCategoryId();
206
- $rootCat = Mage::getModel('catalog/category')->load($rootId);
207
- /* @var $rootCat Mage_Catalog_Model_Category */
208
- $rootCat->setData('store', $store);
209
- if ($this->_debug) {
210
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
211
- 'Default store url ', $defaultStoreUrl . 'store ' . $store->getCode() . ' store base url'
212
- . $baseURL . " root cat url" . $rootCat->getUrl() . " cat name" . $rootCat->getName());
213
- }
214
-
215
- $catUrl = str_replace($defaultStoreUrl, $baseURL, $rootCat->getUrl());
216
- if ($catUrl == $rootCat->getUrl())
217
- $catUrl = str_replace($secDefaultStoreUrl, $baseURL, $rootCat->getUrl());
218
- $cat = new Shipperhq_Pbint_Model_Catalog_Category($rootCat, $catUrl);
219
- if (!$this->file || $fileRecordCount > $maxRecordsCount) {
220
- $this->_createNewCategoryFile($part);
221
- $fileRecordCount = 0;
222
- $part++;
223
- }
224
- $cat->writeToFile($this->file);
225
- fflush($this->file);
226
- $catCount++;
227
- $fileRecordCount++;
228
- $categories = Mage::getModel('catalog/category')
229
- ->getCollection()
230
- ->addUrlRewriteToResult()
231
- ->addAttributeToSelect('name')
232
- ->addFieldToFilter('path', array('like' => "1/$rootId/%"));
233
- $addedCategories[] = $rootCat;
234
- if ($this->_debug) {
235
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
236
- 'Product catalog upload ', 'Found ' .count($categories) .' for processing');
237
- }
238
- foreach ($categories as $category) {
239
- if (!$this->file || $fileRecordCount > $maxRecordsCount) {
240
- $this->_createNewCategoryFile($part);
241
- $fileRecordCount = 0;
242
- $part++;
243
- }
244
- /* @var $category Mage_Catalog_Model_Category */
245
- $category->setStoreId($store->getId());
246
- $category->setData('store', $store);
247
- $addedCategories[] = $category;
248
-
249
- $catUrl = str_replace($defaultStoreUrl, $baseURL, $category->getUrl());
250
- if ($catUrl == $category->getUrl())
251
- $catUrl = str_replace($secDefaultStoreUrl, $baseURL, $category->getUrl());
252
- $cat = new Shipperhq_Pbint_Model_Catalog_Category($category, $catUrl);
253
- $cat->writeToFile($this->file);
254
- fflush($this->file);
255
- $catCount++;
256
- $fileRecordCount++;
257
- }
258
- }
259
- }
260
- if(!$atLeastOneStoreEnabled) {
261
- if ($this->_debug) {
262
- Mage::helper('wsalogger/log')->postInfo('Shipperhq_Pbint',
263
- 'Product catalog upload issue ', ' ShipperHQ Pitney is not set to active for any of your stores,
264
- Please enable in at least one store before attempting to upload catalog');
265
- }
266
- }
267
- if($this->file) {
268
- fclose($this->file);
269
- }
270
- else {
271
- if ($this->_debug) {
272
- Mage::helper('wsalogger/log')->postInfo('Shipperhq_Pbint',
273
- 'Product catalog upload issue ', 'No upload file object was created');
274
- }
275
- }
276
- $this->_stripPartFromFileName($part);
277
- //fwrite($this->file,"</CategoryList>\n<CommodityList>\n");
278
- $fileRecordCount = 0;
279
- $part = 1;
280
- $this->_createNewCommoditiyFile($part);
281
- $part++;
282
- $addedProducts = array();
283
- if(count($addedCategories) == 0) {
284
- if ($this->_debug) {
285
- Mage::helper('wsalogger/log')->postInfo('Shipperhq_Pbint',
286
- 'Product catalog upload ', 'During processing, no product categories were found. Please review full log files for details');
287
- }
288
- }
289
-
290
- $productCollection = Mage::getModel('catalog/product')->getCollection()
291
- ->addAttributeToSelect('name')
292
- ->addAttributeToSelect('sku')
293
- ->addAttributeToSelect('country_of_manufacture')
294
- ->addAttributeToSelect('description')
295
- ->addAttributeToSelect('product_url')
296
- ->addAttributeToSelect('type_id')
297
- ->addAttributeToSelect('shipperhq_pbint_upload')
298
- ->addAttributeToSelect('price')
299
- ->addAttributeToSelect('weight');
300
-
301
- $productCollection->setPageSize(100);
302
-
303
- $pages = $productCollection->getLastPageNumber();
304
- if ($this->_debug) {
305
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
306
- 'Product catalog upload ', 'There are ' .$pages.' pages x 100 products to process');
307
- }
308
- $currentPage = 1;
309
-
310
- do {
311
- $productCollection->setCurPage($currentPage);
312
- $productCollection->load();
313
-
314
- foreach ($productCollection as $product) {
315
- if ($product->getTypeId() == 'virtual') {
316
- continue;
317
- }
318
-
319
- if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'bundle') {
320
- //as we'll use the child products only
321
- continue;
322
- }
323
-
324
- $cateIds = $product->getCategoryIds();
325
- $cateId = 0;
326
- foreach ($cateIds as $cId) {
327
- $cateId = $cId; //get lower level of category
328
- }
329
-
330
- $prodCat = $this->_getSelectedCategory($addedCategories, $cateId);
331
- if (!$prodCat) {
332
- $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
333
- ->getParentIdsByChild($product->getId());
334
- if(empty($parentIds)) {
335
- $parentIds = Mage::getResourceSingleton('bundle/selection')
336
- ->getParentIdsByChild($product->getId());
337
- if(empty($parentIds)) {
338
- if ($this->_debug) {
339
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
340
- 'Product catalog upload ', 'unable to find an exported category for SKU ' .$product->getSku() .' and no assigned parents on this product');
341
- }
342
- continue;
343
- }
344
- }
345
- $parent = Mage::getModel('catalog/product')->load($parentIds[0]);
346
- foreach ($parent->getCategoryIds() as $cId) {
347
- $cateId = $cId; //get lower level of category
348
- }
349
- $prodCat = $this->_getSelectedCategory($addedCategories, $cateId);
350
- if(!$prodCat) {
351
- if ($this->_debug) {
352
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
353
- 'Product catalog upload ', 'unable to find an exported category for SKU ' .$product->getSku() .' - category ID is ' .$cateId);
354
- }
355
- continue; //can't find the category
356
- }
357
- }
358
- $baseURL = Mage::app()->getStore($category->getStoreId())->getBaseUrl();
359
- $productUrlFormat = $baseURL . "catalog/product/view/id/%d/";
360
-
361
- $cIds = explode('/', $prodCat->getPath());
362
- $cIds = array_slice($cIds, 1); //remove root category
363
- $prodCat->setData('id_path', implode(':', $cIds));
364
- $prodCat->setData('name_path', $this->_getCatNamePath($addedCategories, $cIds));
365
-
366
- $pbProduct = new Shipperhq_Pbint_Model_Catalog_Product($product, sprintf($productUrlFormat, $product->getId()));
367
- if ($fileRecordCount > $maxRecordsCount) {
368
- $this->_createNewCommoditiyFile();
369
- $fileRecordCount = 0;
370
- $part++;
371
- }
372
- $this->writeProduct($pbProduct, $cateId, null, $prodCat);
373
- $prodCount++;
374
- $fileRecordCount++;
375
- $addedProducts[$product->getSku()] = "added";
376
-
377
- }
378
-
379
- $currentPage++;
380
- //clear collection and free memory
381
- $productCollection->clear();
382
- } while ($currentPage <= $pages);
383
-
384
- if($this->file) {
385
- fflush($this->file);
386
- }
387
- if ($this->_debug) {
388
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
389
- 'Product upload - Completed file creation', 'Processed ' .$prodCount .' products');
390
- }
391
-
392
- $this->_stripPartFromFileName($part);
393
- return true;
394
- }
395
-
396
- private function _getCatNamePath($categories, $cateIds)
397
- {
398
-
399
- $names = array();
400
- foreach ($cateIds as $id) {
401
- foreach ($categories as $cat) {
402
- if ($cat->getId() == $id) {
403
- array_push($names, $cat->getName());
404
- break;
405
- }
406
- }
407
- }
408
- return implode('|', $names);
409
- }
410
-
411
- /**
412
- * Updates the shipperhq_pbint_upload time in all uploaded products
413
- */
414
- public function updateLastProductUpload()
415
- {
416
-
417
- $this->_debug = Mage::helper('shipperhq_pbint')->isDebug();
418
- $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'shipperhq_pbint_upload');
419
- if (!$attribute->getAttributeId()) {
420
- $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
421
- $setup->addAttribute('catalog_product', 'shipperhq_pbint_upload', array(
422
- 'label' => 'Last Pb upload timestampt',
423
- 'type' => 'varchar',
424
- 'input' => 'text',
425
- 'visible' => false,
426
- 'required' => false,
427
- 'position' => 1,
428
- ));
429
- }
430
-
431
- $productIds = array_unique($this->productIds);
432
- if ($this->_debug) {
433
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
434
- 'Uploaded products', count($productIds));
435
- }
436
- $updated = 0;
437
- foreach ($productIds as $prodId) {
438
- $product = Mage::getModel("catalog/product")->load($prodId);
439
- $product->setPbPbgspUpload(time());
440
- try {
441
- $product->save();
442
- $updated++;
443
- } catch (Exception $e) {
444
- if ($this->_debug) {
445
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
446
- 'There was a problem saving the product with sku', $product->getSku() . " Error Message \n" . $e->getMessage());
447
- }
448
- }
449
-
450
- }
451
- if ($this->_debug) {
452
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
453
- 'shipperhq_pbint_upload', $updated . ' products updated');
454
- }
455
- }
456
-
457
- /**
458
- * Uploads the xml file to clearpath SFTP server
459
- */
460
-
461
- private function _getNotificationDir()
462
- {
463
- $tmpDir = $this->_getTempDir();
464
- $configOptions = Mage::getModel('core/config_options');
465
- $notificationDir = $tmpDir . 'notifications';
466
- $configOptions->createDirIfNotExists($notificationDir);
467
- chmod($notificationDir, 0777);
468
- return $notificationDir;
469
- }
470
-
471
- public function processStatusNotifications()
472
- {
473
- $this->_debug = Mage::helper('shipperhq_pbint')->isDebug();
474
- try {
475
- $adminEmail = Shipperhq_Pbint_Model_Credentials::getAdminEmail();
476
- if (!isset($adminEmail) || $adminEmail == '')
477
- return;
478
- $notificationDir = $this->_getNotificationDir();
479
- $this->_downloadStatusNotifications($notificationDir);
480
- $notificationFiles = array_diff(scandir($notificationDir), array('..', '.'));
481
- if (count($notificationFiles) > 0) {
482
- $mail = new Zend_Mail();
483
- $mail->setFrom('no-reply@pb.com', 'Pitney Bowes');
484
- $mail->addTo($adminEmail)
485
- ->setSubject('Catalog Export Error')
486
- ->setBodyText('Catalog Export Error. Please see attached files.');
487
- $fileCount = 0;
488
- foreach ($notificationFiles as $notificationFile) {
489
- if ($this->_endsWith($notificationFile, '.err') || $this->_endsWith($notificationFile, '.log')) {
490
- $file = $notificationDir . '/' . $notificationFile;
491
- $at = new Zend_Mime_Part(file_get_contents($file));
492
- $at->filename = basename($file);
493
- $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
494
- $at->encoding = Zend_Mime::ENCODING_8BIT;
495
-
496
- $mail->addAttachment($at);
497
- $fileCount++;
498
- }
499
-
500
- }
501
- if ($fileCount > 0) {
502
- $mail->send();
503
- if ($this->_debug) {
504
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
505
- 'ProcessStatusNotifications', 'Email sent with error files.');
506
- }
507
- } else {
508
- if ($this->_debug) {
509
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint',
510
- 'ProcessStatusNotifications', 'No error files found.');
511
- }
512
- }
513
- //keep these files until next upload and delete files from old upload
514
- $this->_cleanNotificationFiles();
515
- }
516
- } catch (Exception $e) {
517
- if ($this->_debug) {
518
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
519
- 'ProcessStatusNotifications', 'Error in processStatusNotifications:' . $e->getMessage());
520
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
521
- 'Full trace of exception: ', $e->getTraceAsString());
522
- }
523
- }
524
- }
525
-
526
- private function _cleanNotificationFiles()
527
- {
528
- //keep resent files until next upload and delete files from old upload
529
- $lastExportedFiles = $this->_getLastExportedFileNames();
530
- if (!$lastExportedFiles)
531
- return;
532
- $notificationDir = $this->_getNotificationDir();
533
- $notificationFiles = array_diff(scandir($notificationDir), array('..', '.'));
534
-
535
- foreach ($notificationFiles as $notificationFile) {
536
- $path_parts = pathinfo($notificationFile);
537
- $localFileNameWithoutExt = $path_parts['filename'];
538
- $isOldFile = true;
539
- foreach ($lastExportedFiles as $lastExportedFile) {
540
- $lastExportedFileNameWithoutExt = str_replace('.gpg', '', str_replace('.csv', '', $lastExportedFile));
541
- if ($lastExportedFileNameWithoutExt == $localFileNameWithoutExt) {
542
- $isOldFile = false;
543
- break;
544
- }
545
- }
546
- if ($isOldFile) {
547
- //this is from 2nd last upload, remove it from disk
548
- unlink($notificationDir . '/' . $notificationFile);
549
- }
550
- }
551
-
552
- }
553
-
554
- private function _downloadStatusNotifications($notificationDir)
555
- {
556
-
557
- $credentials = $this->_getSftpCredentials();
558
- try {
559
- $sftpDumpFile = new Varien_Io_Sftp();
560
- $sftpDumpFile->open(
561
- $credentials
562
- );
563
- $rootDir = Shipperhq_Pbint_Model_Credentials::getSftpCatalogDirectory();
564
- if (!$this->_endsWith($rootDir, '/'))
565
- $rootDir = $rootDir . '/';
566
- $processedDir = $rootDir . 'outbound';
567
- $sftpDumpFile->cd($processedDir);
568
- $files = $sftpDumpFile->ls();
569
-
570
- $exportedFiles = $this->_getLastExportedFileNames();
571
- if (!$exportedFiles)
572
- return;
573
- foreach ($files as $file) {
574
- foreach ($exportedFiles as $exportedFile) {
575
- $fileNameWithoutExtension = str_replace(".gpg", "", str_replace(".csv", "", $exportedFile));
576
- if ($this->_startsWith($file['text'], $fileNameWithoutExtension)) {
577
- $dest = $notificationDir . '/' . $file['text'];
578
- $sftpDumpFile->read($file['text'], $dest);
579
- }
580
- }
581
-
582
- }
583
- $sftpDumpFile->close();
584
- } catch (Exception $e) {
585
- if ($this->_debug) {
586
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
587
- 'Pb Module could not connect to sftp server: ',
588
- $credentials['host'], $e->getMessage());
589
- }
590
- return;
591
- }
592
-
593
- }
594
-
595
- private function _encryptExportedFiles($exportedFiles)
596
- {
597
- $encryptedFiles = array();
598
- $publicKey = Shipperhq_Pbint_Model_Credentials::getPublicKey();
599
- if (!isset($publicKey) || $publicKey == '') {
600
- if ($this->_debug) {
601
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint',
602
- 'EncryptExportedFiles', 'Public key is not set cannot encrypt catalog files.');
603
- }
604
- return $exportedFiles;
605
- }
606
- try {
607
- $gnupg = new gnupg();
608
- $keyInfo = $gnupg->import($publicKey);
609
- $gnupg->addencryptkey($keyInfo['fingerprint']);
610
- $tmpDir = $this->_getTempDir();
611
- if ($this->_debug) {
612
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint', 'EncryptExportedFiles', 'Encrypting the files.');
613
- }
614
- foreach ($exportedFiles as $exportedFile) {
615
- $fileName = $tmpDir . $exportedFile;
616
- if (is_dir($fileName))
617
- continue;
618
- $encryptedFileName = $exportedFile . '.gpg';
619
- if ($this->_debug) {
620
- Mage::helper('wsalogger/log')->postDebug('Shipperhq_Pbint', 'EncryptExportedFiles', 'Encrypted file' . $encryptedFileName);
621
- }
622
- file_put_contents($tmpDir . $encryptedFileName, $gnupg->encrypt(file_get_contents($fileName)));
623
- $encryptedFiles[] = $encryptedFileName;
624
- }
625
- return $encryptedFiles;
626
- } catch (Exception $e) {
627
- if ($this->_debug) {
628
- Mage::helper('wsalogger/log')->postWarning('Shipperhq_Pbint', 'Error in encryption', $e->getTraceAsString());
629
- }
630
- return $encryptedFiles;
631
- }
632
-
633
-
634
- }
635
-
636
-