Version Notes
Inavante_GoogleTrustedStores
Download this release
Release Info
Developer | Inavante_GoogleTrustedStores |
Extension | Inavante_GoogleTrustedStores |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Inavante/GoogleTrustedStores/Block/Adminhtml/GoogleTrustedStores.php +36 -0
- app/code/community/Inavante/GoogleTrustedStores/Block/Adminhtml/GoogleTrustedStores/Grid.php +83 -0
- app/code/community/Inavante/GoogleTrustedStores/Block/Adminhtml/GoogleTrustedStores/Grid/Renderer/Action.php +46 -0
- app/code/community/Inavante/GoogleTrustedStores/Block/Js.php +91 -0
- app/code/community/Inavante/GoogleTrustedStores/Exception.php +5 -0
- app/code/community/Inavante/GoogleTrustedStores/Helper/Data.php +87 -0
- app/code/community/Inavante/GoogleTrustedStores/Helper/Order.php +75 -0
- app/code/community/Inavante/GoogleTrustedStores/Helper/Shipment.php +87 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/Log.php +10 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/Mysql4/Log.php +9 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/Mysql4/Log/Collection.php +11 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/Mysql4/Order/Collection.php +26 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/Observer.php +177 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/System/Config/Backend/CronCancelled.php +44 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/System/Config/Backend/CronShipped.php +44 -0
- app/code/community/Inavante/GoogleTrustedStores/Model/System/Config/Source/CronFrequency.php +32 -0
- app/code/community/Inavante/GoogleTrustedStores/controllers/Adminhtml/GoogletrustedstoresController.php +92 -0
- app/code/community/Inavante/GoogleTrustedStores/etc/adminhtml.xml +72 -0
- app/code/community/Inavante/GoogleTrustedStores/etc/config.xml +142 -0
- app/code/community/Inavante/GoogleTrustedStores/etc/system.xml +158 -0
- app/code/community/Inavante/GoogleTrustedStores/sql/googletrustedstores_setup/install-1.0.0.php +27 -0
- app/design/adminhtml/default/default/layout/googletrustedstores.xml +25 -0
- app/design/frontend/base/default/layout/googletrustedstores.xml +8 -0
- app/etc/modules/Inavante_GoogleTrustedStores.xml +13 -0
- package.xml +18 -0
app/code/community/Inavante/GoogleTrustedStores/Block/Adminhtml/GoogleTrustedStores.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Description of
|
5 |
+
* @package Inavante_GoogleTrustedStores
|
6 |
+
* @company Inavante - http://www.cueblocks.com/
|
7 |
+
* @author Francesco Magazzu' <francesco.magazzu at cueblocks.com>
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class Inavante_GoogleTrustedStores_Block_Adminhtml_GoogleTrustedStores extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Block constructor
|
14 |
+
*/
|
15 |
+
public function __construct() {
|
16 |
+
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
$this->_controller = 'adminhtml_googleTrustedStores';
|
20 |
+
$this->_blockGroup = 'googletrustedstores';
|
21 |
+
|
22 |
+
$this->_removeButton('add');
|
23 |
+
}
|
24 |
+
|
25 |
+
//set the log/grid type on the base of XML Layout
|
26 |
+
public function renderView() {
|
27 |
+
|
28 |
+
$type = $this->getLogType();
|
29 |
+
|
30 |
+
$this->_headerText = Mage::helper('googletrustedstores')->__('Feed Log - ' . $type . ' orders');
|
31 |
+
$this->getLayout()->getBlock($this->_controller . '.grid')->setLogType($type);
|
32 |
+
|
33 |
+
return parent::renderView();
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Block/Adminhtml/GoogleTrustedStores/Grid.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Description of
|
5 |
+
* @package Inavante_GoogleTrustedStores
|
6 |
+
* @company Inavante - http://www.cueblocks.com/
|
7 |
+
* @author Francesco Magazzu' <francesco.magazzu at cueblocks.com>
|
8 |
+
*/
|
9 |
+
class Inavante_GoogleTrustedStores_Block_Adminhtml_GoogleTrustedStores_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
10 |
+
|
11 |
+
public function __construct() {
|
12 |
+
parent::__construct();
|
13 |
+
$this->setUseAjax(true);
|
14 |
+
$this->setId('googletrustedstores');
|
15 |
+
$this->setDefaultSort('id');
|
16 |
+
|
17 |
+
// $urlNew = $this->getUrl('*/Googletrustedstores/new');
|
18 |
+
// $urlConfig = $this->getUrl('*/system_config/edit/section/Googletrustedstores');
|
19 |
+
|
20 |
+
$this->_emptyText = Mage::helper('adminhtml')->__('No log for this feed');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Prepare collection for grid
|
25 |
+
*
|
26 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
27 |
+
*/
|
28 |
+
protected function _prepareCollection() {
|
29 |
+
$collection = Mage::getModel('googletrustedstores/log')->getCollection()
|
30 |
+
->addFieldToFilter('status', $this->getLogType());
|
31 |
+
|
32 |
+
/* @var $collection Mage_Sitemap_Model_Mysql4_Sitemap_Collection */
|
33 |
+
|
34 |
+
$this->setCollection($collection);
|
35 |
+
|
36 |
+
return parent::_prepareCollection();
|
37 |
+
}
|
38 |
+
|
39 |
+
protected function _prepareColumns() {
|
40 |
+
$this->addColumn('id', array(
|
41 |
+
'header' => Mage::helper('googletrustedstores')->__('Log ID'),
|
42 |
+
'index' => 'id',
|
43 |
+
'width' => '16px',
|
44 |
+
));
|
45 |
+
$this->addColumn('order_id', array(
|
46 |
+
'header' => Mage::helper('googletrustedstores')->__('Order ID'),
|
47 |
+
'index' => 'order_id',
|
48 |
+
'width' => '16px',
|
49 |
+
));
|
50 |
+
$this->addColumn('status', array(
|
51 |
+
'header' => Mage::helper('googletrustedstores')->__('Status'),
|
52 |
+
'index' => 'status',
|
53 |
+
));
|
54 |
+
|
55 |
+
if ($this->getLogType() == 'shipped') {
|
56 |
+
|
57 |
+
$this->addColumn('shipment_title', array(
|
58 |
+
'header' => Mage::helper('googletrustedstores')->__('Carrier'),
|
59 |
+
'index' => 'shipment_title',
|
60 |
+
));
|
61 |
+
$this->addColumn('track_number', array(
|
62 |
+
'header' => Mage::helper('googletrustedstores')->__('Track Number'),
|
63 |
+
'index' => 'track_number',
|
64 |
+
));
|
65 |
+
} else if ($this->getLogType() == 'canceled') {
|
66 |
+
|
67 |
+
$this->addColumn('cancel_reason', array(
|
68 |
+
'header' => Mage::helper('googletrustedstores')->__('Cancel Reason'),
|
69 |
+
'index' => 'cancel_reason',
|
70 |
+
));
|
71 |
+
}
|
72 |
+
|
73 |
+
$this->addColumn('created_at', array(
|
74 |
+
'header' => Mage::helper('googletrustedstores')->__('Exported On'),
|
75 |
+
'index' => 'created_at',
|
76 |
+
'type' => 'datetime',
|
77 |
+
'width' => '100px'
|
78 |
+
));
|
79 |
+
|
80 |
+
return parent::_prepareColumns();
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Block/Adminhtml/GoogleTrustedStores/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Description of
|
5 |
+
* @package Inavante_GoogleTrustedStores
|
6 |
+
* @company Inavante - http://www.cueblocks.com/
|
7 |
+
* @author Francesco Magazzu' <francesco.magazzu at cueblocks.com>
|
8 |
+
*/
|
9 |
+
class Inavante_GoogleTrustedStores_Block_Adminhtml_GoogleTrustedStores_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
10 |
+
{
|
11 |
+
|
12 |
+
public function render(Varien_Object $row)
|
13 |
+
{
|
14 |
+
/* @var $row Inavante_GoogleTrustedStores_Model_GoogleTrustedStores */
|
15 |
+
|
16 |
+
$this->getColumn()->setActions(
|
17 |
+
array(
|
18 |
+
array(
|
19 |
+
'url' => $this->getUrl("*/Googletrustedstores/ping", array("sitemap_id" => $row->getSitemapId())),
|
20 |
+
'caption' => Mage::helper('adminhtml')->__('Ping Sitemap'),
|
21 |
+
), array(
|
22 |
+
'url' => $this->getUrl('*/Googletrustedstores/generate', array('sitemap_id' => $row->getSitemapId())),
|
23 |
+
'caption' => Mage::helper('GoogleTrustedStores')->__('Generate'),
|
24 |
+
'confirm' => Mage::helper('adminhtml')->__('Are you sure you want to update/generate this XML Sitemap?'),
|
25 |
+
)
|
26 |
+
// , array(
|
27 |
+
// 'url' => $this->getUrl('*/Googletrustedstores/generatepopup', array('sitemap_id' => $row->getSitemapId())),
|
28 |
+
// 'caption' => Mage::helper('GoogleTrustedStores')->__('Generate Pop Up'),
|
29 |
+
// 'confirm' => Mage::helper('adminhtml')->__('Are you sure you want to update/generate this XML Sitemap?'),
|
30 |
+
// 'popup' => true
|
31 |
+
// )
|
32 |
+
, array(
|
33 |
+
'url' => $this->getUrl('*/Googletrustedstores/delete', array('sitemap_id' => $row->getSitemapId())),
|
34 |
+
'caption' => Mage::helper('GoogleTrustedStores')->__('Delete'),
|
35 |
+
'confirm' => Mage::helper('adminhtml')->__('Are you sure you want to delete this XML Sitemap?'),
|
36 |
+
)
|
37 |
+
// , array(
|
38 |
+
// 'url' => $this->getUrl('*/Googletrustedstores/addRobots', array('sitemap_id' => $row->getSitemapId())),
|
39 |
+
// 'caption' => Mage::helper('GoogleTrustedStores')->__('Add to Robots.txt'),
|
40 |
+
// )
|
41 |
+
)
|
42 |
+
);
|
43 |
+
return parent::render($row);
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Block/Js.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Block_Js extends Mage_Core_Block_Text {
|
4 |
+
/* (non-PHPdoc)
|
5 |
+
* @see Mage_Core_Block_Text::_toHtml()
|
6 |
+
*/
|
7 |
+
|
8 |
+
protected function _toHtml() {
|
9 |
+
if (!Mage::getStoreConfigFlag('googletrustedstores/config/enabled', Mage::app()->getStore()->getId())) {
|
10 |
+
return '';
|
11 |
+
}
|
12 |
+
|
13 |
+
$accountId = Mage::getStoreConfig('googletrustedstores/config/account_id', Mage::app()->getStore()->getId());
|
14 |
+
|
15 |
+
$html = <<<JS
|
16 |
+
<!-- BEGIN: Google Trusted Store -->
|
17 |
+
<script type="text/javascript">
|
18 |
+
var gts = gts || [];
|
19 |
+
|
20 |
+
gts.push(["id", "{$accountId}"]);
|
21 |
+
|
22 |
+
(function() {
|
23 |
+
var scheme = (("https:" == document.location.protocol) ? "https://" : "http://");
|
24 |
+
var gts = document.createElement("script");
|
25 |
+
gts.type = "text/javascript";
|
26 |
+
gts.async = true;
|
27 |
+
gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js";
|
28 |
+
var s = document.getElementsByTagName("script")[0];
|
29 |
+
s.parentNode.insertBefore(gts, s);
|
30 |
+
})();
|
31 |
+
</script>
|
32 |
+
<!-- END: Google Trusted Store -->
|
33 |
+
JS;
|
34 |
+
if (!$this->getOrderIds()) {
|
35 |
+
return $html;
|
36 |
+
}
|
37 |
+
|
38 |
+
foreach ($this->getOrderIds() as $orderId) {
|
39 |
+
$order = Mage::getModel('sales/order')
|
40 |
+
->load($orderId);
|
41 |
+
if (!$order->getId()) {
|
42 |
+
continue;
|
43 |
+
}
|
44 |
+
|
45 |
+
$htmlOrderItems = '';
|
46 |
+
foreach ($order->getAllItems() as $item) {
|
47 |
+
$htmlOrderItems .= <<<SPAN
|
48 |
+
<span class="gts-item">
|
49 |
+
<span class="gts-i-name">{$item->getName()}</span>
|
50 |
+
<span class="gts-i-price">{$item->getPrice()}</span>
|
51 |
+
<span class="gts-i-quantity">{$item->getQtyOrdered()}</span>
|
52 |
+
</span>
|
53 |
+
SPAN;
|
54 |
+
}
|
55 |
+
|
56 |
+
$urlArray = parse_url(Mage::getStoreConfig('web/unsecure/base_url', $order->getStoreId()));
|
57 |
+
$domain = $urlArray['host'];
|
58 |
+
$estShipDateDays = Mage::getStoreConfig('googletrustedstores/config/delivery_weekdays', $order->getStoreId());
|
59 |
+
$estShipDateDate = Mage::app()->getLocale()->date()->addWeekday($estShipDateDays)->toString('yyyy-MM-dd');
|
60 |
+
|
61 |
+
$html .= <<<DIV
|
62 |
+
<!-- START Trusted Stores Order -->
|
63 |
+
<div id="gts-order" style="display:none;">
|
64 |
+
<!-- start order and merchant information -->
|
65 |
+
<span id="gts-o-id">{$order->getIncrementId()}</span>
|
66 |
+
<span id="gts-o-domain">{$domain}</span>
|
67 |
+
<span id="gts-o-email">{$order->getCustomerEmail()}</span>
|
68 |
+
<span id="gts-o-country">{$order->getBillingAddress()->getCountryId()}</span>
|
69 |
+
<span id="gts-o-currency">{$order->getOrderCurrencyCode()}</span>
|
70 |
+
<span id="gts-o-total">{$order->getGrandTotal()}</span>
|
71 |
+
<span id="gts-o-discounts">{$order->getDiscountAmount()}</span>
|
72 |
+
<span id="gts-o-shipping-total">{$order->getShippingAmount()}</span>
|
73 |
+
<span id="gts-o-tax-total">{$order->getTaxAmount()}</span>
|
74 |
+
<span id="gts-o-est-ship-date">{$estShipDateDate}</span>
|
75 |
+
<span id="gts-o-has-preorder">N</span>
|
76 |
+
<span id="gts-o-has-digital">N</span>
|
77 |
+
<!-- end order and merchant information -->
|
78 |
+
|
79 |
+
<!-- start repeated item specific information -->
|
80 |
+
{$htmlOrderItems}
|
81 |
+
<!-- end repeated item specific information -->
|
82 |
+
|
83 |
+
</div>
|
84 |
+
<!-- END Trusted Stores -->
|
85 |
+
DIV;
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
return $html;
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Exception.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Exception extends Exception {
|
4 |
+
|
5 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Helper/Data.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
// Check if it is EE and RMA is avariable
|
6 |
+
public function isRmaEE() {
|
7 |
+
// $ver = (int) (substr(implode('', Mage::getVersionInfo()), 0, 3));
|
8 |
+
// return ( Mage::getEdition() == Mage::EDITION_ENTERPRISE && $ver >= 111);
|
9 |
+
|
10 |
+
try {
|
11 |
+
$table = Mage::getSingleton('core/resource')->getTableName('enterprise_rma/rma');
|
12 |
+
} catch (Exception $e) {
|
13 |
+
return false;
|
14 |
+
}
|
15 |
+
|
16 |
+
return $table;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setCanceledLog($id, $reason, $date) {
|
20 |
+
|
21 |
+
$model = Mage::getModel('googletrustedstores/log');
|
22 |
+
|
23 |
+
$model
|
24 |
+
->setOrderId($id)
|
25 |
+
->setStatus(Mage_Sales_Model_Order::STATE_CANCELED)
|
26 |
+
->setCancelReason($reason)
|
27 |
+
->setCreatedAt($date);
|
28 |
+
|
29 |
+
$model->save();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function setShipLog($id, $trackNumber, $shipmentTitle, $date) {
|
33 |
+
|
34 |
+
$model = Mage::getModel('googletrustedstores/log');
|
35 |
+
|
36 |
+
$model
|
37 |
+
->setOrderId($id)
|
38 |
+
->setStatus('shipped')
|
39 |
+
->setShipmentTitle($shipmentTitle)
|
40 |
+
->setTrackNumber($trackNumber)
|
41 |
+
->setCreatedAt($date);
|
42 |
+
|
43 |
+
$model->save();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* TEST METHOD
|
48 |
+
*
|
49 |
+
*
|
50 |
+
*/
|
51 |
+
public function testCleanAll() {
|
52 |
+
//CLEAN gts_export FLAG
|
53 |
+
echo '- Clean Order Exported Flag' . '<br>';
|
54 |
+
|
55 |
+
$gtsFlag = array('neq' => Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Not_Exported);
|
56 |
+
$collection = Mage::helper('googletrustedstores/order')
|
57 |
+
->getGtsOrder(null, null, $gtsFlag);
|
58 |
+
|
59 |
+
foreach ($collection as $order) {
|
60 |
+
$order->setGtsExported(Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Not_Exported)
|
61 |
+
->save();
|
62 |
+
}
|
63 |
+
|
64 |
+
//CLEAN log TABLE
|
65 |
+
$collection = Mage::getModel('googletrustedstores/log')->getCollection();
|
66 |
+
foreach ($collection as $log) {
|
67 |
+
$log->delete();
|
68 |
+
}
|
69 |
+
echo '- Clean Log Table ' . '<br>';
|
70 |
+
//REMOVE files
|
71 |
+
$fileName = Mage::getStoreConfig('googletrustedstores/config/feed_filename_canceled');
|
72 |
+
$path = Mage::getBaseDir('media') . DS . $fileName;
|
73 |
+
if (file_exists($path)) {
|
74 |
+
unlink($path);
|
75 |
+
echo '- Delete File: ' . $fileName . '<br>';
|
76 |
+
}
|
77 |
+
|
78 |
+
$fileName = Mage::getStoreConfig('googletrustedstores/config/feed_filename_shipped');
|
79 |
+
$path = Mage::getBaseDir('media') . DS . $fileName;
|
80 |
+
if (file_exists($path)) {
|
81 |
+
unlink($path);
|
82 |
+
echo '- Delete File: ' . $fileName . '<br>';
|
83 |
+
}
|
84 |
+
return true;
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Helper/Order.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Helper_Order extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getGtsCanceledOrder($store) {
|
6 |
+
|
7 |
+
$type = Mage_Sales_Model_Order::STATE_CANCELED;
|
8 |
+
return $this->getGtsOrder($store, $type);
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getGtsShipOrder($store) {
|
12 |
+
|
13 |
+
$type = Mage_Sales_Model_Order::STATE_COMPLETE;
|
14 |
+
return $this->getGtsOrder($store, $type);
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getGtsRmaOrder($store) {
|
18 |
+
|
19 |
+
if ($table = mage::helper('googletrustedstores')->isRmaEE()) {
|
20 |
+
|
21 |
+
$gtsFlag = array('neq' =>
|
22 |
+
array(Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Exported_RMA));
|
23 |
+
|
24 |
+
//Join
|
25 |
+
$aliasTable = array('rma' => $table);
|
26 |
+
$aliasField = array('rma_status' => 'rma.status');
|
27 |
+
|
28 |
+
$conditions = join(' AND ', array(
|
29 |
+
'rma.order_increment_id=main_table.increment_id',
|
30 |
+
'rma.status=\'authorized\'')
|
31 |
+
);
|
32 |
+
|
33 |
+
$collection = $this->getGtsOrder($store, null, $gtsFlag);
|
34 |
+
$rmaSelect = $collection->getSelect()
|
35 |
+
->join($aliasTable, $conditions, $aliasField);
|
36 |
+
|
37 |
+
return $collection;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getGtsOrder($store = null, $type = null, $gtsExport = null, $days = -7) {
|
42 |
+
|
43 |
+
if ($gtsExport == null) {
|
44 |
+
$gtsExport = Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Not_Exported;
|
45 |
+
}
|
46 |
+
|
47 |
+
$collection = Mage::getResourceModel('googletrustedstores/order_collection');
|
48 |
+
|
49 |
+
$collection
|
50 |
+
->addGtsExportedFilter($gtsExport)
|
51 |
+
->addAttributeToSelect('*')
|
52 |
+
->addDaysFilter($days);
|
53 |
+
|
54 |
+
if ($type != null) {
|
55 |
+
$collection = $collection->addTypeFilter($type);
|
56 |
+
}
|
57 |
+
if ($store != null) {
|
58 |
+
$collection = $collection->addStoreFilter($store);
|
59 |
+
}
|
60 |
+
|
61 |
+
return $collection;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function rmaJoinCleanItem($collection) {
|
65 |
+
|
66 |
+
foreach ($collection as $key => $order) {
|
67 |
+
if ($order->getRmaStatus() != 'authorized' && $order->getState() != 'canceled') {
|
68 |
+
$collection->removeItemByKey($key);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $collection;
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Helper/Shipment.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Helper_Shipment extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
// public function includeRMA($type) {
|
6 |
+
// return ($type == 'canceled' && $this->isRmaEE());
|
7 |
+
// }
|
8 |
+
|
9 |
+
public function GetTrackContent($shipment, $orderIncrementId) {
|
10 |
+
if ($shipment) {
|
11 |
+
$contents = array();
|
12 |
+
$shipmentTrack = $this->GetTrack($shipment);
|
13 |
+
// format: [ID],[TrackNumber],[Carrier_Code],[Other_Carrier_Code],[date]
|
14 |
+
//[ID]
|
15 |
+
$contents[0] = $orderIncrementId;
|
16 |
+
if ($shipmentTrack) {
|
17 |
+
|
18 |
+
//[TrackNumber]
|
19 |
+
$trackNumber = ($shipmentTrack->getTrackNumber()) ? $shipmentTrack->getTrackNumber() : '';
|
20 |
+
$contents[1] = $trackNumber;
|
21 |
+
//[Carrier_Code]
|
22 |
+
$trackCode = $this->getTrackCode($shipmentTrack->getCarrierCode());
|
23 |
+
$contents[2] = $trackCode;
|
24 |
+
|
25 |
+
//[Other_Carrier_Code]
|
26 |
+
if ($trackCode == 'Other') {
|
27 |
+
$trackCodeOther = $this->getTrackOtherCode($shipmentTrack->getCarrierCode(), $shipmentTrack->getTitle());
|
28 |
+
$contents[3] = $trackCodeOther;
|
29 |
+
}else
|
30 |
+
$contents[3] = '';
|
31 |
+
}
|
32 |
+
//[date]
|
33 |
+
$contents[4] = Mage::app()->getLocale()->date(Varien_Date::formatDate($shipment->getCreatedAt()))->toString('yyyy-MM-dd');
|
34 |
+
|
35 |
+
return $contents;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
private function getTrackCode($code) {
|
40 |
+
|
41 |
+
$code = strtolower($code);
|
42 |
+
|
43 |
+
switch ($code) {
|
44 |
+
case 'ups':
|
45 |
+
$code = 'UPS';
|
46 |
+
break;
|
47 |
+
case 'fedex':
|
48 |
+
$code = 'FedEx';
|
49 |
+
break;
|
50 |
+
case 'usps':
|
51 |
+
$code = 'USPS';
|
52 |
+
break;
|
53 |
+
|
54 |
+
default:
|
55 |
+
$code = 'Other';
|
56 |
+
break;
|
57 |
+
}
|
58 |
+
|
59 |
+
return $code;
|
60 |
+
}
|
61 |
+
|
62 |
+
private function getTrackOtherCode($code, $title) {
|
63 |
+
|
64 |
+
$code = strtoupper($code);
|
65 |
+
|
66 |
+
if (!$code || $code == "OTHER") {
|
67 |
+
if ($title != "") {
|
68 |
+
return $title;
|
69 |
+
} else {
|
70 |
+
return "OTHER";
|
71 |
+
}
|
72 |
+
}
|
73 |
+
return $code;
|
74 |
+
}
|
75 |
+
|
76 |
+
private function GetTrack($shipment) {
|
77 |
+
|
78 |
+
$shipmentTrack = Mage::getResourceModel('sales/order_shipment_track_collection')
|
79 |
+
->addAttributeToSelect('*')
|
80 |
+
->addAttributeToFilter('parent_id', $shipment->getId())
|
81 |
+
->setPage(1, 1)
|
82 |
+
->getFirstItem();
|
83 |
+
|
84 |
+
return $shipmentTrack;
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Model/Log.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_Log extends Mage_Core_Model_Abstract {
|
4 |
+
|
5 |
+
public function _construct() {
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('googletrustedstores/log');
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Model/Mysql4/Log.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('googletrustedstores/log', 'id');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Model/Mysql4/Log/Collection.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
4 |
+
|
5 |
+
public function _construct() {
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('googletrustedstores/log');
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
11 |
+
|
app/code/community/Inavante/GoogleTrustedStores/Model/Mysql4/Order/Collection.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection extends Mage_Sales_Model_Mysql4_Order_Collection {
|
4 |
+
|
5 |
+
const Not_Exported = '0';
|
6 |
+
const Exported = '1';
|
7 |
+
const Exported_RMA = '2';
|
8 |
+
|
9 |
+
public function addDaysFilter($days = -7) {
|
10 |
+
return $this->addAttributeToFilter('created_at', array('from' => $days));
|
11 |
+
}
|
12 |
+
|
13 |
+
public function addStoreFilter($store) {
|
14 |
+
return $this->addAttributeToFilter('main_table.store_id', $store->getId());
|
15 |
+
}
|
16 |
+
|
17 |
+
public function addGtsExportedFilter($gtsExport) {
|
18 |
+
return $this->addAttributeToFilter('main_table.gts_exported', $gtsExport);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function addTypeFilter($type) {
|
22 |
+
return $this->addAttributeToFilter('main_table.state', $type);
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
26 |
+
|
app/code/community/Inavante/GoogleTrustedStores/Model/Observer.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_Observer {
|
4 |
+
|
5 |
+
public function setGoogleJsOnOrderSuccessPageView(Varien_Event_Observer $observer) {
|
6 |
+
if (!Mage::getStoreConfigFlag('googletrustedstores/config/enabled', Mage::app()->getStore()->getId())) {
|
7 |
+
return $this;
|
8 |
+
}
|
9 |
+
$orderIds = $observer->getEvent()->getOrderIds();
|
10 |
+
if (empty($orderIds) || !is_array($orderIds)) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
$block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('googletrustedstores.js');
|
14 |
+
if ($block) {
|
15 |
+
$block->setOrderIds($orderIds);
|
16 |
+
}
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function generateShipmentFeedCanceled() {
|
21 |
+
|
22 |
+
$i = 0;
|
23 |
+
$orderHelper = Mage::helper('googletrustedstores/order');
|
24 |
+
$helper = Mage::helper('googletrustedstores');
|
25 |
+
|
26 |
+
foreach (Mage::app()->getStores() as $store) {
|
27 |
+
|
28 |
+
$enabled = Mage::getStoreConfigFlag('googletrustedstores/config/enabled', $store->getId());
|
29 |
+
|
30 |
+
if (!$enabled) {
|
31 |
+
continue;
|
32 |
+
}
|
33 |
+
|
34 |
+
$collection = $orderHelper->getGtsCanceledOrder($store);
|
35 |
+
if (Mage::helper('googletrustedstores')->isRmaEE())
|
36 |
+
$rma = $orderHelper->getGtsRmaOrder($store);
|
37 |
+
|
38 |
+
if (count($collection) || (($rma) && count($rma))) {
|
39 |
+
|
40 |
+
$fileName = Mage::getStoreConfig('googletrustedstores/config/feed_filename_canceled', $store->getId());
|
41 |
+
$delimiter = Mage::getStoreConfig('googletrustedstores/config/feed_delimiter', $store->getId());
|
42 |
+
$path = Mage::getBaseDir('media') . DS . $fileName;
|
43 |
+
|
44 |
+
if (!file_exists($path)) {
|
45 |
+
// FORMAT: [Order_id], [Reason]
|
46 |
+
file_put_contents($path, implode(
|
47 |
+
$delimiter, array('merchant order id', 'reason')) . "\n", FILE_APPEND | LOCK_EX
|
48 |
+
);
|
49 |
+
}
|
50 |
+
|
51 |
+
foreach ($collection as $order) {
|
52 |
+
|
53 |
+
$reason = 'MerchantCanceled';
|
54 |
+
|
55 |
+
// FORMAT: [Order_id], [Reason]
|
56 |
+
file_put_contents($path, implode($delimiter, array($order->getIncrementId(), $reason)) . "\n", FILE_APPEND | LOCK_EX);
|
57 |
+
|
58 |
+
$order->setGtsExported(Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Exported);
|
59 |
+
$order->save();
|
60 |
+
|
61 |
+
$helper->setCanceledLog($order->getIncrementId(), $reason, Mage::getModel('core/date')->gmtDate());
|
62 |
+
|
63 |
+
$i++;
|
64 |
+
}
|
65 |
+
|
66 |
+
if (Mage::helper('googletrustedstores')->isRmaEE()) {
|
67 |
+
foreach ($rma as $order) {
|
68 |
+
|
69 |
+
if ($order->getRmaStatus() == 'authorized') {
|
70 |
+
|
71 |
+
$reason = 'canceled by customer';
|
72 |
+
// FORMAT: [Order_id], [Reason]
|
73 |
+
file_put_contents($path, implode($delimiter, array($order->getIncrementId(), $reason)) . "\n", FILE_APPEND | LOCK_EX);
|
74 |
+
|
75 |
+
$order->setGtsExported(Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Exported_RMA);
|
76 |
+
$order->save();
|
77 |
+
|
78 |
+
$helper->setCanceledLog($order->getIncrementId(), $reason, Mage::getModel('core/date')->gmtDate());
|
79 |
+
|
80 |
+
$i++;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
if (Mage::getStoreConfigFlag('googletrustedstores/config/feed_ftp_upload', $store->getId())) {
|
86 |
+
$this->_ftpUpload(
|
87 |
+
$fileName, Mage::getStoreConfig('googletrustedstores/config/feed_ftp_server', $store->getId()), Mage::getStoreConfig('googletrustedstores/config/feed_ftp_username', $store->getId()), Mage::getStoreConfig('googletrustedstores/config/feed_ftp_password', $store->getId()), true
|
88 |
+
);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
return $i;
|
93 |
+
}
|
94 |
+
|
95 |
+
public function generateShipmentFeedShipped() {
|
96 |
+
|
97 |
+
$i = 0;
|
98 |
+
$orderHelper = Mage::helper('googletrustedstores/order');
|
99 |
+
$helper = Mage::helper('googletrustedstores');
|
100 |
+
|
101 |
+
foreach (Mage::app()->getStores() as $store) {
|
102 |
+
|
103 |
+
$enabled = Mage::getStoreConfigFlag('googletrustedstores/config/enabled', $store->getId());
|
104 |
+
if (!$enabled) {
|
105 |
+
continue;
|
106 |
+
}
|
107 |
+
|
108 |
+
$collection = $orderHelper->getGtsShipOrder($store);
|
109 |
+
|
110 |
+
if (count($collection)) {
|
111 |
+
|
112 |
+
$fileName = Mage::getStoreConfig('googletrustedstores/config/feed_filename_shipped', $store->getId());
|
113 |
+
$delimiter = Mage::getStoreConfig('googletrustedstores/config/feed_delimiter', $store->getId());
|
114 |
+
$path = Mage::getBaseDir('media') . DS . $fileName;
|
115 |
+
|
116 |
+
if (!file_exists($path)) {
|
117 |
+
file_put_contents($path, implode(
|
118 |
+
$delimiter, array('merchant order id', 'tracking number', 'carrier code', 'other carrier name', 'ship date')) . "\n", FILE_APPEND | LOCK_EX
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
foreach ($collection as $order) {
|
123 |
+
|
124 |
+
foreach ($order->getShipmentsCollection() as $shipment) {
|
125 |
+
// format:[Order_increment_id],[TrackNumber],[Title],[Other_Title], [Ship date]
|
126 |
+
$contents = Mage::helper('googletrustedstores/shipment')->GetTrackContent($shipment, $order->getIncrementId());
|
127 |
+
}
|
128 |
+
|
129 |
+
file_put_contents($path, implode($delimiter, $contents) . "\n", FILE_APPEND | LOCK_EX);
|
130 |
+
|
131 |
+
$order->setGtsExported(Inavante_GoogleTrustedStores_Model_Mysql4_Order_Collection::Exported)
|
132 |
+
->save();
|
133 |
+
|
134 |
+
$trackNumber = $contents[1];
|
135 |
+
$shipmentTitle = ($contents[3] == '') ? $contents[2] : $contents[3];
|
136 |
+
|
137 |
+
$helper->setShipLog(
|
138 |
+
$order->getIncrementId(), $trackNumber, $shipmentTitle, Mage::getModel('core/date')->gmtDate()
|
139 |
+
);
|
140 |
+
|
141 |
+
$i++;
|
142 |
+
}
|
143 |
+
|
144 |
+
if (Mage::getStoreConfigFlag('googletrustedstores/config/feed_ftp_upload', $store->getId())) {
|
145 |
+
$this->_ftpUpload(
|
146 |
+
$fileName, Mage::getStoreConfig('googletrustedstores/config/feed_ftp_server', $store->getId()), Mage::getStoreConfig('googletrustedstores/config/feed_ftp_username', $store->getId()), Mage::getStoreConfig('googletrustedstores/config/feed_ftp_password', $store->getId()), true
|
147 |
+
);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
return $i;
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function _ftpUpload($fileName, $ftpServer, $ftpUsername, $ftpPassword, $unlink = false) {
|
155 |
+
|
156 |
+
if (!extension_loaded('ftp')) {
|
157 |
+
throw new Inavante_GoogleTrustedStores_Exception(Mage::helper('googletrustedstores')->__('"ftp" extension is not available on this server.'));
|
158 |
+
}
|
159 |
+
|
160 |
+
$path = Mage::getBaseDir('media') . DS . $fileName;
|
161 |
+
if (file_exists($path)) {
|
162 |
+
$connId = ftp_connect($ftpServer);
|
163 |
+
$loginResult = ftp_login($connId, $ftpUsername, $ftpPassword);
|
164 |
+
if ($loginResult && ftp_put($connId, $fileName, $path, FTP_ASCII)) {
|
165 |
+
if ($unlink) {
|
166 |
+
unlink($path);
|
167 |
+
}
|
168 |
+
} else {
|
169 |
+
throw new Inavante_GoogleTrustedStores_Exception(Mage::helper('googletrustedstores')->__('There was a problem while uploading file: %s', $path));
|
170 |
+
}
|
171 |
+
ftp_close($connId);
|
172 |
+
}
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
|
176 |
+
}
|
177 |
+
|
app/code/community/Inavante/GoogleTrustedStores/Model/System/Config/Backend/CronCancelled.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_System_Config_Backend_CronCancelled extends Mage_Core_Model_Config_Data {
|
4 |
+
|
5 |
+
const CRON_STRING_PATH = 'crontab/jobs/googletrustedstores_feed_canceled/schedule/cron_expr';
|
6 |
+
const CRON_MODEL_PATH = 'crontab/jobs/googletrustedstores_feed_canceled/run/model';
|
7 |
+
|
8 |
+
protected function _afterSave() {
|
9 |
+
|
10 |
+
//$service = $this->getData('groups/import/fields/service/value');
|
11 |
+
$time = $this->getData('groups/config/fields/time_cancel/value');
|
12 |
+
$frequency = $this->getData('groups/config/fields/frequency_cancel/value');
|
13 |
+
|
14 |
+
$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
|
15 |
+
$frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
|
16 |
+
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
|
17 |
+
|
18 |
+
$cronExprArray = array(
|
19 |
+
intval($time[1]), # Minute
|
20 |
+
intval($time[0]), # Hour
|
21 |
+
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
|
22 |
+
'*', # Month of the Year
|
23 |
+
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
|
24 |
+
);
|
25 |
+
|
26 |
+
$cronExprString = join(' ', $cronExprArray);
|
27 |
+
|
28 |
+
try {
|
29 |
+
Mage::getModel('core/config_data')
|
30 |
+
->load(self::CRON_STRING_PATH, 'path')
|
31 |
+
->setValue($cronExprString)
|
32 |
+
->setPath(self::CRON_STRING_PATH)
|
33 |
+
->save();
|
34 |
+
Mage::getModel('core/config_data')
|
35 |
+
->load(self::CRON_MODEL_PATH, 'path')
|
36 |
+
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
|
37 |
+
->setPath(self::CRON_MODEL_PATH)
|
38 |
+
->save();
|
39 |
+
} catch (Exception $e) {
|
40 |
+
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Model/System/Config/Backend/CronShipped.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_System_Config_Backend_CronShipped extends Mage_Core_Model_Config_Data {
|
4 |
+
|
5 |
+
const CRON_STRING_PATH = 'crontab/jobs/googletrustedstores_feed_shipped/schedule/cron_expr';
|
6 |
+
const CRON_MODEL_PATH = 'crontab/jobs/googletrustedstores_feed_shipped/run/model';
|
7 |
+
|
8 |
+
protected function _afterSave() {
|
9 |
+
|
10 |
+
//$service = $this->getData('groups/import/fields/service/value');
|
11 |
+
$time = $this->getData('groups/config/fields/time_ship/value');
|
12 |
+
$frequency = $this->getData('groups/config/fields/frequency_ship/value');
|
13 |
+
|
14 |
+
$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
|
15 |
+
$frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
|
16 |
+
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
|
17 |
+
|
18 |
+
$cronExprArray = array(
|
19 |
+
intval($time[1]), # Minute
|
20 |
+
intval($time[0]), # Hour
|
21 |
+
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
|
22 |
+
'*', # Month of the Year
|
23 |
+
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
|
24 |
+
);
|
25 |
+
|
26 |
+
$cronExprString = join(' ', $cronExprArray);
|
27 |
+
|
28 |
+
try {
|
29 |
+
Mage::getModel('core/config_data')
|
30 |
+
->load(self::CRON_STRING_PATH, 'path')
|
31 |
+
->setValue($cronExprString)
|
32 |
+
->setPath(self::CRON_STRING_PATH)
|
33 |
+
->save();
|
34 |
+
Mage::getModel('core/config_data')
|
35 |
+
->load(self::CRON_MODEL_PATH, 'path')
|
36 |
+
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
|
37 |
+
->setPath(self::CRON_MODEL_PATH)
|
38 |
+
->save();
|
39 |
+
} catch (Exception $e) {
|
40 |
+
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/Model/System/Config/Source/CronFrequency.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Inavante_GoogleTrustedStores_Model_System_Config_Source_CronFrequency {
|
4 |
+
|
5 |
+
protected static $_options;
|
6 |
+
|
7 |
+
public function toOptionArray() {
|
8 |
+
|
9 |
+
$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
|
10 |
+
$frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
|
11 |
+
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
|
12 |
+
|
13 |
+
if (!self::$_options) {
|
14 |
+
self::$_options = array(
|
15 |
+
array(
|
16 |
+
'label' => Mage::helper('cron')->__('Daily (Once in a day)'),
|
17 |
+
'value' => $frequencyDaily,
|
18 |
+
),
|
19 |
+
array(
|
20 |
+
'label' => Mage::helper('cron')->__('Weekly (Once in a week)'),
|
21 |
+
'value' => $frequencyWeekly,
|
22 |
+
),
|
23 |
+
array(
|
24 |
+
'label' => Mage::helper('cron')->__('Monthly (Once in a month)'),
|
25 |
+
'value' => $frequencyMonthly,
|
26 |
+
),
|
27 |
+
);
|
28 |
+
}
|
29 |
+
return self::$_options;
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/controllers/Adminhtml/GoogletrustedstoresController.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Description of GoogleTrustedStoresController
|
5 |
+
* @package CueBlocks_GoogleTrustedStores
|
6 |
+
* @company CueBlocks - http://www.cueblocks.com/
|
7 |
+
* @author Francesco Magazzu' <francesco.magazzu at cueblocks.com>
|
8 |
+
*/
|
9 |
+
class Inavante_GoogleTrustedStores_Adminhtml_GoogletrustedstoresController extends Mage_Adminhtml_Controller_action {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Init actions
|
13 |
+
*
|
14 |
+
* @return Mage_Adminhtml_SitemapController
|
15 |
+
*/
|
16 |
+
protected function _initAction() {
|
17 |
+
|
18 |
+
// load layout, set active menu and breadcrumbs
|
19 |
+
$this->loadLayout();
|
20 |
+
|
21 |
+
// $this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'));
|
22 |
+
// $this->_addBreadcrumb(Mage::helper('sitemapEnhanced')->__('Sitemap Enhanced'), Mage::helper('sitemapEnhanced')->__('Sitemap Enhanced'));
|
23 |
+
$this->_setActiveMenu('reports/sales');
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Ajax action for billing agreements
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
public function gridAction() {
|
32 |
+
$this->loadLayout(false)
|
33 |
+
->renderLayout();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Index action
|
38 |
+
*/
|
39 |
+
public function indexAction() {
|
40 |
+
|
41 |
+
$this->_title($this->__('Catalog'))->_title($this->__('Google Trusted Stores Feed Log'));
|
42 |
+
|
43 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
44 |
+
$this->_forward('grid');
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->_initAction();
|
49 |
+
$this->renderLayout();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Index action
|
54 |
+
*/
|
55 |
+
public function shiplogAction() {
|
56 |
+
|
57 |
+
$this->_title($this->__('Catalog'))->_title($this->__('Google Trusted Stores Feed Log'));
|
58 |
+
|
59 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
60 |
+
$this->_forward('grid');
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
|
64 |
+
$this->_initAction();
|
65 |
+
$this->renderLayout();
|
66 |
+
}
|
67 |
+
/**
|
68 |
+
* Index action
|
69 |
+
*/
|
70 |
+
public function cancellogAction() {
|
71 |
+
|
72 |
+
$this->_title($this->__('Catalog'))->_title($this->__('Google Trusted Stores Feed Log'));
|
73 |
+
|
74 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
75 |
+
$this->_forward('grid');
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->_initAction();
|
80 |
+
$this->renderLayout();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Check the permission to run it
|
85 |
+
*
|
86 |
+
* @return boolean
|
87 |
+
*/
|
88 |
+
// protected function _isAllowed() {
|
89 |
+
// return Mage::getSingleton('admin/session')->isAllowed('googletrustedstores/googletrustedstores');
|
90 |
+
// }
|
91 |
+
|
92 |
+
}
|
app/code/community/Inavante/GoogleTrustedStores/etc/adminhtml.xml
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<report>
|
5 |
+
<children>
|
6 |
+
<salesroot>
|
7 |
+
<children>
|
8 |
+
<googletrustedstores translate="title" module="googletrustedstores">
|
9 |
+
<title>Google Trusted Store</title>
|
10 |
+
<sort_order>190</sort_order>
|
11 |
+
<children>
|
12 |
+
<ship_log module="googletrustedstores">
|
13 |
+
<title>Shipment Feed Log</title>
|
14 |
+
<action>adminhtml/googletrustedstores/shiplog</action>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
</ship_log>
|
17 |
+
</children>
|
18 |
+
<children>
|
19 |
+
<cancel_log module="googletrustedstores">
|
20 |
+
<title>Canceled Feed Log</title>
|
21 |
+
<action>adminhtml/googletrustedstores/cancellog</action>
|
22 |
+
<sort_order>20</sort_order>
|
23 |
+
</cancel_log>
|
24 |
+
</children>
|
25 |
+
</googletrustedstores>
|
26 |
+
</children>
|
27 |
+
</salesroot>
|
28 |
+
</children>
|
29 |
+
</report>
|
30 |
+
</menu>
|
31 |
+
<acl>
|
32 |
+
<resources>
|
33 |
+
<admin>
|
34 |
+
<children>
|
35 |
+
<report>
|
36 |
+
<children>
|
37 |
+
<salesroot>
|
38 |
+
<children>
|
39 |
+
<googletrustedstores translate="title" module="googletrustedstores">
|
40 |
+
<title>Google Trusted Store</title>
|
41 |
+
<children>
|
42 |
+
<ship_log module="googletrustedstores">
|
43 |
+
<title>Shipment Feed Log</title>
|
44 |
+
</ship_log>
|
45 |
+
</children>
|
46 |
+
<children>
|
47 |
+
<cancel_log module="googletrustedstores">
|
48 |
+
<title>Cancelled Feed Log</title>
|
49 |
+
</cancel_log>
|
50 |
+
</children>
|
51 |
+
</googletrustedstores>
|
52 |
+
</children>
|
53 |
+
</salesroot>
|
54 |
+
</children>
|
55 |
+
</report>
|
56 |
+
<system>
|
57 |
+
<children>
|
58 |
+
<config>
|
59 |
+
<children>
|
60 |
+
<googletrustedstores translate="title" module="googletrustedstores">
|
61 |
+
<title>Google Trusted Stores</title>
|
62 |
+
<sort_order>1000</sort_order>
|
63 |
+
</googletrustedstores>
|
64 |
+
</children>
|
65 |
+
</config>
|
66 |
+
</children>
|
67 |
+
</system>
|
68 |
+
</children>
|
69 |
+
</admin>
|
70 |
+
</resources>
|
71 |
+
</acl>
|
72 |
+
</config>
|
app/code/community/Inavante/GoogleTrustedStores/etc/config.xml
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Inavante_GoogleTrustedStores>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Inavante_GoogleTrustedStores>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<googletrustedstores>
|
11 |
+
<class>Inavante_GoogleTrustedStores_Block</class>
|
12 |
+
</googletrustedstores>
|
13 |
+
</blocks>
|
14 |
+
<helpers>
|
15 |
+
<googletrustedstores>
|
16 |
+
<class>Inavante_GoogleTrustedStores_Helper</class>
|
17 |
+
</googletrustedstores>
|
18 |
+
</helpers>
|
19 |
+
<models>
|
20 |
+
<googletrustedstores>
|
21 |
+
<class>Inavante_GoogleTrustedStores_Model</class>
|
22 |
+
<resourceModel>googletrustedstores_mysql4</resourceModel>
|
23 |
+
</googletrustedstores>
|
24 |
+
<googletrustedstores_mysql4>
|
25 |
+
<class>Inavante_GoogleTrustedStores_Model_Mysql4</class>
|
26 |
+
<entities>
|
27 |
+
<log>
|
28 |
+
<table>gts_log</table>
|
29 |
+
</log>
|
30 |
+
</entities>
|
31 |
+
</googletrustedstores_mysql4>
|
32 |
+
</models>
|
33 |
+
<resources>
|
34 |
+
<googletrustedstores_setup>
|
35 |
+
<setup>
|
36 |
+
<module>Inavante_GoogleTrustedStores</module>
|
37 |
+
<class>Mage_Catalog_Model_Resource_Setup</class>
|
38 |
+
</setup>
|
39 |
+
<connection>
|
40 |
+
<use>core_setup</use>
|
41 |
+
</connection>
|
42 |
+
</googletrustedstores_setup>
|
43 |
+
<googletrustedstores_write>
|
44 |
+
<connection>
|
45 |
+
<use>core_write</use>
|
46 |
+
</connection>
|
47 |
+
</googletrustedstores_write>
|
48 |
+
<googletrustedstores_read>
|
49 |
+
<connection>
|
50 |
+
<use>core_read</use>
|
51 |
+
</connection>
|
52 |
+
</googletrustedstores_read>
|
53 |
+
</resources>
|
54 |
+
</global>
|
55 |
+
<frontend>
|
56 |
+
<events>
|
57 |
+
<checkout_onepage_controller_success_action>
|
58 |
+
<observers>
|
59 |
+
<googletrustedstores_order_success>
|
60 |
+
<class>googletrustedstores/observer</class>
|
61 |
+
<method>setGoogleJsOnOrderSuccessPageView</method>
|
62 |
+
</googletrustedstores_order_success>
|
63 |
+
</observers>
|
64 |
+
</checkout_onepage_controller_success_action>
|
65 |
+
<checkout_multishipping_controller_success_action>
|
66 |
+
<observers>
|
67 |
+
<googletrustedstores_order_success>
|
68 |
+
<class>googletrustedstores/observer</class>
|
69 |
+
<method>setGoogleJsOnOrderSuccessPageView</method>
|
70 |
+
</googletrustedstores_order_success>
|
71 |
+
</observers>
|
72 |
+
</checkout_multishipping_controller_success_action>
|
73 |
+
</events>
|
74 |
+
<layout>
|
75 |
+
<updates>
|
76 |
+
<googletrustedstores>
|
77 |
+
<file>googletrustedstores.xml</file>
|
78 |
+
</googletrustedstores>
|
79 |
+
</updates>
|
80 |
+
</layout>
|
81 |
+
</frontend>
|
82 |
+
<adminhtml>
|
83 |
+
<layout>
|
84 |
+
<updates>
|
85 |
+
<googletrustedstores>
|
86 |
+
<file>googletrustedstores.xml</file>
|
87 |
+
</googletrustedstores>
|
88 |
+
</updates>
|
89 |
+
</layout>
|
90 |
+
</adminhtml>
|
91 |
+
<admin>
|
92 |
+
<routers>
|
93 |
+
<adminhtml>
|
94 |
+
<args>
|
95 |
+
<modules>
|
96 |
+
<googletrustedstores before="Mage_Adminhtml">Inavante_GoogleTrustedStores_Adminhtml</googletrustedstores>
|
97 |
+
</modules>
|
98 |
+
</args>
|
99 |
+
</adminhtml>
|
100 |
+
</routers>
|
101 |
+
</admin>
|
102 |
+
<default>
|
103 |
+
<googletrustedstores>
|
104 |
+
<config>
|
105 |
+
<enabled>1</enabled>
|
106 |
+
<account_id></account_id>
|
107 |
+
<delivery_weekdays>5</delivery_weekdays>
|
108 |
+
<feed_delimiter>|</feed_delimiter>
|
109 |
+
<feed_filename_shipped>shipped.txt</feed_filename_shipped>
|
110 |
+
<feed_filename_canceled>canceled.txt</feed_filename_canceled>
|
111 |
+
<feed_ftp_upload>0</feed_ftp_upload>
|
112 |
+
<feed_ftp_server>uploads.google.com</feed_ftp_server>
|
113 |
+
<feed_ftp_username></feed_ftp_username>
|
114 |
+
<feed_ftp_password></feed_ftp_password>
|
115 |
+
<time_ship>2,00,00</time_ship>
|
116 |
+
<frequency_ship>D</frequency_ship>
|
117 |
+
<time_cancel>2,00,00</time_cancel>
|
118 |
+
<frequency_cancel>D</frequency_cancel>
|
119 |
+
</config>
|
120 |
+
</googletrustedstores>
|
121 |
+
</default>
|
122 |
+
<crontab>
|
123 |
+
<jobs>
|
124 |
+
<googletrustedstores_feed_shipped>
|
125 |
+
<schedule>
|
126 |
+
<!-- <cron_expr>0 2 * * *</cron_expr>-->
|
127 |
+
</schedule>
|
128 |
+
<run>
|
129 |
+
<model>googletrustedstores/observer::generateShipmentFeedShipped</model>
|
130 |
+
</run>
|
131 |
+
</googletrustedstores_feed_shipped>
|
132 |
+
<googletrustedstores_feed_canceled>
|
133 |
+
<schedule>
|
134 |
+
<!--<cron_expr>0 2 * * *</cron_expr>-->
|
135 |
+
</schedule>
|
136 |
+
<run>
|
137 |
+
<model>googletrustedstores/observer::generateShipmentFeedCanceled</model>
|
138 |
+
</run>
|
139 |
+
</googletrustedstores_feed_canceled>
|
140 |
+
</jobs>
|
141 |
+
</crontab>
|
142 |
+
</config>
|
app/code/community/Inavante/GoogleTrustedStores/etc/system.xml
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<googletrustedstores translate="label" module="googletrustedstores">
|
5 |
+
<class>separator-top</class>
|
6 |
+
<label>Google Trusted Stores</label>
|
7 |
+
<tab>sales</tab>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>1000</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>0</show_in_website>
|
12 |
+
<show_in_store>0</show_in_store>
|
13 |
+
<groups>
|
14 |
+
<config translate="label" module="googletrustedstores">
|
15 |
+
<label>Configuration</label>
|
16 |
+
<frontend_type>text</frontend_type>
|
17 |
+
<sort_order>10</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>0</show_in_website>
|
20 |
+
<show_in_store>0</show_in_store>
|
21 |
+
<fields>
|
22 |
+
<enabled translate="label" module="googletrustedstores">
|
23 |
+
<label>Enabled</label>
|
24 |
+
<frontend_type>select</frontend_type>
|
25 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
26 |
+
<sort_order>10</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>0</show_in_website>
|
29 |
+
<show_in_store>0</show_in_store>
|
30 |
+
</enabled>
|
31 |
+
<account_id translate="label" module="googletrustedstores">
|
32 |
+
<label>Google Merchant Account ID</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>20</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>0</show_in_website>
|
37 |
+
<show_in_store>0</show_in_store>
|
38 |
+
</account_id>
|
39 |
+
<delivery_weekdays translate="label" module="googletrustedstores">
|
40 |
+
<label>Estimated Delivery</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<sort_order>30</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>0</show_in_website>
|
45 |
+
<show_in_store>0</show_in_store>
|
46 |
+
<comment>Number of weekdays from order place.</comment>
|
47 |
+
</delivery_weekdays>
|
48 |
+
<feed_filename_shipped translate="label" module="googletrustedstores">
|
49 |
+
<label>Feed Filename Shipped</label>
|
50 |
+
<frontend_type>text</frontend_type>
|
51 |
+
<sort_order>40</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>0</show_in_website>
|
54 |
+
<show_in_store>0</show_in_store>
|
55 |
+
<comment>Name of the file generated in media directory.</comment>
|
56 |
+
</feed_filename_shipped>
|
57 |
+
<feed_filename_canceled translate="label" module="googletrustedstores">
|
58 |
+
<label>Feed Filename Canceled</label>
|
59 |
+
<frontend_type>text</frontend_type>
|
60 |
+
<sort_order>50</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>0</show_in_website>
|
63 |
+
<show_in_store>0</show_in_store>
|
64 |
+
<comment>Name of the file generated in media directory.</comment>
|
65 |
+
</feed_filename_canceled>
|
66 |
+
<feed_delimiter translate="label">
|
67 |
+
<label>Feed Delimiter</label>
|
68 |
+
<frontend_type>text</frontend_type>
|
69 |
+
<sort_order>55</sort_order>
|
70 |
+
<show_in_default>1</show_in_default>
|
71 |
+
<show_in_website>0</show_in_website>
|
72 |
+
<show_in_store>0</show_in_store>
|
73 |
+
<comment>Available delimiters: Pipe(|), Tilde(~), Tab(\t).</comment>
|
74 |
+
</feed_delimiter>
|
75 |
+
<feed_ftp_upload translate="label" module="googletrustedstores">
|
76 |
+
<label>FTP Upload Mode</label>
|
77 |
+
<frontend_type>select</frontend_type>
|
78 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
79 |
+
<sort_order>60</sort_order>
|
80 |
+
<show_in_default>1</show_in_default>
|
81 |
+
<show_in_website>0</show_in_website>
|
82 |
+
<show_in_store>0</show_in_store>
|
83 |
+
</feed_ftp_upload>
|
84 |
+
<feed_ftp_server translate="label" module="googletrustedstores">
|
85 |
+
<label>FTP Server</label>
|
86 |
+
<frontend_type>text</frontend_type>
|
87 |
+
<sort_order>70</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>0</show_in_website>
|
90 |
+
<show_in_store>0</show_in_store>
|
91 |
+
<depends>
|
92 |
+
<feed_ftp_upload>1</feed_ftp_upload>
|
93 |
+
</depends>
|
94 |
+
</feed_ftp_server>
|
95 |
+
<feed_ftp_username translate="label" module="googletrustedstores">
|
96 |
+
<label>FTP Username</label>
|
97 |
+
<frontend_type>text</frontend_type>
|
98 |
+
<sort_order>80</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
<show_in_website>0</show_in_website>
|
101 |
+
<show_in_store>0</show_in_store>
|
102 |
+
<depends>
|
103 |
+
<feed_ftp_upload>1</feed_ftp_upload>
|
104 |
+
</depends>
|
105 |
+
</feed_ftp_username>
|
106 |
+
<feed_ftp_password translate="label" module="googletrustedstores">
|
107 |
+
<label>FTP Password</label>
|
108 |
+
<frontend_type>text</frontend_type>
|
109 |
+
<sort_order>90</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>0</show_in_website>
|
112 |
+
<show_in_store>0</show_in_store>
|
113 |
+
<depends>
|
114 |
+
<feed_ftp_upload>1</feed_ftp_upload>
|
115 |
+
</depends>
|
116 |
+
</feed_ftp_password>
|
117 |
+
<frequency_ship translate="label">
|
118 |
+
<label>Cron Job - Frequency (shipped)</label>
|
119 |
+
<frontend_type>select</frontend_type>
|
120 |
+
<source_model>googletrustedstores/system_config_source_cronFrequency</source_model>
|
121 |
+
<backend_model>googletrustedstores/system_config_backend_cronShipped</backend_model>
|
122 |
+
<sort_order>100</sort_order>
|
123 |
+
<show_in_default>1</show_in_default>
|
124 |
+
<show_in_website>0</show_in_website>
|
125 |
+
<show_in_store>0</show_in_store>
|
126 |
+
</frequency_ship>
|
127 |
+
<time_ship translate="label">
|
128 |
+
<label>Cron Job - Time (shipped)</label>
|
129 |
+
<frontend_type>time</frontend_type>
|
130 |
+
<sort_order>110</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>0</show_in_website>
|
133 |
+
<show_in_store>0</show_in_store>
|
134 |
+
</time_ship>
|
135 |
+
<frequency_cancel translate="label">
|
136 |
+
<label>Cron Job - Frequency (canceled)</label>
|
137 |
+
<frontend_type>select</frontend_type>
|
138 |
+
<source_model>googletrustedstores/system_config_source_cronFrequency</source_model>
|
139 |
+
<backend_model>googletrustedstores/system_config_backend_cronCancelled</backend_model>
|
140 |
+
<sort_order>120</sort_order>
|
141 |
+
<show_in_default>1</show_in_default>
|
142 |
+
<show_in_website>0</show_in_website>
|
143 |
+
<show_in_store>0</show_in_store>
|
144 |
+
</frequency_cancel>
|
145 |
+
<time_cancel translate="label">
|
146 |
+
<label>Cron Job - Time (canceled)</label>
|
147 |
+
<frontend_type>time</frontend_type>
|
148 |
+
<sort_order>130</sort_order>
|
149 |
+
<show_in_default>1</show_in_default>
|
150 |
+
<show_in_website>0</show_in_website>
|
151 |
+
<show_in_store>0</show_in_store>
|
152 |
+
</time_cancel>
|
153 |
+
</fields>
|
154 |
+
</config>
|
155 |
+
</groups>
|
156 |
+
</googletrustedstores>
|
157 |
+
</sections>
|
158 |
+
</config>
|
app/code/community/Inavante/GoogleTrustedStores/sql/googletrustedstores_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
/* @var $installer Mage_Catalog_Model_Resource_Setup */
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->run("
|
9 |
+
|
10 |
+
-- DROP TABLE IF EXISTS {$this->getTable('googletrustedstores/log')};
|
11 |
+
|
12 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('googletrustedstores/log')} (
|
13 |
+
`id` int(11) unsigned NOT NULL auto_increment,
|
14 |
+
`order_id` varchar(255) NOT NULL default '',
|
15 |
+
`status` varchar(255) NOT NULL default '',
|
16 |
+
`cancel_reason` varchar(255) NOT NULL default '',
|
17 |
+
`shipment_title` varchar(255) NOT NULL default '',
|
18 |
+
`track_number` varchar(255) NOT NULL default '',
|
19 |
+
`created_at` timestamp NULL,
|
20 |
+
PRIMARY KEY (`id`)
|
21 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->getConnection()->addColumn($this->getTable('sales/order'), 'gts_exported', 'tinyint(1) unsigned NOT NULL default 0');
|
25 |
+
|
26 |
+
|
27 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/googletrustedstores.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_googletrustedstores_shiplog>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="googletrustedstores/adminhtml_googleTrustedStores" name="googletrustedstores.index" >
|
6 |
+
<action method="setLogType">
|
7 |
+
<params>shipped</params>
|
8 |
+
</action>
|
9 |
+
</block>
|
10 |
+
</reference>
|
11 |
+
</adminhtml_googletrustedstores_shiplog>
|
12 |
+
<adminhtml_googletrustedstores_cancellog>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="googletrustedstores/adminhtml_googleTrustedStores" name="googletrustedstores.index" >
|
15 |
+
<action method="setLogType">
|
16 |
+
<params>canceled</params>
|
17 |
+
</action>
|
18 |
+
</block>
|
19 |
+
</reference>
|
20 |
+
</adminhtml_googletrustedstores_cancellog>
|
21 |
+
|
22 |
+
<adminhtml_googletrustedstores_grid>
|
23 |
+
<block type="googletrustedstores/adminhtml_googletrustedstores_grid" name="googletrustedstores.grid" output="toHtml"></block>
|
24 |
+
</adminhtml_googletrustedstores_grid>
|
25 |
+
</layout>
|
app/design/frontend/base/default/layout/googletrustedstores.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="after_body_start">
|
5 |
+
<block type="googletrustedstores/js" name="googletrustedstores.js" as="googletrustedstores_js" />
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
+
</layout>
|
app/etc/modules/Inavante_GoogleTrustedStores.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Inavante_GoogleTrustedStores>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Core />
|
9 |
+
<Mage_Sales />
|
10 |
+
</depends>
|
11 |
+
</Inavante_GoogleTrustedStores>
|
12 |
+
</modules>
|
13 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Inavante_GoogleTrustedStores</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Inavante_GoogleTrustedStores</summary>
|
10 |
+
<description>Inavante_GoogleTrustedStores</description>
|
11 |
+
<notes>Inavante_GoogleTrustedStores</notes>
|
12 |
+
<authors><author><name>Inavante_GoogleTrustedStores</name><user>Inavante_GoogleTrustedStores</user><email>Inavante_GoogleTrustedStores@aaa.ir</email></author></authors>
|
13 |
+
<date>2012-11-16</date>
|
14 |
+
<time>09:28:05</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Inavante"><dir name="GoogleTrustedStores"><dir name="Block"><dir name="Adminhtml"><dir name="GoogleTrustedStores"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="9255d272e209341d4a715adcfbec8ef2"/></dir></dir><file name="Grid.php" hash="cad683633ff4ca6c917761a89251404d"/></dir><file name="GoogleTrustedStores.php" hash="ed33dc0ad3c2ac0564b8643dcc310fe1"/></dir><file name="Js.php" hash="7708d69b059c5cf90470bfc75177dcf9"/></dir><file name="Exception.php" hash="a47de57627389c650b9bf76f5c5e4d6b"/><dir name="Helper"><file name="Data.php" hash="b70c67e70565b9cbaeb9c96a553faba9"/><file name="Order.php" hash="570afda2b0e93311c7f4aa59127c22e7"/><file name="Shipment.php" hash="1bc27873d135f16cea3883df7cf77920"/></dir><dir name="Model"><file name="Log.php" hash="8d5e07156a25d41ecba5d05ab826a209"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="c3040a57f244e8c212a78572c4988549"/></dir><file name="Log.php" hash="ee2f4c3a6563a2f1eae1b269de6c5dd8"/><dir name="Order"><file name="Collection.php" hash="90732ef6a31714c6a551b8e14bc2fa8c"/></dir></dir><file name="Observer.php" hash="e4bc54e31cc1af8e43bf7b9fd6ed08d5"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="CronCancelled.php" hash="1d3009ff277b50b383756a6694fc5755"/><file name="CronShipped.php" hash="36b9240a4b180a19ced750d47b2128e7"/></dir><dir name="Source"><file name="CronFrequency.php" hash="f0555a16c7c13ef6088a50888d8e7ae2"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="GoogletrustedstoresController.php" hash="e91414d30a2b71612f15ab0596c8991c"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="acbe25568ebdc8e8dfb8fe2a45fb2bbe"/><file name="config.xml" hash="ba7bf074aea5b201d6b4fd1627b8e7cf"/><file name="system.xml" hash="d18941f402c4f0b92d821bb9b35db21d"/></dir><dir name="sql"><dir name="googletrustedstores_setup"><file name="install-1.0.0.php" hash="6ad23a04eedd2043f6c1cc76fcc7bb21"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Inavante_GoogleTrustedStores.xml" hash="4057b7a0f9e6835a53b31b99fdf3e353"/></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="googletrustedstores.xml" hash="0ad2a41db993c60e12aae2b3f1f41e60"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="googletrustedstores.xml" hash="b3d143d6f30543a80439bb3f985c4b74"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.2</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|