Version Notes
MyBuys Website Code & Data Feed Integration
Download this release
Release Info
Developer | Greg Croasdill |
Extension | MyBuys_Personalization_Extension |
Version | 1.0.9 |
Comparing to | |
See all releases |
Version 1.0.9
- app/code/community/Mybuys/Connector/Block/Adminhtml/Export.php +41 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/Export/Grid.php +120 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/Export/Grid/Renderer/Action.php +21 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/Job.php +56 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/Job/Grid.php +165 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/System/Config/CommentText.php +18 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/System/Config/Date.php +30 -0
- app/code/community/Mybuys/Connector/Block/Adminhtml/System/Config/Form/Field/Date.php +19 -0
- app/code/community/Mybuys/Connector/Block/Category.php +42 -0
- app/code/community/Mybuys/Connector/Block/Zone.php +34 -0
- app/code/community/Mybuys/Connector/Helper/Data.php +137 -0
- app/code/community/Mybuys/Connector/Helper/SftpConnection.php +271 -0
- app/code/community/Mybuys/Connector/Helper/Tsvfile.php +157 -0
- app/code/community/Mybuys/Connector/Model/Feed/Base.php +260 -0
- app/code/community/Mybuys/Connector/Model/Feed/Category.php +111 -0
- app/code/community/Mybuys/Connector/Model/Feed/Crosssell.php +110 -0
- app/code/community/Mybuys/Connector/Model/Feed/Email/Optin.php +104 -0
- app/code/community/Mybuys/Connector/Model/Feed/Email/Optout.php +104 -0
- app/code/community/Mybuys/Connector/Model/Feed/Product.php +229 -0
- app/code/community/Mybuys/Connector/Model/Feed/Rating.php +133 -0
- app/code/community/Mybuys/Connector/Model/Feed/Sku.php +225 -0
- app/code/community/Mybuys/Connector/Model/Feed/Transaction.php +152 -0
- app/code/community/Mybuys/Connector/Model/Generatefeeds.php +78 -0
- app/code/community/Mybuys/Connector/Model/Job.php +375 -0
- app/code/community/Mybuys/Connector/Model/Mysql4/Job.php +21 -0
- app/code/community/Mybuys/Connector/Model/Mysql4/Job/Collection.php +21 -0
- app/code/community/Mybuys/Connector/Model/Observer.php +124 -0
- app/code/community/Mybuys/Connector/Model/System/Config/EnableToggle.php +21 -0
- app/code/community/Mybuys/Connector/Model/System/Config/ProductAttributes.php +28 -0
- app/code/community/Mybuys/Connector/Model/System/Validate/ProductAttributes.php +27 -0
- app/code/community/Mybuys/Connector/Model/Transferfeeds.php +179 -0
- app/code/community/Mybuys/Connector/controllers/Adminhtml/ExportController.php +112 -0
- app/code/community/Mybuys/Connector/controllers/Adminhtml/JobController.php +165 -0
- app/code/community/Mybuys/Connector/etc/adminhtml.xml +77 -0
- app/code/community/Mybuys/Connector/etc/config.xml +171 -0
- app/code/community/Mybuys/Connector/etc/system.xml +450 -0
- app/code/community/Mybuys/Connector/sql/mybuys_setup/mysql4-install-0.1.0.php +38 -0
- app/design/adminhtml/default/default/layout/mybuys.xml +25 -0
- app/design/frontend/base/default/layout/mybuys/websitecode.xml +105 -0
- app/design/frontend/base/default/template/mybuys/websitecode/button.phtml +16 -0
- app/design/frontend/base/default/template/mybuys/websitecode/header.phtml +11 -0
- app/design/frontend/base/default/template/mybuys/websitecode/init.phtml +5 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/cat_high_level.phtml +19 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/cat_leaf.phtml +20 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/checkout.phtml +30 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/confirmation.phtml +51 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/home.phtml +5 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/product.phtml +41 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/product_review.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/search.phtml +16 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/target_rule_related.phtml +13 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/target_rule_upsell.phtml +13 -0
- app/design/frontend/base/default/template/mybuys/websitecode/params/wishlist.phtml +5 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_add_to_cart.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_cat_high.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_cat_leaf.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_checkout.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_home.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_order_confirmation.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_product_detail.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_product_review.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_search_result.phtml +7 -0
- app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_wishlist.phtml +7 -0
- app/etc/modules/Mybuys_Connector.xml +10 -0
- package.xml +18 -0
- skin/frontend/base/default/css/recommendation_zone.css +7 -0
app/code/community/Mybuys/Connector/Block/Adminhtml/Export.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_Export extends Mage_Adminhtml_Block_Widget_Grid_Container
|
12 |
+
{
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
|
17 |
+
$this->_controller = "adminhtml_export";
|
18 |
+
$this->_blockGroup = "mybuys";
|
19 |
+
$this->_headerText = Mage::helper("mybuys")->__("Generate MyBuys Baseline Data Feeds");
|
20 |
+
parent::__construct();
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
// Remove add button
|
27 |
+
$this->_removeButton('add');
|
28 |
+
|
29 |
+
// Add export all button
|
30 |
+
$this->_addButton('exportall', array(
|
31 |
+
'label' => 'Export Baseline Feeds For All Sites',
|
32 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/exportall') . '\')',
|
33 |
+
'class' => 'exportall',
|
34 |
+
));
|
35 |
+
|
36 |
+
// Call parent
|
37 |
+
return parent::_prepareLayout();
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/Export/Grid.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_Export_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
12 |
+
{
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
parent::__construct();
|
17 |
+
$this->setId("exportGrid");
|
18 |
+
$this->setDefaultDir("ASC");
|
19 |
+
$this->setSaveParametersInSession(true);
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareCollection()
|
23 |
+
{
|
24 |
+
// Build a collection representing each data feed for each website
|
25 |
+
$collection = new Varien_Data_Collection();
|
26 |
+
|
27 |
+
// Iterate websites and check configuration
|
28 |
+
$websites = Mage::app()->getWebsites(false, true);
|
29 |
+
foreach($websites as $website) {
|
30 |
+
// Grab id from website
|
31 |
+
$websiteId = $website->getId();
|
32 |
+
|
33 |
+
// Create Website Row in Grid
|
34 |
+
if(Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') == 'enabled') {
|
35 |
+
// Lookup configuration for this site
|
36 |
+
$feedTypes = '';
|
37 |
+
foreach(Mybuys_Connector_Model_Generatefeeds::getFeedTypes() as $curFeedType) {
|
38 |
+
if(Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $curFeedType) == 'enabled') {
|
39 |
+
if(strlen($feedTypes) > 0) {
|
40 |
+
$feedTypes .= ', ';
|
41 |
+
}
|
42 |
+
$feedTypes .= $curFeedType;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
$sftpUser = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/username');
|
46 |
+
$sftpDestination = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/hostname');
|
47 |
+
|
48 |
+
// Create and save grid item
|
49 |
+
$newItem = $collection->getNewEmptyItem();
|
50 |
+
$newItem->setData(array(
|
51 |
+
'id' => $website->getId(),
|
52 |
+
'website_name' => $website->getName(),
|
53 |
+
'website_code' => $website->getCode(),
|
54 |
+
'feeds' => $feedTypes,
|
55 |
+
'sftp_destination' => $sftpDestination,
|
56 |
+
'sftp_user' => $sftpUser,
|
57 |
+
));
|
58 |
+
$collection->addItem($newItem);
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
$this->setCollection($collection);
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function _prepareColumns()
|
68 |
+
{
|
69 |
+
$this->addColumn('id', array(
|
70 |
+
'header' => Mage::helper('mybuys')->__('Website ID'),
|
71 |
+
'width' => '50px',
|
72 |
+
'index' => 'id'
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addColumn('website_name', array(
|
76 |
+
'header' => Mage::helper('mybuys')->__('Website Name'),
|
77 |
+
'width' => '110px',
|
78 |
+
'index' => 'website_name'
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('website_code', array(
|
82 |
+
'header' => Mage::helper('mybuys')->__('Website Code'),
|
83 |
+
'width' => '100px',
|
84 |
+
'index' => 'website_code'
|
85 |
+
));
|
86 |
+
|
87 |
+
$this->addColumn('feeds', array(
|
88 |
+
'header' => Mage::helper('mybuys')->__('Feeds to Send'),
|
89 |
+
'width' => '320px',
|
90 |
+
'index' => 'feeds'
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('sftp_destination', array(
|
94 |
+
'header' => Mage::helper('mybuys')->__('SFTP Destination'),
|
95 |
+
'width' => '140px',
|
96 |
+
'index' => 'sftp_destination'
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('sftp_user', array(
|
100 |
+
'header' => Mage::helper('mybuys')->__('SFTP User'),
|
101 |
+
'width' => '100px',
|
102 |
+
'index' => 'sftp_user'
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->addColumn('action', array(
|
106 |
+
'header' => Mage::helper('mybuys')->__('Action'),
|
107 |
+
'filter' => false,
|
108 |
+
'sortable' => false,
|
109 |
+
'renderer' => 'mybuys/adminhtml_export_grid_renderer_action'
|
110 |
+
));
|
111 |
+
|
112 |
+
return parent::_prepareColumns();
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getRowUrl($row)
|
116 |
+
{
|
117 |
+
return $this->getUrl("*/*/exportone", array("id" => $row->getId()));
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/Export/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_Export_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
12 |
+
{
|
13 |
+
public function render(Varien_Object $row)
|
14 |
+
{
|
15 |
+
$this->getColumn()->setActions(array(array(
|
16 |
+
'url' => $this->getUrl('*/*/exportone', array('id' => $row->getId())),
|
17 |
+
'caption' => Mage::helper('mybuys')->__('Export Baseline Feed For ' . $row->getWebsiteName()),
|
18 |
+
)));
|
19 |
+
return parent::render($row);
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/Job.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* StoreFront Consulting MyBuys Magento Module
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @author StoreFront Consulting, Inc.
|
8 |
+
* @website http://www.storefrontconsulting.com
|
9 |
+
* @copyright Copyright � 2009-2012 StoreFront Consulting, Inc. All Rights Reserved.
|
10 |
+
*/
|
11 |
+
|
12 |
+
class Mybuys_Connector_Block_Adminhtml_Job extends Mage_Adminhtml_Block_Widget_Grid_Container
|
13 |
+
{
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
|
18 |
+
$this->_controller = "adminhtml_job";
|
19 |
+
$this->_blockGroup = "mybuys";
|
20 |
+
$this->_headerText = Mage::helper("mybuys")->__("MyBuys Data Feeds Job Queue");
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
// Remove add button
|
28 |
+
$this->_removeButton('add');
|
29 |
+
|
30 |
+
// Add refesh button
|
31 |
+
$this->_addButton('refresh', array(
|
32 |
+
'label' => Mage::helper("mybuys")->__("Refresh"),
|
33 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/index') . '\')',
|
34 |
+
'class' => 'refresh',
|
35 |
+
));
|
36 |
+
|
37 |
+
// Add export all button
|
38 |
+
$this->_addButton('exportall', array(
|
39 |
+
'label' => Mage::helper("mybuys")->__("Export Baseline Feeds For All Sites"),
|
40 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/exportall') . '\')',
|
41 |
+
'class' => 'exportall',
|
42 |
+
));
|
43 |
+
|
44 |
+
// Add purge all jobs button
|
45 |
+
$this->_addButton('deleteall', array(
|
46 |
+
'label' => Mage::helper("mybuys")->__("Purge Job Queue"),
|
47 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/purgeall') . '\')',
|
48 |
+
'class' => 'purgeall',
|
49 |
+
));
|
50 |
+
|
51 |
+
// Call parent
|
52 |
+
return parent::_prepareLayout();
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/Job/Grid.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_Job_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
12 |
+
{
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
parent::__construct();
|
17 |
+
$this->setId("jobGrid");
|
18 |
+
$this->setDefaultSort('job_id');
|
19 |
+
$this->setDefaultDir("DESC");
|
20 |
+
$this->setSaveParametersInSession(true);
|
21 |
+
if (Mage::registry('preparedFilter')) {
|
22 |
+
$this->setDefaultFilter(Mage::registry('preparedFilter'));
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _addColumnFilterToCollection($column)
|
27 |
+
{
|
28 |
+
$filterArr = Mage::registry('preparedFilter');
|
29 |
+
if (($column->getId() === 'store_id' || $column->getId() === 'status') && $column->getFilter()->getValue() && strpos($column->getFilter()->getValue(), ',')) {
|
30 |
+
$_inNin = explode(',', $column->getFilter()->getValue());
|
31 |
+
$inNin = array();
|
32 |
+
foreach ($_inNin as $k => $v) {
|
33 |
+
if (is_string($v) && strlen(trim($v))) {
|
34 |
+
$inNin[] = trim($v);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
if (count($inNin) > 1 && in_array($inNin[0], array('in', 'nin'))) {
|
38 |
+
$in = $inNin[0];
|
39 |
+
$values = array_slice($inNin, 1);
|
40 |
+
$this->getCollection()->addFieldToFilter($column->getId(), array($in => $values));
|
41 |
+
} else {
|
42 |
+
parent::_addColumnFilterToCollection($column);
|
43 |
+
}
|
44 |
+
} elseif (is_array($filterArr) && array_key_exists($column->getId(), $filterArr) && isset($filterArr[$column->getId()])) {
|
45 |
+
$this->getCollection()->addFieldToFilter($column->getId(), $filterArr[$column->getId()]);
|
46 |
+
} else {
|
47 |
+
parent::_addColumnFilterToCollection($column);
|
48 |
+
}
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function _prepareCollection()
|
53 |
+
{
|
54 |
+
// Create collection
|
55 |
+
$collection = Mage::getResourceModel('mybuys/job_collection');
|
56 |
+
$this->setCollection($collection);
|
57 |
+
return parent::_prepareCollection();
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function _prepareColumns()
|
61 |
+
{
|
62 |
+
$this->addColumn('job_id', array(
|
63 |
+
'header' => Mage::helper('mybuys')->__('Job ID'),
|
64 |
+
'width' => '50px',
|
65 |
+
'index' => 'job_id'
|
66 |
+
));
|
67 |
+
|
68 |
+
$this->addColumn('dependent_on_job_id', array(
|
69 |
+
'header' => Mage::helper('mybuys')->__('Parent Job'),
|
70 |
+
'width' => '50px',
|
71 |
+
'index' => 'dependent_on_job_id'
|
72 |
+
));
|
73 |
+
|
74 |
+
$this->addColumn('website_id', array(
|
75 |
+
'header' => Mage::helper('mybuys')->__('Website ID'),
|
76 |
+
'width' => '50px',
|
77 |
+
'index' => 'website_id'
|
78 |
+
));
|
79 |
+
|
80 |
+
$this->addColumn('type', array(
|
81 |
+
'header' => Mage::helper('mybuys')->__('Job Type'),
|
82 |
+
'width' => '100px',
|
83 |
+
'index' => 'type',
|
84 |
+
'type' => 'options',
|
85 |
+
'options' => array(
|
86 |
+
Mybuys_Connector_Model_Job::TYPE_GENERATE_BASELINE => Mage::helper('mybuys')->__('Baseline Feed'),
|
87 |
+
Mybuys_Connector_Model_Job::TYPE_GENERATE_DAILY => Mage::helper('mybuys')->__('Daily Feed'),
|
88 |
+
Mybuys_Connector_Model_Job::TYPE_TRANSFER => Mage::helper('mybuys')->__('SFTP Transfer'),
|
89 |
+
),
|
90 |
+
));
|
91 |
+
|
92 |
+
$this->addColumn('feed_type', array(
|
93 |
+
'header' => Mage::helper('mybuys')->__('Feed Type'),
|
94 |
+
'width' => '100px',
|
95 |
+
'index' => 'feed_type'
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addColumn('scheduled_at', array(
|
99 |
+
'header' => Mage::helper('mybuys')->__('Scheduled'),
|
100 |
+
'type' => 'datetime',
|
101 |
+
'width' => '160px',
|
102 |
+
'index' => 'scheduled_at'
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->addColumn('started_at', array(
|
106 |
+
'header' => Mage::helper('mybuys')->__('Started'),
|
107 |
+
'type' => 'datetime',
|
108 |
+
'width' => '160px',
|
109 |
+
'index' => 'started_at'
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('ended_at', array(
|
113 |
+
'header' => Mage::helper('mybuys')->__('Completed'),
|
114 |
+
'type' => 'datetime',
|
115 |
+
'width' => '160px',
|
116 |
+
'index' => 'ended_at'
|
117 |
+
));
|
118 |
+
|
119 |
+
$this->addColumn('status', array(
|
120 |
+
'header' => Mage::helper('mybuys')->__('Status'),
|
121 |
+
'width' => '100px',
|
122 |
+
'index' => 'status',
|
123 |
+
'type' => 'options',
|
124 |
+
'options' => array(
|
125 |
+
Mybuys_Connector_Model_Job::STATUS_SCHEDULED => Mage::helper('mybuys')->__('Scheduled'),
|
126 |
+
Mybuys_Connector_Model_Job::STATUS_RUNNING => Mage::helper('mybuys')->__('Running'),
|
127 |
+
Mybuys_Connector_Model_Job::STATUS_COMPLETED => Mage::helper('mybuys')->__('Completed'),
|
128 |
+
Mybuys_Connector_Model_Job::STATUS_ERROR => Mage::helper('mybuys')->__('Error'),
|
129 |
+
),
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('min_entity_id', array(
|
133 |
+
'header' => Mage::helper('mybuys')->__('Next Batch Start ID'),
|
134 |
+
'width' => '100px',
|
135 |
+
'index' => 'min_entity_id'
|
136 |
+
));
|
137 |
+
|
138 |
+
$this->addColumn('error_message', array(
|
139 |
+
'header' => Mage::helper('mybuys')->__('Error Message'),
|
140 |
+
'index' => 'error_message'
|
141 |
+
));
|
142 |
+
|
143 |
+
return parent::_prepareColumns();
|
144 |
+
}
|
145 |
+
|
146 |
+
protected function _prepareMassaction()
|
147 |
+
{
|
148 |
+
$this->setMassactionIdField('job_id');
|
149 |
+
$this->getMassactionBlock()->setFormFieldName('job_id');
|
150 |
+
|
151 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
152 |
+
'label' => Mage::helper('mybuys')->__('Delete'),
|
153 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
154 |
+
'confirm' => Mage::helper('mybuys')->__('Delete selected job(s)?')
|
155 |
+
));
|
156 |
+
|
157 |
+
$this->getMassactionBlock()->addItem('execute', array(
|
158 |
+
'label' => Mage::helper('mybuys')->__('Run Job'),
|
159 |
+
'url' => $this->getUrl('*/*/massRun'),
|
160 |
+
'confirm' => Mage::helper('mybuys')->__('Run selected job(s)? Note that running multiple and/or jobs may impact site performance.')
|
161 |
+
));
|
162 |
+
|
163 |
+
return $this;
|
164 |
+
}
|
165 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/System/Config/CommentText.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_System_Config_CommentText extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
12 |
+
|
13 |
+
{
|
14 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
return $element->getComment();
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/System/Config/Date.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_System_Form_Field_Date extends Mage_Adminhtml_Block_System_Config_Form_Field
|
12 |
+
{
|
13 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$date = new Varien_Data_Form_Element_Date;
|
16 |
+
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
17 |
+
|
18 |
+
$data = array(
|
19 |
+
'name' => $element->getName(),
|
20 |
+
'html_id' => $element->getId(),
|
21 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
22 |
+
);
|
23 |
+
$date->setData($data);
|
24 |
+
$date->setValue($element->getValue(), $format);
|
25 |
+
$date->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
|
26 |
+
$date->setForm($element->getForm());
|
27 |
+
|
28 |
+
return $date->getElementHtml();
|
29 |
+
}
|
30 |
+
}
|
app/code/community/Mybuys/Connector/Block/Adminhtml/System/Config/Form/Field/Date.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Adminhtml_System_Config_Form_Field_Date extends Mage_Adminhtml_Block_System_Config_Form_Field
|
12 |
+
{
|
13 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$element->setFormat(Varien_Date::DATE_INTERNAL_FORMAT); //or other format
|
16 |
+
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
|
17 |
+
return parent::render($element);
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Mybuys/Connector/Block/Category.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Category extends Mage_Core_Block_Template
|
12 |
+
{
|
13 |
+
|
14 |
+
public function getProductsInCategory(int $catId)
|
15 |
+
{
|
16 |
+
$_category = Mage::getModel('catalog/category')->load($catId);
|
17 |
+
$subs = $_category->getAllChildren(true);
|
18 |
+
$result = array();
|
19 |
+
foreach($subs as $cat_id)
|
20 |
+
{
|
21 |
+
$category = new Mage_Catalog_Model_Category();
|
22 |
+
$category->load($cat_id);
|
23 |
+
$collection = $category->getProductCollection();
|
24 |
+
foreach ($collection as $product)
|
25 |
+
{
|
26 |
+
$result[] = $product->getId();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
return $result;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function zoneEnabled()
|
33 |
+
{
|
34 |
+
$zoneConfig = Mage::getStoreConfig('mybuys_websitecode/general/website_code');
|
35 |
+
if($zoneConfig == 'enabled')
|
36 |
+
{
|
37 |
+
return true;
|
38 |
+
}
|
39 |
+
else { return false; }
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/Mybuys/Connector/Block/Zone.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Block_Zone extends Mage_Core_Block_Template
|
12 |
+
{
|
13 |
+
|
14 |
+
public function zonesEnabled()
|
15 |
+
{
|
16 |
+
$webConfig = Mage::getStoreConfig('mybuys_websitecode/general/website_code');
|
17 |
+
if($webConfig == 'enabled')
|
18 |
+
{
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
else { return false; }
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getZoneStatus($page)
|
25 |
+
{
|
26 |
+
$zoneConfig = Mage::getStoreConfig('mybuys_websitecode/recommendation');
|
27 |
+
if ($zoneConfig[$page] == 'enabled')
|
28 |
+
{
|
29 |
+
return true;
|
30 |
+
}
|
31 |
+
else { return false; }
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/Mybuys/Connector/Helper/Data.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constants
|
15 |
+
*/
|
16 |
+
const LOG_FILE = 'mybuys.log';
|
17 |
+
/*
|
18 |
+
* Example of how logging should be done in this extension:
|
19 |
+
* Mage::log($message, Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
20 |
+
*/
|
21 |
+
|
22 |
+
public function sendErrorEmail($websiteId, $error)
|
23 |
+
{
|
24 |
+
try {
|
25 |
+
// Get recipients
|
26 |
+
$recipients = explode(',', Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/notification/emails'));
|
27 |
+
if (!count($recipients)) {
|
28 |
+
Mage::log('No recipients for error email', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
// Create Zend_Mail
|
33 |
+
$mail = new Zend_Mail();
|
34 |
+
|
35 |
+
// Set recipients
|
36 |
+
foreach ($recipients as $email) {
|
37 |
+
$mail->addTo(trim($email));
|
38 |
+
}
|
39 |
+
|
40 |
+
// Subject
|
41 |
+
$mail->setSubject('MyBuys Magento Extension Error Nofication - ' . Mage::getSingleton('core/date')->gmtDate());
|
42 |
+
|
43 |
+
// Body
|
44 |
+
$sBody = 'Timestamp: ' . Mage::getSingleton('core/date')->gmtDate() . "\n\n";
|
45 |
+
$sBody .= "Error:\n$error\n\n";
|
46 |
+
$mail->setBodyText($sBody);
|
47 |
+
|
48 |
+
// From
|
49 |
+
$mail->setFrom(Mage::getStoreConfig('general/store_information/address'));
|
50 |
+
|
51 |
+
// Send
|
52 |
+
$mail->send();
|
53 |
+
}
|
54 |
+
catch(Exception $e) {
|
55 |
+
// Log exception
|
56 |
+
Mage::logException($e);
|
57 |
+
Mage::log('Failed to send error email, error: ', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
58 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Validate feed configuration settings for one website or all websites
|
64 |
+
*
|
65 |
+
*/
|
66 |
+
public function validateFeedConfiguration($websiteId)
|
67 |
+
{
|
68 |
+
// Check input params
|
69 |
+
$websites = array();
|
70 |
+
if($websiteId) {
|
71 |
+
$websites[] = $websiteId;
|
72 |
+
}
|
73 |
+
else {
|
74 |
+
$websiteModels = Mage::app()->getWebsites(false, true);
|
75 |
+
foreach($websiteModels as $curWebsite) {
|
76 |
+
$websites[] = $curWebsite->getId();
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
// Track if feeds enabled for any website
|
81 |
+
$bFeedsEnabled = false;
|
82 |
+
// Iterate all websites
|
83 |
+
foreach($websites as $curWebsiteId) {
|
84 |
+
// Check data feeds enabled
|
85 |
+
// Check feed of this type if config is enabled
|
86 |
+
if (Mage::app()->getWebsite($curWebsiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') == 'enabled') {
|
87 |
+
// Track if feeds enabled for any website
|
88 |
+
$bFeedsEnabled = true;
|
89 |
+
|
90 |
+
// Lookup up throttle param
|
91 |
+
$throttle = Mage::app()->getWebsite($curWebsiteId)->getConfig('mybuys_datafeeds/advanced/throttle');
|
92 |
+
if($throttle < 0) {
|
93 |
+
Mage::throwException('Invalid throttle parameter (' . $throttle . ') for website id: ' . $curWebsiteId);
|
94 |
+
}
|
95 |
+
|
96 |
+
// Assemble SFTP credentials
|
97 |
+
try {
|
98 |
+
// Get hostname & port
|
99 |
+
$sftpHost = Mage::app()->getWebsite($curWebsiteId)->getConfig('mybuys_datafeeds/connect/hostname');
|
100 |
+
$sftpPort = Mage::app()->getWebsite($curWebsiteId)->getConfig('mybuys_datafeeds/connect/port');
|
101 |
+
// Get user credentials from config
|
102 |
+
$sftpUser = Mage::app()->getWebsite($curWebsiteId)->getConfig('mybuys_datafeeds/connect/username');
|
103 |
+
$sftpPassword = Mage::app()->getWebsite($curWebsiteId)->getConfig('mybuys_datafeeds/connect/password');
|
104 |
+
$sftpPassword = Mage::helper('core')->decrypt(trim($sftpPassword));
|
105 |
+
}
|
106 |
+
catch (Exception $e)
|
107 |
+
{
|
108 |
+
// Log
|
109 |
+
Mage::logException($e);
|
110 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
111 |
+
// Throw proper error message
|
112 |
+
Mage::throwException('Error looking up feed transfer connectivity parameters for website id: ' . $curWebsiteId);
|
113 |
+
}
|
114 |
+
// Check SFTP credentials
|
115 |
+
if(strlen($sftpHost) <= 0) {
|
116 |
+
Mage::throwException('SFTP host (' . $sftpHost . ') setting is invalid for website id: ' . $curWebsiteId);
|
117 |
+
}
|
118 |
+
if(strlen($sftpPort) <= 0 || $sftpPort < 1 || $sftpPort > 65535) {
|
119 |
+
Mage::throwException('SFTP port (' . $sftpPort . ') setting is invalid for website id: ' . $curWebsiteId);
|
120 |
+
}
|
121 |
+
if(strlen($sftpUser) <= 0) {
|
122 |
+
Mage::throwException('SFTP user (' . $sftpUser . ') setting is invalid for website id: ' . $curWebsiteId);
|
123 |
+
}
|
124 |
+
if(strlen($sftpPassword) <= 0) {
|
125 |
+
Mage::throwException('SFTP password setting is invalid for website id: ' . $curWebsiteId);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
// Now send error message if feeds not enable for any website
|
131 |
+
if(!$bFeedsEnabled) {
|
132 |
+
Mage::throwException('Data feeds or not enabled for any website.');
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
}
|
137 |
+
|
app/code/community/Mybuys/Connector/Helper/SftpConnection.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Includes
|
12 |
+
require_once('phpseclib/Net/SFTP.php');
|
13 |
+
|
14 |
+
class Mybuys_Connector_Helper_SftpConnection extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Constants
|
18 |
+
*
|
19 |
+
* Hardcode MyBuys SFTP port and timeout value
|
20 |
+
*/
|
21 |
+
const SFTP_TIMEOUT = 20;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Connection handle
|
25 |
+
*/
|
26 |
+
private $_oConnection = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Connect
|
30 |
+
* @return boolean
|
31 |
+
*/
|
32 |
+
public function connect($host, $port, $user, $pw)
|
33 |
+
{
|
34 |
+
|
35 |
+
try
|
36 |
+
{
|
37 |
+
// Close
|
38 |
+
if (isset($this->_oConnection)) {
|
39 |
+
$this->close();
|
40 |
+
}
|
41 |
+
|
42 |
+
// Get config values
|
43 |
+
// -- Server
|
44 |
+
$sServer = $host;
|
45 |
+
$sServer = ($sServer ? trim($sServer) : '');
|
46 |
+
// -- Server
|
47 |
+
$sPort = $port;
|
48 |
+
$sPort = ($sPort ? trim($sPort) : '');
|
49 |
+
// -- Username
|
50 |
+
$sUsername = $user;
|
51 |
+
$sUsername = ($sUsername ? trim($sUsername) : '');
|
52 |
+
// -- Password
|
53 |
+
$sPassword = $pw;
|
54 |
+
$sPassword = ($sPassword ? trim($sPassword) : '');
|
55 |
+
|
56 |
+
// Check credentials
|
57 |
+
if (!strlen($sServer)) {
|
58 |
+
Mage::throwException('Invalid SFTP host: ' . $sServer);
|
59 |
+
}
|
60 |
+
if (!strlen($sPort) || !ctype_digit($sPort)) {
|
61 |
+
Mage::throwException('Invalid SFTP port: ' . $sPort);
|
62 |
+
}
|
63 |
+
if (!strlen($sUsername)) {
|
64 |
+
Mage::throwException('Invalid SFTP user: ' . $sUsername);
|
65 |
+
}
|
66 |
+
if (!strlen($sPassword)) {
|
67 |
+
Mage::throwException('Invalid SFTP password: ' . $sPassword);
|
68 |
+
}
|
69 |
+
|
70 |
+
// -- Open connection
|
71 |
+
$this->_oConnection = new Net_SFTP($sServer, $sPort, self::SFTP_TIMEOUT);
|
72 |
+
if (!$this->_oConnection->login($sUsername, $sPassword)) {
|
73 |
+
Mage::throwException(sprintf(__("Unable to open SFTP connection as %s@%s", $sUsername, $sServer)));
|
74 |
+
}
|
75 |
+
|
76 |
+
return true;
|
77 |
+
}
|
78 |
+
|
79 |
+
catch (Exception $e)
|
80 |
+
{
|
81 |
+
// Log
|
82 |
+
Mage::logException($e);
|
83 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
84 |
+
if ($this->_oConnection->getLastSFTPError())
|
85 |
+
Mage::log("SFTP reported error is ". $this->_oConnection->getLastSFTPError(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
86 |
+
}
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Close
|
92 |
+
* @return boolean
|
93 |
+
*/
|
94 |
+
public function close()
|
95 |
+
{
|
96 |
+
try
|
97 |
+
{
|
98 |
+
// Close connection
|
99 |
+
if (isset($this->_oConnection)) {
|
100 |
+
$bRes = $this->_oConnection->disconnect();
|
101 |
+
unset($this->_oConnection);
|
102 |
+
return $bRes;
|
103 |
+
}
|
104 |
+
else {
|
105 |
+
Mage::throwException('Connection not open!');
|
106 |
+
}
|
107 |
+
}
|
108 |
+
catch (Exception $e)
|
109 |
+
{
|
110 |
+
// Log
|
111 |
+
Mage::logException($e);
|
112 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
113 |
+
}
|
114 |
+
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Is connected
|
120 |
+
* @return boolean
|
121 |
+
*/
|
122 |
+
public function isConnected()
|
123 |
+
{
|
124 |
+
return (isset($this->_oConnection));
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Change directory
|
129 |
+
* @param string directory
|
130 |
+
* @return boolean
|
131 |
+
*/
|
132 |
+
public function changeDir($sDir)
|
133 |
+
{
|
134 |
+
try
|
135 |
+
{
|
136 |
+
// Close connection
|
137 |
+
if (!$this->isConnected()) {
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
|
141 |
+
// Get filename
|
142 |
+
return $this->_oConnection->chdir($sDir);
|
143 |
+
}
|
144 |
+
catch (Exception $e)
|
145 |
+
{
|
146 |
+
// Log
|
147 |
+
Mage::logException($e);
|
148 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
149 |
+
}
|
150 |
+
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Make directory
|
156 |
+
* @param string directory
|
157 |
+
* @return boolean
|
158 |
+
*/
|
159 |
+
public function makeDir($sDir)
|
160 |
+
{
|
161 |
+
try
|
162 |
+
{
|
163 |
+
// Close connection
|
164 |
+
if (!$this->isConnected()) {
|
165 |
+
return false;
|
166 |
+
}
|
167 |
+
|
168 |
+
// Get filename
|
169 |
+
return $this->_oConnection->mkdir($sDir);
|
170 |
+
}
|
171 |
+
catch (Exception $e)
|
172 |
+
{
|
173 |
+
// Log
|
174 |
+
Mage::logException($e);
|
175 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
176 |
+
}
|
177 |
+
|
178 |
+
return false;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* List files
|
183 |
+
* @param string directory
|
184 |
+
* @return array
|
185 |
+
*/
|
186 |
+
public function listFiles($sDir = '.')
|
187 |
+
{
|
188 |
+
try
|
189 |
+
{
|
190 |
+
// Close connection
|
191 |
+
if (!$this->isConnected()) {
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
|
195 |
+
// Get filename
|
196 |
+
return $this->_oConnection->nlist($sDir);
|
197 |
+
}
|
198 |
+
catch (Exception $e)
|
199 |
+
{
|
200 |
+
// Log
|
201 |
+
Mage::logException($e);
|
202 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
203 |
+
}
|
204 |
+
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Transfer file
|
210 |
+
* @param string Local file path
|
211 |
+
* @return boolean
|
212 |
+
*/
|
213 |
+
public function putFile($sLocalFilePath)
|
214 |
+
{
|
215 |
+
try
|
216 |
+
{
|
217 |
+
// Close connection
|
218 |
+
if (!$this->isConnected()) {
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
// Get filename
|
223 |
+
$sFilename = basename($sLocalFilePath);
|
224 |
+
|
225 |
+
// Transfer
|
226 |
+
$bSuccess = $this->_oConnection->put($sFilename, $sLocalFilePath, NET_SFTP_LOCAL_FILE);
|
227 |
+
|
228 |
+
// Check success and log errors
|
229 |
+
if(!$bSuccess) {
|
230 |
+
Mage::log('SFTP Error: ' . $this->_oConnection->getLastSFTPError(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
231 |
+
}
|
232 |
+
|
233 |
+
// Return success
|
234 |
+
return $bSuccess;
|
235 |
+
}
|
236 |
+
catch (Exception $e)
|
237 |
+
{
|
238 |
+
// Log
|
239 |
+
Mage::logException($e);
|
240 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
241 |
+
}
|
242 |
+
|
243 |
+
return false;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Transfer file and delete when successful as one atomic operation
|
248 |
+
* @param string Local file path
|
249 |
+
* @return boolean
|
250 |
+
*/
|
251 |
+
public function putAndDeleteFile($sLocalFilePath)
|
252 |
+
{
|
253 |
+
try
|
254 |
+
{
|
255 |
+
$bSuccess = $this->putFile($sLocalFilePath);
|
256 |
+
if($bSuccess) {
|
257 |
+
$oIo = new Varien_Io_File();
|
258 |
+
$oIo->rm($sLocalFilePath);
|
259 |
+
}
|
260 |
+
return $bSuccess;
|
261 |
+
}
|
262 |
+
catch (Exception $e)
|
263 |
+
{
|
264 |
+
// Log
|
265 |
+
Mage::logException($e);
|
266 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
267 |
+
}
|
268 |
+
|
269 |
+
return false;
|
270 |
+
}
|
271 |
+
}
|
app/code/community/Mybuys/Connector/Helper/Tsvfile.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Helper_Tsvfile extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Variables
|
16 |
+
*/
|
17 |
+
private $_filename;
|
18 |
+
private $_handle;
|
19 |
+
private $_path;
|
20 |
+
private $_errorMessage;
|
21 |
+
private $_columnHeaders;
|
22 |
+
|
23 |
+
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
$this->_filename = null;
|
27 |
+
$this->_handle = null;
|
28 |
+
$this->_path = null;
|
29 |
+
$this->_errorMessage = null;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Open file
|
34 |
+
* @param array $columnHeaders An array of column header names, one for each column
|
35 |
+
* @param string $filename fully qualified filename + path. (directory must be writable)
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
public function open($filename, array $columnHeaders)
|
39 |
+
{
|
40 |
+
$this->_columnHeaders = $columnHeaders;
|
41 |
+
$this->_filename = $filename;
|
42 |
+
|
43 |
+
try
|
44 |
+
{
|
45 |
+
// Open file, truncate for writing
|
46 |
+
$this->_handle = fopen($this->_filename, 'w');
|
47 |
+
// Build header row string with delimiters & termination
|
48 |
+
$rowString = implode("\t", $this->encodeFields($columnHeaders)) . "\r\n";
|
49 |
+
// Write row to file, including delimiters and termination
|
50 |
+
$result = fwrite($this->_handle, $rowString);
|
51 |
+
}
|
52 |
+
catch (Exception $e) {
|
53 |
+
Mage::logException($e);
|
54 |
+
return false;
|
55 |
+
}
|
56 |
+
|
57 |
+
return true;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Re Open existing file
|
62 |
+
* @param string $filename fully qualified filename + path. (directory must be writable)
|
63 |
+
* @return boolean
|
64 |
+
*/
|
65 |
+
public function reopen($filename, array $columnHeaders)
|
66 |
+
{
|
67 |
+
$this->_columnHeaders = $columnHeaders;
|
68 |
+
$this->_filename = $filename;
|
69 |
+
|
70 |
+
try
|
71 |
+
{
|
72 |
+
// Reopen file, append for writing
|
73 |
+
$this->_handle = fopen($this->_filename, 'a');
|
74 |
+
}
|
75 |
+
catch (Exception $e) {
|
76 |
+
Mage::logException($e);
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
return true;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Close file
|
85 |
+
*/
|
86 |
+
public function close()
|
87 |
+
{
|
88 |
+
try
|
89 |
+
{
|
90 |
+
fclose($this->_handle);
|
91 |
+
}
|
92 |
+
catch (Exception $e) {
|
93 |
+
Mage::logException($e);
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
|
97 |
+
return true;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Write row to file
|
102 |
+
*
|
103 |
+
* @param array $rowValues An associative array of columns => values, cells for columns not included in this row are left empty
|
104 |
+
* @return boolean
|
105 |
+
*/
|
106 |
+
public function writeRow(array $rowValues)
|
107 |
+
{
|
108 |
+
try
|
109 |
+
{
|
110 |
+
// Filter and order rowValues based on column headers
|
111 |
+
$selectedRowValues = array();
|
112 |
+
foreach($this->_columnHeaders as $columnHeader) {
|
113 |
+
$selectedRowValues[] = $rowValues[$columnHeader];
|
114 |
+
}
|
115 |
+
|
116 |
+
// Convert values to utf8
|
117 |
+
$convertedRowValues = $this->encodeFields($selectedRowValues);
|
118 |
+
// Build row string with delimiters & termination
|
119 |
+
$rowString = implode("\t", $convertedRowValues) . "\r\n";
|
120 |
+
// Write row to file, including delimiters and termination
|
121 |
+
$result = fwrite($this->_handle, $rowString);
|
122 |
+
// Check result
|
123 |
+
if($result != strlen($rowString)) {
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
catch (Exception $e) {
|
128 |
+
Mage::logException($e);
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
return true;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Convert strings in array to Utf8 and encode for CSV file usage
|
137 |
+
* @param array $values
|
138 |
+
* @return array $converted
|
139 |
+
*/
|
140 |
+
private function encodeFields(array $values)
|
141 |
+
{
|
142 |
+
$converted = array();
|
143 |
+
foreach($values as $value)
|
144 |
+
{
|
145 |
+
// Encode in utf8
|
146 |
+
$newVal = utf8_encode($value);
|
147 |
+
// Encode delimters inside field
|
148 |
+
$newVal = str_replace('"', '""', $newVal);
|
149 |
+
// Add delimiter
|
150 |
+
$newVal = '"' . $newVal . '"';
|
151 |
+
// Add to converted array
|
152 |
+
array_push($converted,$newVal);
|
153 |
+
}
|
154 |
+
|
155 |
+
return $converted;
|
156 |
+
}
|
157 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Base.php
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Base extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $_optionValueMap=array();
|
15 |
+
|
16 |
+
protected $_attrSetIdToName=array();
|
17 |
+
|
18 |
+
protected function _initAttributeSets($storeId=0)
|
19 |
+
{
|
20 |
+
$optionValueTable = Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value');
|
21 |
+
$sql="select option_id, value from $optionValueTable where store_id=$storeId";
|
22 |
+
$attributeValues = Mage::getSingleton('core/resource')
|
23 |
+
->getConnection('default_read')
|
24 |
+
->fetchAll($sql);
|
25 |
+
|
26 |
+
//create an array to map attribute option id's into option values
|
27 |
+
foreach ($attributeValues as $values) {
|
28 |
+
$this->_attrSetIdToName[$values['option_id']] = $values['value'];
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
35 |
+
// This field must be populated by derived classes
|
36 |
+
public function getFieldMap()
|
37 |
+
{
|
38 |
+
return array();
|
39 |
+
}
|
40 |
+
|
41 |
+
// Feed file name key
|
42 |
+
// This must be overridde by derived classes
|
43 |
+
public function getFileNameKey()
|
44 |
+
{
|
45 |
+
return '';
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Build collection object used to generate feed
|
50 |
+
*
|
51 |
+
* @param int|string $websiteId Id of the website for which to generate feed
|
52 |
+
* @return Varien_Data_Collection_Db Collection of data to spit out into feed file
|
53 |
+
*/
|
54 |
+
public function getFeedCollection($websiteId)
|
55 |
+
{
|
56 |
+
return null;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
61 |
+
*
|
62 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
63 |
+
*/
|
64 |
+
protected function addIncrementalFilter($collection, $incrementalDate=null)
|
65 |
+
{
|
66 |
+
return null;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
71 |
+
*
|
72 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
73 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
74 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
75 |
+
*/
|
76 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
77 |
+
{
|
78 |
+
return null;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Add custom attributes selected by magento admin to query
|
83 |
+
*
|
84 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
85 |
+
* @param string $customAttribs Comma separated list of attribute codes
|
86 |
+
* @param array $fieldMap Reference to fieldmap where attribute codes should also be added
|
87 |
+
*/
|
88 |
+
protected function addCustomAttributes($collection, $customAttribs, &$fieldMap)
|
89 |
+
{
|
90 |
+
// Log
|
91 |
+
Mage::log("Adding custom attributes include in query: {$customAttribs}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
92 |
+
// Check if we have any custom attribs
|
93 |
+
if (strlen(trim($customAttribs)) > 0) {
|
94 |
+
// Iterate custom attribs
|
95 |
+
foreach (explode(',', $customAttribs) as $curAttrib) {
|
96 |
+
// Trim attribute code
|
97 |
+
$curAttrib = trim($curAttrib);
|
98 |
+
// Check if attribute exists
|
99 |
+
|
100 |
+
$_attribute=$collection->getAttribute($curAttrib);
|
101 |
+
if ($_attribute === false) {
|
102 |
+
// Attribute not found
|
103 |
+
Mage::throwException("Attribte not found: {$curAttrib}");
|
104 |
+
}
|
105 |
+
// Log
|
106 |
+
Mage::log("Adding attribute to query: {$curAttrib}", Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
107 |
+
|
108 |
+
if ($_attribute->getFrontendInput()=="select" || $_attribute->getFrontendInput()=="multiselect") {
|
109 |
+
// attribute is a select of multi-select input and attribute id to value translation is needed
|
110 |
+
// Log
|
111 |
+
Mage::log("Note - Attribute needs translation", Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
112 |
+
$this->_optionValueMap['custom_' . $curAttrib]=true;
|
113 |
+
}
|
114 |
+
// Add attribute to select
|
115 |
+
$collection
|
116 |
+
->addExpressionAttributeToSelect('custom_' . $curAttrib, "{{" . $curAttrib . "}}", $curAttrib)
|
117 |
+
->addAttributeToSelect($curAttrib);
|
118 |
+
// Add attribute to map
|
119 |
+
$fieldMap['custom_' . $curAttrib] = 'custom_' . $curAttrib;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
// Return the original collection object
|
124 |
+
return $collection;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Generate one feed for this website and store feed file at the specified path
|
129 |
+
*
|
130 |
+
* @param int|string $websiteId Id of the website for which to generate data feed file
|
131 |
+
* @param string $exportPath Path to the folder where data feed files should be stored
|
132 |
+
* @param bool $bBaselineFile Should this file be a baseline file or an automated daily file
|
133 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run, 0 = unlimited throttle
|
134 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
135 |
+
* @param bool $bDone Indicates when the feed generation is done
|
136 |
+
*/
|
137 |
+
public function generate($websiteId, $exportPath, $bBaselineFile, $throttle, &$minEntityId, &$bDone)
|
138 |
+
{
|
139 |
+
// Log
|
140 |
+
Mage::log('Generating ' . $this->getFileNameKey() . ' data feed for website with Id: ' . $websiteId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
141 |
+
Mage::log("Export path: {$exportPath}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
142 |
+
Mage::log("Baseline feed: {$bBaselineFile}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
143 |
+
Mage::log("Throttle: {$throttle}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
144 |
+
Mage::log("Min entity_id: {$minEntityId}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
145 |
+
|
146 |
+
// initialize done flag
|
147 |
+
$bDone = false;
|
148 |
+
|
149 |
+
//
|
150 |
+
// Build output file name
|
151 |
+
//
|
152 |
+
|
153 |
+
// Lookup website name
|
154 |
+
$websitecode = Mage::app()->getWebsite($websiteId)->getCode();
|
155 |
+
|
156 |
+
// Build date for incremental query
|
157 |
+
$incrementalDate = date("Y-m-d", time() - 60 * 60 * 24);
|
158 |
+
|
159 |
+
// Check if baseline or incremental feed
|
160 |
+
if (!$bBaselineFile) {
|
161 |
+
// Generating automated feed file, use full file name
|
162 |
+
$filename = $exportPath . DS . $this->getFileNameKey() . '-websiteid-' . $websiteId . '-' . $websitecode . '-' . $incrementalDate . '.tsv';
|
163 |
+
} else {
|
164 |
+
// Generating baseline file, use simple file name
|
165 |
+
$filename = $exportPath . DS . $this->getFileNameKey() . '-websiteid-' . $websiteId . '-' . $websitecode . '-' . 'baseline.tsv';
|
166 |
+
}
|
167 |
+
Mage::log("Output Filenane: {$filename}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
168 |
+
|
169 |
+
// build collection
|
170 |
+
$collection = $this->getFeedCollection($websiteId);
|
171 |
+
|
172 |
+
// Add throttle filter when configured
|
173 |
+
if ($throttle > 0) {
|
174 |
+
$collection = $this->addThrottleFilter($collection, $throttle, $minEntityId);
|
175 |
+
}
|
176 |
+
|
177 |
+
// Add incremental / automatic daily feed filter
|
178 |
+
if (!$bBaselineFile) {
|
179 |
+
$collection = $this->addIncrementalFilter($collection, $incrementalDate);
|
180 |
+
}
|
181 |
+
|
182 |
+
//Mage::log(ucfirst($this->getFileNameKey()) . " feed query", Zend_Log::INFO, "mybuys_query.log");
|
183 |
+
//Mage::log($collection->getSelect()->__toString(), Zend_Log::INFO, "mybuys_query.log");
|
184 |
+
|
185 |
+
// Get column headers from field map provided by derived class
|
186 |
+
$headerColumns = array_values($this->getFieldMap());
|
187 |
+
|
188 |
+
// Create / open output file
|
189 |
+
$file = Mage::helper('mybuys/tsvfile');
|
190 |
+
/* @var $file Mybuys_Connector_Helper_Tsvfile */
|
191 |
+
// Open file, either create new one or open existing depending on $throttle and $minEntityId
|
192 |
+
if ($throttle > 0 && $minEntityId > 0) {
|
193 |
+
// open existing file
|
194 |
+
$bSuccess = $file->reopen($filename, $headerColumns);
|
195 |
+
} else {
|
196 |
+
// otherwise, start new file with headers
|
197 |
+
$bSuccess = $file->open($filename, $headerColumns);
|
198 |
+
}
|
199 |
+
|
200 |
+
// Check success opening file
|
201 |
+
if (!$bSuccess) {
|
202 |
+
Mage::log('Failed to open data feed file:' . $filename, Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
//get all the attribute values for this website
|
208 |
+
Mage::log('Initializing attribute values', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
209 |
+
$this->_initAttributeSets();
|
210 |
+
|
211 |
+
// Iterate data rows and output to file
|
212 |
+
foreach ($collection as $curRow) {
|
213 |
+
// Build row output array
|
214 |
+
// Put data into assoc array by column headers
|
215 |
+
$curRowData = $curRow->getData();
|
216 |
+
$rowValues = array();
|
217 |
+
|
218 |
+
foreach ($this->getFieldMap() as $mapKey => $mapValue) {
|
219 |
+
//if the attribute is a select or multiselect then we need to translate the
|
220 |
+
// option id value into the display value
|
221 |
+
if ($this->_optionValueMap[$mapKey]) {
|
222 |
+
$items = explode(",",$curRowData[$mapKey]);
|
223 |
+
$attrList=array();
|
224 |
+
foreach ($items as $item) {
|
225 |
+
$attrList[]= $this->_attrSetIdToName[$item];
|
226 |
+
}
|
227 |
+
$rowValues[$mapValue] = implode(",", $attrList);
|
228 |
+
} else {
|
229 |
+
$rowValues[$mapValue] = $curRowData[$mapKey];
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
// Output this row
|
234 |
+
$bSuccess = $file->writeRow($rowValues);
|
235 |
+
if (!$bSuccess) {
|
236 |
+
Mage::log('Failed to write to data feed file: ' . $filename, Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
237 |
+
$file->close();
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
|
241 |
+
// Collect last entity Id and generate new minEntityId param
|
242 |
+
$minEntityId = $curRow->getEntityId() + 1;
|
243 |
+
}
|
244 |
+
|
245 |
+
// Check if we're done this feed export
|
246 |
+
// Check a few different conditions to determine if we're done
|
247 |
+
if ($throttle == 0 || count($collection) == 0 || count($collection) < $throttle) {
|
248 |
+
$bDone = true;
|
249 |
+
}
|
250 |
+
|
251 |
+
// Close file
|
252 |
+
$bSuccess = $file->close();
|
253 |
+
if (!$bSuccess) {
|
254 |
+
Mage::log('Failed to close data feed file: ' . $filename, Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
255 |
+
return false;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
}
|
260 |
+
|
app/code/community/Mybuys/Connector/Model/Feed/Category.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Category extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
|
14 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
15 |
+
private $fieldMap = array(
|
16 |
+
'entity_id' => 'Category ID',
|
17 |
+
'name' => 'Name',
|
18 |
+
'parent_id' => 'Parent ID',
|
19 |
+
'is_root_category' => 'Is Root Category',
|
20 |
+
);
|
21 |
+
|
22 |
+
public function getFieldMap()
|
23 |
+
{
|
24 |
+
return $this->fieldMap;
|
25 |
+
}
|
26 |
+
|
27 |
+
// File name key
|
28 |
+
public function getFileNameKey()
|
29 |
+
{
|
30 |
+
return 'category';
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Build collection to do query
|
35 |
+
*
|
36 |
+
* @param int|string $websiteId Which website to query for collection
|
37 |
+
*/
|
38 |
+
public function getFeedCollection($websiteId)
|
39 |
+
{
|
40 |
+
// Lookup category path for root category
|
41 |
+
// Assume only 1 store per website
|
42 |
+
$rootCategoryId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getRootCategoryId();
|
43 |
+
$rootCategory = Mage::getModel('catalog/category')->load($rootCategoryId);
|
44 |
+
$rootCategoryPath = $rootCategory->getPath();
|
45 |
+
|
46 |
+
// Create collection
|
47 |
+
$collection = Mage::getModel('catalog/category')->getCollection();
|
48 |
+
|
49 |
+
// Get name and id
|
50 |
+
$collection
|
51 |
+
->addAttributeToSelect('name');
|
52 |
+
|
53 |
+
// Filter collection to only include active categories
|
54 |
+
$collection
|
55 |
+
->addIsActiveFilter();
|
56 |
+
|
57 |
+
// determine if we are at the top level of the catalog
|
58 |
+
$collection->getSelect()
|
59 |
+
->from(null, array("is_root_category" => "if(level = 1, 'Yes', 'No')"));
|
60 |
+
|
61 |
+
// Filter feed to only include products for given website
|
62 |
+
// Do this by filtering on 'path' attribute, based on root category path found above
|
63 |
+
// Include the root category itself in the feed
|
64 |
+
$collection
|
65 |
+
->addAttributeToFilter('path', array('like' => $rootCategoryPath . '%') );
|
66 |
+
|
67 |
+
// make sure we order by entity_id
|
68 |
+
$collection->getSelect()
|
69 |
+
->order('entity_id');
|
70 |
+
|
71 |
+
// Return collection
|
72 |
+
return $collection;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
77 |
+
*
|
78 |
+
* $collection Collection of data which will be spit out as feed
|
79 |
+
*/
|
80 |
+
protected function addIncrementalFilter($collection, $incrementalDate=null)
|
81 |
+
{
|
82 |
+
// No incremental date filtering of this feed
|
83 |
+
return $collection;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
88 |
+
*
|
89 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
90 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
91 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
92 |
+
*/
|
93 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
94 |
+
{
|
95 |
+
// Add mim entity id filter
|
96 |
+
if($minEntityId > 0) {
|
97 |
+
$collection->getSelect()
|
98 |
+
->where("e.entity_id >= {$minEntityId}");
|
99 |
+
}
|
100 |
+
|
101 |
+
// Add throttle param
|
102 |
+
if($throttle > 0) {
|
103 |
+
$collection->getSelect()
|
104 |
+
->limit($throttle);
|
105 |
+
}
|
106 |
+
|
107 |
+
// Return the modified collection
|
108 |
+
return $collection;
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Crosssell.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Crosssell extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
|
14 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
15 |
+
public function getFieldMap()
|
16 |
+
{
|
17 |
+
return array(
|
18 |
+
'product_id' => 'Product ID',
|
19 |
+
'linked_products' => 'Crosssell Product IDs',
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
// File name key
|
24 |
+
public function getFileNameKey()
|
25 |
+
{
|
26 |
+
return 'crosssell';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Build collection to do query
|
31 |
+
*
|
32 |
+
* @param int|string $websiteId Which website to query for collection
|
33 |
+
*/
|
34 |
+
public function getFeedCollection($websiteId)
|
35 |
+
{
|
36 |
+
// Create collection
|
37 |
+
$collection = Mage::getResourceModel('catalog/product_link_collection');
|
38 |
+
|
39 |
+
// Add entity_id field
|
40 |
+
$collection->getSelect()
|
41 |
+
->columns('product_id as entity_id');
|
42 |
+
|
43 |
+
// Filter feed to only include products for given website
|
44 |
+
$collection->getSelect()
|
45 |
+
->where($websiteId . ' in (select website_id from catalog_product_website cpw where cpw.product_id = main_table.product_id)')
|
46 |
+
;
|
47 |
+
|
48 |
+
// Filter based on types of links
|
49 |
+
// Cross Sells, Upsells & Related for now
|
50 |
+
$collection->getSelect()
|
51 |
+
->where('main_table.link_type_id IN (?)',
|
52 |
+
array(
|
53 |
+
Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED,
|
54 |
+
Mage_Catalog_Model_Product_Link::LINK_TYPE_UPSELL,
|
55 |
+
Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL,
|
56 |
+
));
|
57 |
+
|
58 |
+
// Do group by and concat to build list of related product ids
|
59 |
+
$collection->getSelect()
|
60 |
+
->group('main_table.product_id')
|
61 |
+
->columns(array(
|
62 |
+
'linked_products' =>
|
63 |
+
"group_concat(main_table.linked_product_id separator ', ')"))
|
64 |
+
;
|
65 |
+
|
66 |
+
// make sure we order by entity_id
|
67 |
+
$collection->getSelect()
|
68 |
+
->order('product_id');
|
69 |
+
|
70 |
+
// Return collection
|
71 |
+
return $collection;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
76 |
+
*
|
77 |
+
* $collection Collection of data which will be spit out as feed
|
78 |
+
*/
|
79 |
+
protected function addIncrementalFilter($collection, $incrementalDate=null)
|
80 |
+
{
|
81 |
+
// No incremental date filtering of this feed
|
82 |
+
return $collection;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
87 |
+
*
|
88 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
89 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
90 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
91 |
+
*/
|
92 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
93 |
+
{
|
94 |
+
// Add mim entity id filter
|
95 |
+
if($minEntityId > 0) {
|
96 |
+
$collection->getSelect()
|
97 |
+
->where("product_id >= {$minEntityId}");
|
98 |
+
}
|
99 |
+
|
100 |
+
// Add throttle param
|
101 |
+
if($throttle > 0) {
|
102 |
+
$collection->getSelect()
|
103 |
+
->limit($throttle);
|
104 |
+
}
|
105 |
+
|
106 |
+
// Return the modified collection
|
107 |
+
return $collection;
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Email/Optin.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Email_Optin extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
|
14 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
15 |
+
public function getFieldMap()
|
16 |
+
{
|
17 |
+
return array(
|
18 |
+
'subscriber_email' => 'Email Address',
|
19 |
+
'change_status_at' => 'Opt-In Date',
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
// File name key
|
24 |
+
public function getFileNameKey()
|
25 |
+
{
|
26 |
+
return 'email_optin';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Build collection to do query
|
31 |
+
*
|
32 |
+
* @param int|string $websiteId Which website to query for collection
|
33 |
+
*/
|
34 |
+
public function getCollection($websiteId)
|
35 |
+
{
|
36 |
+
// Create collection
|
37 |
+
$collection = Mage::getResourceModel('newsletter/subscriber_collection');
|
38 |
+
|
39 |
+
// Add entity_id field
|
40 |
+
$collection->getSelect()
|
41 |
+
->columns('main_table.subscriber_id as entity_id');
|
42 |
+
|
43 |
+
// Filter feed to only include products for given website
|
44 |
+
// Join to core_store table and grab website_id field
|
45 |
+
$collection->getSelect()
|
46 |
+
->joinLeft('core_store', 'main_table.store_id = core_store.store_id', 'core_store.website_id')
|
47 |
+
->where('core_store.website_id = ' . $websiteId)
|
48 |
+
;
|
49 |
+
|
50 |
+
// Filter feed by status
|
51 |
+
$collection
|
52 |
+
->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
|
53 |
+
|
54 |
+
// make sure we order by entity_id
|
55 |
+
$collection->getSelect()
|
56 |
+
->order('main_table.subscriber_id');
|
57 |
+
|
58 |
+
// Return collection
|
59 |
+
return $collection;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
64 |
+
*
|
65 |
+
* $collection Collection of data which will be spit out as feed
|
66 |
+
*/
|
67 |
+
protected function addIncrementalFilter($collection)
|
68 |
+
{
|
69 |
+
//
|
70 |
+
// Don't filter the incremental feed, because sometimes the change date field in Magento is not updated
|
71 |
+
//
|
72 |
+
// Filter transactions by date and only send yesterday's transactions
|
73 |
+
//$collection->getSelect()
|
74 |
+
// ->where("date(main_table.change_status_at) = '" . $incrementalDate . "'");
|
75 |
+
|
76 |
+
return $collection;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
81 |
+
*
|
82 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
83 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
84 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
85 |
+
*/
|
86 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
87 |
+
{
|
88 |
+
// Add mim entity id filter
|
89 |
+
if($minEntityId > 0) {
|
90 |
+
$collection->getSelect()
|
91 |
+
->where("main_table.subscriber_id >= {$minEntityId}");
|
92 |
+
}
|
93 |
+
|
94 |
+
// Add throttle param
|
95 |
+
if($throttle > 0) {
|
96 |
+
$collection->getSelect()
|
97 |
+
->limit($throttle);
|
98 |
+
}
|
99 |
+
|
100 |
+
// Return the modified collection
|
101 |
+
return $collection;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Email/Optout.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Email_Optout extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
|
14 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
15 |
+
public function getFieldMap()
|
16 |
+
{
|
17 |
+
return array(
|
18 |
+
'subscriber_email' => 'Email Address',
|
19 |
+
'change_status_at' => 'Opt-Out Date',
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
// File name key
|
24 |
+
public function getFileNameKey()
|
25 |
+
{
|
26 |
+
return 'email_optout';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Build collection to do query
|
31 |
+
*
|
32 |
+
* @param int|string $websiteId Which website to query for collection
|
33 |
+
*/
|
34 |
+
public function getCollection($websiteId)
|
35 |
+
{
|
36 |
+
// Create collection
|
37 |
+
$collection = Mage::getResourceModel('newsletter/subscriber_collection');
|
38 |
+
|
39 |
+
// Add entity_id field
|
40 |
+
$collection->getSelect()
|
41 |
+
->columns('main_table.subscriber_id as entity_id');
|
42 |
+
|
43 |
+
// Filter feed to only include products for given website
|
44 |
+
// Join to core_store table and grab website_id field
|
45 |
+
$collection->getSelect()
|
46 |
+
->joinLeft('core_store', 'main_table.store_id = core_store.store_id', 'core_store.website_id')
|
47 |
+
->where('core_store.website_id = ' . $websiteId)
|
48 |
+
;
|
49 |
+
|
50 |
+
// Filter feed by status
|
51 |
+
$collection
|
52 |
+
->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
|
53 |
+
|
54 |
+
// make sure we order by entity_id
|
55 |
+
$collection->getSelect()
|
56 |
+
->order('main_table.subscriber_id');
|
57 |
+
|
58 |
+
// Return collection
|
59 |
+
return $collection;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
64 |
+
*
|
65 |
+
* $collection Collection of data which will be spit out as feed
|
66 |
+
*/
|
67 |
+
protected function addIncrementalFilter($collection)
|
68 |
+
{
|
69 |
+
//
|
70 |
+
// Don't filter the incremental feed, because sometimes the change date field in Magento is not updated
|
71 |
+
//
|
72 |
+
// Filter transactions by date and only send yesterday's transactions
|
73 |
+
//$collection->getSelect()
|
74 |
+
// ->where("date(main_table.change_status_at) = '" . $incrementalDate . "'");
|
75 |
+
|
76 |
+
return $collection;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
81 |
+
*
|
82 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
83 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
84 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
85 |
+
*/
|
86 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
87 |
+
{
|
88 |
+
// Add mim entity id filter
|
89 |
+
if($minEntityId > 0) {
|
90 |
+
$collection->getSelect()
|
91 |
+
->where("main_table.subscriber_id >= {$minEntityId}");
|
92 |
+
}
|
93 |
+
|
94 |
+
// Add throttle param
|
95 |
+
if($throttle > 0) {
|
96 |
+
$collection->getSelect()
|
97 |
+
->limit($throttle);
|
98 |
+
}
|
99 |
+
|
100 |
+
// Return the modified collection
|
101 |
+
return $collection;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Product.php
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Product extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
|
14 |
+
// Field mapping - Magento product fields to MyBuys Product Feed
|
15 |
+
|
16 |
+
private $fieldMap = array(
|
17 |
+
|
18 |
+
'entity_id' => 'Product ID',
|
19 |
+
'name' => 'Product Name',
|
20 |
+
'category_ids' => 'Category IDs',
|
21 |
+
'product_url' => 'URL',
|
22 |
+
'image_url' => 'Large Image URL',
|
23 |
+
'calc_base_price' => 'Base Price',
|
24 |
+
'minimal_price' => 'Current Price',
|
25 |
+
'is_on_sale' => 'On Sale',
|
26 |
+
'adj_qty' => 'Inventory Quantity',
|
27 |
+
'is_in_stock' => 'Inventory Status',
|
28 |
+
'cur_visibility' => 'Visibility',
|
29 |
+
'type_id' => 'Product Type',
|
30 |
+
/*
|
31 |
+
'price' => 'price',
|
32 |
+
'final_price' => 'final_price',
|
33 |
+
'minimal_price' => 'minimal_price',
|
34 |
+
'min_price' => 'min_price',
|
35 |
+
'max_price' => 'max_price',
|
36 |
+
'tier_price' => 'tier_price',
|
37 |
+
'avg_price'=>'avg_price',
|
38 |
+
*/
|
39 |
+
);
|
40 |
+
|
41 |
+
public function getFieldMap()
|
42 |
+
{
|
43 |
+
return $this->fieldMap;
|
44 |
+
}
|
45 |
+
|
46 |
+
// File name key
|
47 |
+
public function getFileNameKey()
|
48 |
+
{
|
49 |
+
return 'product';
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Build collection to do query
|
54 |
+
*
|
55 |
+
* @param int|string $websiteId Which website to query for collection
|
56 |
+
*/
|
57 |
+
public function getFeedCollection($websiteId)
|
58 |
+
{
|
59 |
+
// Create collection
|
60 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
61 |
+
|
62 |
+
// Add product name to feed
|
63 |
+
$collection
|
64 |
+
->addAttributeToSelect('name');
|
65 |
+
|
66 |
+
// Filter feed to only include products for given website
|
67 |
+
$collection
|
68 |
+
->addWebsiteFilter($websiteId);
|
69 |
+
|
70 |
+
// Filter on enabled
|
71 |
+
$collection->
|
72 |
+
addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
73 |
+
|
74 |
+
// Filter on visible
|
75 |
+
$collection
|
76 |
+
->addAttributeToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
|
77 |
+
|
78 |
+
//add price data
|
79 |
+
$collection
|
80 |
+
// ->addMinimalPrice();
|
81 |
+
->addPriceData(null, $websiteId); // have to use this version so you can set the website id
|
82 |
+
|
83 |
+
// Add stock level fields
|
84 |
+
$collection->joinTable(
|
85 |
+
array ('at_qty'=>'cataloginventory/stock_item'),
|
86 |
+
'product_id=entity_id',
|
87 |
+
array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'),
|
88 |
+
'{{table}}.stock_id=1',
|
89 |
+
'left');
|
90 |
+
|
91 |
+
// Add categories to query
|
92 |
+
$prodCatTable = $collection->getTable('catalog/category_product');
|
93 |
+
$collection->getSelect()
|
94 |
+
->columns(array(
|
95 |
+
'category_ids' =>
|
96 |
+
' (select ' .
|
97 |
+
" group_concat(distinct pc.category_id separator ' | ') " .
|
98 |
+
' from ' . $prodCatTable . ' pc ' .
|
99 |
+
' where ' .
|
100 |
+
' pc.product_id = e.entity_id) '
|
101 |
+
,));
|
102 |
+
|
103 |
+
|
104 |
+
// Add full product page URL
|
105 |
+
// Lookup un-secure store base URL
|
106 |
+
$baseUrl = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getBaseUrl();
|
107 |
+
$coreRewriteTable = $collection->getTable('core/url_rewrite');
|
108 |
+
$collection->getSelect()
|
109 |
+
->columns(array(
|
110 |
+
'product_url' =>
|
111 |
+
" (select " .
|
112 |
+
" concat('{$baseUrl}', url.request_path) " .
|
113 |
+
" from " .
|
114 |
+
" {$coreRewriteTable} url " .
|
115 |
+
" where " .
|
116 |
+
" id_path = concat('product/', e.entity_id) " .
|
117 |
+
" limit 1) "
|
118 |
+
,));
|
119 |
+
|
120 |
+
// Add product image URL
|
121 |
+
// TODO - check for other images (small and thumb) just in case the default one is not defined
|
122 |
+
$imageBaseURL = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "catalog/product";
|
123 |
+
$collection
|
124 |
+
->addExpressionAttributeToSelect(
|
125 |
+
'image_url',
|
126 |
+
"if({{image}} <> 'no_selection', " .
|
127 |
+
" concat('{$imageBaseURL}', {{image}}), " .
|
128 |
+
" '')",
|
129 |
+
'image'
|
130 |
+
);
|
131 |
+
|
132 |
+
|
133 |
+
$collection->getSelect()->columns('if(price_index.final_price < price_index.price, 1, 0) as is_on_sale ');
|
134 |
+
|
135 |
+
// Add product attributes which indicate if product is visible or not
|
136 |
+
// Status, visibility and is_in_stock must all be set for product to show up
|
137 |
+
$collection
|
138 |
+
->addExpressionAttributeToSelect('cur_status', "{{status}}", 'status');
|
139 |
+
|
140 |
+
//base price
|
141 |
+
// for grouped and bundled products - return the average price
|
142 |
+
// for giftcards - return the minimum price
|
143 |
+
// for other products - return the price
|
144 |
+
$collection
|
145 |
+
->addExpressionAttributeToSelect(
|
146 |
+
'calc_base_price',
|
147 |
+
"IF({{type_id}} NOT IN ('giftcard','grouped','bundle'),
|
148 |
+
price_index.price,
|
149 |
+
ROUND(
|
150 |
+
IF({{type_id}} IN ('bundle','grouped'),
|
151 |
+
-- get average price
|
152 |
+
(IF(price_index.tier_price IS NOT NULL,
|
153 |
+
LEAST(price_index.min_price, price_index.tier_price),
|
154 |
+
price_index.min_price)
|
155 |
+
+ price_index.max_price / 2),
|
156 |
+
-- else get minimum price
|
157 |
+
(IF(price_index.tier_price IS NOT NULL,
|
158 |
+
LEAST(price_index.min_price, price_index.tier_price),
|
159 |
+
price_index.min_price))),
|
160 |
+
2))",
|
161 |
+
'type_id'
|
162 |
+
);
|
163 |
+
|
164 |
+
$collection
|
165 |
+
->addExpressionAttributeToSelect(
|
166 |
+
'adj_qty',
|
167 |
+
"if({{type_id}} = 'simple', " .
|
168 |
+
"at_qty.qty, " .
|
169 |
+
"if (at_qty.is_in_stock=1, ".
|
170 |
+
"if (at_qty.qty>0, ".
|
171 |
+
"at_qty.qty, at_qty.is_in_stock),".
|
172 |
+
"at_qty.is_in_stock))",
|
173 |
+
'type_id'
|
174 |
+
);
|
175 |
+
|
176 |
+
// Add any custom attributes to feed
|
177 |
+
$customAttribs = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/product_attributes');
|
178 |
+
$collection = $this->addCustomAttributes($collection, $customAttribs, $this->fieldMap);
|
179 |
+
|
180 |
+
// Make sure we order by entity_id
|
181 |
+
// $collection->getSelect()
|
182 |
+
// ->order('e.entity_id');
|
183 |
+
|
184 |
+
// Return collection
|
185 |
+
return $collection;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
190 |
+
*
|
191 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
192 |
+
*/
|
193 |
+
protected function addIncrementalFilter($collection, $incrementalDate = NULL)
|
194 |
+
{
|
195 |
+
Mage::log('Adding incremental filters to product feed', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
196 |
+
// daily feeds do not include out of stock items Filter on in_stock
|
197 |
+
$collection->
|
198 |
+
addAttributeToFilter('is_in_stock', 1);
|
199 |
+
|
200 |
+
// No incremental date filtering of this feed
|
201 |
+
return $collection;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
206 |
+
*
|
207 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
208 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
209 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
210 |
+
*/
|
211 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
212 |
+
{
|
213 |
+
// Add mim entity id filter
|
214 |
+
if ($minEntityId > 0) {
|
215 |
+
$collection->getSelect()
|
216 |
+
->where("e.entity_id >= {$minEntityId}");
|
217 |
+
}
|
218 |
+
|
219 |
+
// Add throttle param
|
220 |
+
if ($throttle > 0) {
|
221 |
+
$collection->getSelect()
|
222 |
+
->limit($throttle);
|
223 |
+
}
|
224 |
+
|
225 |
+
// Return the modified collection
|
226 |
+
return $collection;
|
227 |
+
}
|
228 |
+
|
229 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Rating.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Rating extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
|
14 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
15 |
+
public function getFieldMap()
|
16 |
+
{
|
17 |
+
return array(
|
18 |
+
'entity_id' => 'Product ID',
|
19 |
+
'review_count' => 'Review Count',
|
20 |
+
'avg_rating' => 'Average Overall Rating',
|
21 |
+
'last_review_date' => 'Last Review Date',
|
22 |
+
);
|
23 |
+
}
|
24 |
+
|
25 |
+
// File name key
|
26 |
+
public function getFileNameKey()
|
27 |
+
{
|
28 |
+
return 'rating';
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Build collection to do query
|
33 |
+
*
|
34 |
+
* @param int|string $websiteId Which website to query for collection
|
35 |
+
*/
|
36 |
+
public function getFeedCollection($websiteId)
|
37 |
+
{
|
38 |
+
// Create collection
|
39 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
40 |
+
|
41 |
+
// Filter feed to only include products for given website
|
42 |
+
$collection
|
43 |
+
->addWebsiteFilter($websiteId);
|
44 |
+
|
45 |
+
// Don't hard code table names
|
46 |
+
$coreStoreTable = $collection->getTable('core/store');
|
47 |
+
$reviewTable = $collection->getTable('review/review');
|
48 |
+
$reviewDetailTable = $collection->getTable('review/review_detail');
|
49 |
+
$reviewEntityTable = $collection->getTable('review/review_entity');
|
50 |
+
$ratingTable = $collection->getTable('rating/rating');
|
51 |
+
$rovaTable = $collection->getTable('rating/rating_vote_aggregated');
|
52 |
+
$ratingEntityTable = $collection->getTable('rating/rating_entity');
|
53 |
+
|
54 |
+
// Add # of reviews total, avg rating & last reivew date to the query
|
55 |
+
$collection->getSelect()
|
56 |
+
->columns(array(
|
57 |
+
'review_count' =>
|
58 |
+
' (select ' .
|
59 |
+
' count(*) ' .
|
60 |
+
' from ' . $reviewTable . ' r ' .
|
61 |
+
' where ' .
|
62 |
+
' (select store_id from ' . $reviewDetailTable . ' rd where rd.review_id=r.review_id) in (select store_id from ' . $coreStoreTable . ' where website_id = ' . $websiteId . ') and ' .
|
63 |
+
' r.entity_pk_value = e.entity_id and ' .
|
64 |
+
' r.entity_id in ' .
|
65 |
+
" (select entity_id from " . $reviewEntityTable . " where entity_code = '" . Mage_Review_Model_Review::ENTITY_PRODUCT_CODE . "'))",
|
66 |
+
'avg_rating' =>
|
67 |
+
' (select ' .
|
68 |
+
' (sum(vote_value_sum) / sum(vote_count))' .
|
69 |
+
' from ' .
|
70 |
+
' ' . $rovaTable . ' rova, ' . $ratingTable . ' ra ' .
|
71 |
+
' where ' .
|
72 |
+
' rova.store_id in (select store_id from ' . $coreStoreTable . ' cs2 where cs2.website_id = ' . $websiteId . ') and ' .
|
73 |
+
' ra.entity_id in ' .
|
74 |
+
" (select entity_id from " . $ratingEntityTable . " where entity_code = '" . Mage_Rating_Model_Rating::ENTITY_PRODUCT_CODE . "') and " .
|
75 |
+
' rova.entity_pk_value = e.entity_id and ' .
|
76 |
+
' rova.rating_id = ra.rating_id ' .
|
77 |
+
' group by rova.entity_pk_value) ',
|
78 |
+
'last_review_date' =>
|
79 |
+
' (select ' .
|
80 |
+
' date(max(r2.created_at))' .
|
81 |
+
' from ' . $reviewTable . ' r2 ' .
|
82 |
+
' where ' .
|
83 |
+
' (select store_id from ' . $reviewDetailTable . ' rd where rd.review_id=r2.review_id) in (select store_id from ' . $coreStoreTable . ' where website_id = ' . $websiteId . ') and ' .
|
84 |
+
' r2.entity_pk_value = e.entity_id and ' .
|
85 |
+
' r2.entity_id in ' .
|
86 |
+
" (select entity_id from " . $reviewEntityTable . " where entity_code = '" . Mage_Review_Model_Review::ENTITY_PRODUCT_CODE . "'))",
|
87 |
+
));
|
88 |
+
|
89 |
+
// make sure we order by entity_id
|
90 |
+
$collection->getSelect()
|
91 |
+
->order('e.entity_id');
|
92 |
+
|
93 |
+
// Return collection
|
94 |
+
return $collection;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
99 |
+
*
|
100 |
+
* $collection Collection of data which will be spit out as feed
|
101 |
+
*/
|
102 |
+
protected function addIncrementalFilter($collection, $incrementalDate=null)
|
103 |
+
{
|
104 |
+
// Don't do any date filtering on this data, its not easy to detect which parts have changed
|
105 |
+
return $collection;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
110 |
+
*
|
111 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
112 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
113 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
114 |
+
*/
|
115 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
116 |
+
{
|
117 |
+
// Add mim entity id filter
|
118 |
+
if($minEntityId > 0) {
|
119 |
+
$collection->getSelect()
|
120 |
+
->where("e.entity_id >= {$minEntityId}");
|
121 |
+
}
|
122 |
+
|
123 |
+
// Add throttle param
|
124 |
+
if($throttle > 0) {
|
125 |
+
$collection->getSelect()
|
126 |
+
->limit($throttle);
|
127 |
+
}
|
128 |
+
|
129 |
+
// Return the modified collection
|
130 |
+
return $collection;
|
131 |
+
}
|
132 |
+
|
133 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Sku.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Sku extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
private $fieldMap = array(
|
14 |
+
'sku' => 'SKU ID',
|
15 |
+
'product_id' => 'Product ID',
|
16 |
+
'stock_status' => 'Inventory Status',
|
17 |
+
'calc_base_price' => 'Base Price',
|
18 |
+
'minimal_price' => 'Current Price',
|
19 |
+
'adj_qty' => 'Inventory Quantity',
|
20 |
+
//'qty' => 'Real Stock Qty',
|
21 |
+
'type_id' => 'Magento Product Type',
|
22 |
+
//'base_price'=>'base_price',
|
23 |
+
//'calc_base_price'=>'calc_base_price'
|
24 |
+
//'attributes' => 'Generic Attributes',
|
25 |
+
);
|
26 |
+
|
27 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
28 |
+
public function getFieldMap()
|
29 |
+
{
|
30 |
+
return $this->fieldMap;
|
31 |
+
}
|
32 |
+
|
33 |
+
// File name key
|
34 |
+
public function getFileNameKey()
|
35 |
+
{
|
36 |
+
return 'sku';
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Build collection to do query
|
41 |
+
*
|
42 |
+
* @param int|string $websiteId Which website to query for collection
|
43 |
+
*/
|
44 |
+
public function getFeedCollection($websiteId)
|
45 |
+
{
|
46 |
+
// Create collection
|
47 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
48 |
+
|
49 |
+
// Filter feed to only include products for given website
|
50 |
+
$collection
|
51 |
+
->addWebsiteFilter($websiteId);
|
52 |
+
|
53 |
+
// Filter on enabled
|
54 |
+
$collection->
|
55 |
+
addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
56 |
+
|
57 |
+
|
58 |
+
// Add product name to feed
|
59 |
+
$collection
|
60 |
+
->addAttributeToSelect('name');
|
61 |
+
|
62 |
+
// Add product sku to feed
|
63 |
+
$collection
|
64 |
+
->addAttributeToSelect('sku');
|
65 |
+
|
66 |
+
//add price data
|
67 |
+
$collection
|
68 |
+
->addPriceData(null, $websiteId); // have to use this version so you can set the website id
|
69 |
+
|
70 |
+
// Add stock level fields
|
71 |
+
$collection->joinTable(
|
72 |
+
array('at_qty'=>'cataloginventory/stock_item'),
|
73 |
+
'product_id=entity_id',
|
74 |
+
array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'),
|
75 |
+
'{{table}}.stock_id=1',
|
76 |
+
'left');
|
77 |
+
|
78 |
+
/*
|
79 |
+
//get base price based on product type
|
80 |
+
$collection
|
81 |
+
->addExpressionAttributeToSelect(
|
82 |
+
'base_price',
|
83 |
+
"if({{type_id}} = 'bundle' OR {{type_id}} = 'giftcard' OR {{type_id}} = 'grouped', " .
|
84 |
+
"price_index.min_price, " .
|
85 |
+
"price_index.price)",
|
86 |
+
'type_id'
|
87 |
+
);
|
88 |
+
*/
|
89 |
+
//base price
|
90 |
+
// for grouped and bundled products - return the average price
|
91 |
+
// for giftcards - return the minimum price
|
92 |
+
// for other products - return the price
|
93 |
+
$collection
|
94 |
+
->addExpressionAttributeToSelect(
|
95 |
+
'calc_base_price',
|
96 |
+
"IF({{type_id}} NOT IN ('giftcard','grouped','bundle'),
|
97 |
+
price_index.price,
|
98 |
+
ROUND(
|
99 |
+
IF({{type_id}} IN ('bundle','grouped'),
|
100 |
+
-- get average price
|
101 |
+
(IF(price_index.tier_price IS NOT NULL,
|
102 |
+
LEAST(price_index.min_price, price_index.tier_price),
|
103 |
+
price_index.min_price)
|
104 |
+
+ price_index.max_price / 2),
|
105 |
+
-- else get minimum price
|
106 |
+
(IF(price_index.tier_price IS NOT NULL,
|
107 |
+
LEAST(price_index.min_price, price_index.tier_price),
|
108 |
+
price_index.min_price))),
|
109 |
+
2))",
|
110 |
+
'type_id'
|
111 |
+
);
|
112 |
+
|
113 |
+
|
114 |
+
// Add product attributes which indicate if product is visible or not
|
115 |
+
// Status, visibility and is_in_stock must all be set for product to show up
|
116 |
+
$collection
|
117 |
+
->addExpressionAttributeToSelect('cur_status', "{{status}}", 'status')
|
118 |
+
->addExpressionAttributeToSelect('cur_visibility', "{{visibility}}", 'visibility');
|
119 |
+
|
120 |
+
|
121 |
+
$joinCond = 'super_link.product_id = `e`.`entity_id`';
|
122 |
+
$colls = 'super_link.parent_id';
|
123 |
+
$collection->getSelect()
|
124 |
+
->joinLeft(
|
125 |
+
array('super_link' => $collection->getTable('catalog/product_super_link')),
|
126 |
+
$joinCond,
|
127 |
+
$colls
|
128 |
+
);
|
129 |
+
|
130 |
+
$collection
|
131 |
+
->addExpressionAttributeToSelect(
|
132 |
+
'product_id',
|
133 |
+
"if(super_link.parent_id IS NULL, " .
|
134 |
+
"{{entity_id}}, " .
|
135 |
+
"super_link.parent_id)",
|
136 |
+
"entity_id"
|
137 |
+
);
|
138 |
+
|
139 |
+
|
140 |
+
// Add stock info for parent
|
141 |
+
$collection->getSelect()->joinLeft(
|
142 |
+
array("pstock"=>$collection->getTable('cataloginventory/stock_item')),
|
143 |
+
join(' AND ',
|
144 |
+
array('super_link.parent_id=pstock.product_id',
|
145 |
+
'pstock.stock_id=1')),
|
146 |
+
array('qty','is_in_stock'));
|
147 |
+
|
148 |
+
|
149 |
+
$collection
|
150 |
+
->addExpressionAttributeToSelect(
|
151 |
+
'adj_qty',
|
152 |
+
"if({{type_id}} = 'simple', " .
|
153 |
+
"at_qty.qty, " .
|
154 |
+
"if (at_qty.is_in_stock=1, ".
|
155 |
+
"if (at_qty.qty>0, ".
|
156 |
+
"at_qty.qty, at_qty.is_in_stock),".
|
157 |
+
"at_qty.is_in_stock))",
|
158 |
+
'type_id'
|
159 |
+
);
|
160 |
+
|
161 |
+
$collection
|
162 |
+
->addExpressionAttributeToSelect(
|
163 |
+
'stock_status',
|
164 |
+
"if(super_link.parent_id IS NULL, " .
|
165 |
+
"at_qty.is_in_stock, " .
|
166 |
+
"pstock.is_in_stock)",
|
167 |
+
"entity_id"
|
168 |
+
);
|
169 |
+
|
170 |
+
//TODO - get status for parent somehow
|
171 |
+
//LEFT JOIN `catalog_product_entity_int` AS `at_status_parent_default` ON (`at_status_parent_default`.`entity_id` = super_link.parent_id) AND (`at_status_parent_default`.`attribute_id` = '273') AND `at_status_parent_default`.`store_id` = 0
|
172 |
+
|
173 |
+
// Add price
|
174 |
+
$collection
|
175 |
+
->addExpressionAttributeToSelect('cur_price', "{{price}}", 'price');
|
176 |
+
/*
|
177 |
+
// Add any custom attributes to feed
|
178 |
+
$customAttribs = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/product_attributes');
|
179 |
+
$collection = $this->addCustomAttributes($collection, $customAttribs, $this->fieldMap);
|
180 |
+
*/
|
181 |
+
// Make sure we order by entity_id
|
182 |
+
$collection->getSelect()
|
183 |
+
->order('e.entity_id');
|
184 |
+
|
185 |
+
$collection->groupByAttribute('entity_id');
|
186 |
+
// Return collection
|
187 |
+
return $collection;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
192 |
+
*
|
193 |
+
* $collection Collection of data which will be spit out as feed
|
194 |
+
*/
|
195 |
+
protected function addIncrementalFilter($collection, $incrementalDate=null)
|
196 |
+
{
|
197 |
+
// No incremental date filtering of this feed
|
198 |
+
return $collection;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
203 |
+
*
|
204 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
205 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
206 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
207 |
+
*/
|
208 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
209 |
+
{
|
210 |
+
if ($minEntityId > 0) {
|
211 |
+
$collection->getSelect()
|
212 |
+
->where("e.entity_id >= {$minEntityId}");
|
213 |
+
}
|
214 |
+
|
215 |
+
// Add throttle param
|
216 |
+
if ($throttle > 0) {
|
217 |
+
$collection->getSelect()
|
218 |
+
->limit($throttle);
|
219 |
+
}
|
220 |
+
|
221 |
+
// Return the modified collection
|
222 |
+
return $collection;
|
223 |
+
}
|
224 |
+
|
225 |
+
}
|
app/code/community/Mybuys/Connector/Model/Feed/Transaction.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Feed_Transaction extends Mybuys_Connector_Model_Feed_Base
|
12 |
+
{
|
13 |
+
// Field mapping - Magento attributes to MyBuys Feed Fields
|
14 |
+
|
15 |
+
private $fieldMap = array(
|
16 |
+
'customer_email' => 'Email Address',
|
17 |
+
'created_at' => 'Transaction Date',
|
18 |
+
'order_id' => 'Transaction ID',
|
19 |
+
'base_subtotal' => 'Transaction Total',
|
20 |
+
'calc_product_id' => 'Item ID',
|
21 |
+
'qty_ordered' => 'Item Quantity',
|
22 |
+
'base_original_price' => 'Item Price',
|
23 |
+
'base_row_total' => 'Item Subtotal',
|
24 |
+
'base_original_price' => 'Item Original Price',
|
25 |
+
'increment_id' => 'Order Id',
|
26 |
+
);
|
27 |
+
|
28 |
+
public function getFieldMap()
|
29 |
+
{
|
30 |
+
return $this->fieldMap;
|
31 |
+
}
|
32 |
+
|
33 |
+
// Feed file name key
|
34 |
+
public function getFileNameKey()
|
35 |
+
{
|
36 |
+
return 'transaction';
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Build collection to do query
|
41 |
+
*
|
42 |
+
* @param int|string $websiteId Which website to query for collection
|
43 |
+
*/
|
44 |
+
public function getFeedCollection($websiteId)
|
45 |
+
{
|
46 |
+
// Create collection (of sales order items
|
47 |
+
$collection = Mage::getResourceModel('sales/order_item_collection');
|
48 |
+
|
49 |
+
$collection // tried to use an array here, but it kept giving an error
|
50 |
+
->addAttributeToSelect('order_id')
|
51 |
+
->addAttributeToSelect('created_at')
|
52 |
+
->addAttributeToSelect('product_id')
|
53 |
+
->addAttributeToSelect('qty_ordered')
|
54 |
+
->addAttributeToSelect('base_price')
|
55 |
+
->addAttributeToSelect('base_row_total')
|
56 |
+
->addAttributeToSelect('base_original_price')
|
57 |
+
->addAttributeToSelect('parent_item_id');
|
58 |
+
|
59 |
+
//filter out child products
|
60 |
+
$collection->addAttributeToFilter('parent_item_id', array('null' => true));
|
61 |
+
|
62 |
+
// Filter collection for current website
|
63 |
+
// need to join to core_store table and grab website_id field
|
64 |
+
$collection->getSelect()
|
65 |
+
->joinLeft('core_store', 'main_table.store_id = core_store.store_id', 'core_store.website_id')
|
66 |
+
->where('core_store.website_id = ' . $websiteId);
|
67 |
+
|
68 |
+
// Join order item up with main order record for subtotals and emails
|
69 |
+
$collection->getSelect()
|
70 |
+
->joinLeft('sales_flat_order', 'main_table.order_id = sales_flat_order.entity_id', array('base_subtotal', 'customer_email', 'increment_id'));
|
71 |
+
|
72 |
+
//get the visibility data from the product's attribute data
|
73 |
+
//thanks Vanai
|
74 |
+
$attributeCode = 'visibility';
|
75 |
+
$alias = $attributeCode . '_table';
|
76 |
+
$attribute = Mage::getSingleton('eav/config')
|
77 |
+
->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode);
|
78 |
+
|
79 |
+
$collection->getSelect()
|
80 |
+
->join(
|
81 |
+
array($alias => $attribute->getBackendTable()),
|
82 |
+
"main_table.product_id = $alias.entity_id AND $alias.attribute_id={$attribute->getId()}",
|
83 |
+
array($attributeCode => 'value')
|
84 |
+
);
|
85 |
+
|
86 |
+
|
87 |
+
//addExpressionAttributeToSelect does not work for the order_item_collection model
|
88 |
+
//use the send columns function to add the if directly
|
89 |
+
$collection
|
90 |
+
->getSelect()->columns(array('calc_product_id' =>
|
91 |
+
'if((product_type="grouped" and `visibility_table`.`value` = ' . Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE . '),
|
92 |
+
if(LOCATE(\'super_product_config\', product_options)>0,
|
93 |
+
CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(product_options,\'super_product_config\',-1), \'product_id\',-1), \'";\',2),\':"\',-1) AS UNSIGNED),
|
94 |
+
0),
|
95 |
+
`main_table`.`product_id`)'));
|
96 |
+
|
97 |
+
// Add alias for entity_id column to use with throttle function
|
98 |
+
$collection->getSelect()
|
99 |
+
->columns(array('entity_id' => 'main_table.item_id'));
|
100 |
+
|
101 |
+
// order by order item id
|
102 |
+
$collection->getSelect()
|
103 |
+
->order('main_table.item_id');
|
104 |
+
|
105 |
+
// Return collection
|
106 |
+
return $collection;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Add filter to collection to make it only include records necessary for automatic daily feed (instead of one-time baseline feed).
|
111 |
+
*
|
112 |
+
* $collection Collection of data which will be spit out as feed
|
113 |
+
*/
|
114 |
+
protected function addIncrementalFilter($collection, $incrementalDate)
|
115 |
+
{
|
116 |
+
|
117 |
+
// convert given date into GMT (Magento) time
|
118 |
+
$dateStart = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(strtotime($incrementalDate . "00:00:00")));
|
119 |
+
$dateEnd = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(strtotime($incrementalDate . "23:59:59")));
|
120 |
+
|
121 |
+
$collection->getSelect()
|
122 |
+
->where("date(main_table.created_at) between '" . $dateStart . "' AND '" . $dateEnd . "'");
|
123 |
+
|
124 |
+
return $collection;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Add throttle parameter to collection to limit output to X number of rows
|
129 |
+
*
|
130 |
+
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
131 |
+
* @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
|
132 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
133 |
+
*/
|
134 |
+
protected function addThrottleFilter($collection, $throttle, $minEntityId)
|
135 |
+
{
|
136 |
+
// Add mim entity id filter
|
137 |
+
if ($minEntityId > 0) {
|
138 |
+
$collection->getSelect()
|
139 |
+
->where("main_table.item_id >= {$minEntityId}");
|
140 |
+
}
|
141 |
+
|
142 |
+
// Add throttle param
|
143 |
+
if ($throttle > 0) {
|
144 |
+
$collection->getSelect()
|
145 |
+
->limit($throttle);
|
146 |
+
}
|
147 |
+
|
148 |
+
// Return the modified collection
|
149 |
+
return $collection;
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
app/code/community/Mybuys/Connector/Model/Generatefeeds.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Generatefeeds
|
12 |
+
{
|
13 |
+
const MBUYS_FEED_PATH = 'mybuys/feeds';
|
14 |
+
|
15 |
+
protected static $feedTypes = array(
|
16 |
+
'category',
|
17 |
+
'product',
|
18 |
+
'sku',
|
19 |
+
'transaction',
|
20 |
+
'crosssell',
|
21 |
+
'rating',
|
22 |
+
'email_optin',
|
23 |
+
'email_optout',
|
24 |
+
);
|
25 |
+
|
26 |
+
protected function _construct(){
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Return a list of possible feed types
|
32 |
+
*
|
33 |
+
* @returns array Array of all known feeds types
|
34 |
+
*/
|
35 |
+
public static function getFeedTypes()
|
36 |
+
{
|
37 |
+
return self::$feedTypes;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Generate data feeds for this specific website
|
42 |
+
*
|
43 |
+
* @param in $websiteId Id of the website for which to generate data feeds
|
44 |
+
* @param bool $bBaselineFile Should this file be a baseline file or an automated daily file
|
45 |
+
* @param string $feedType Type of feed to generate, null = generate all feeds
|
46 |
+
* @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
|
47 |
+
*/
|
48 |
+
|
49 |
+
public function generateForWebsite($websiteId, $bBaselineFile, $feedType, &$minEntityId, &$bDone)
|
50 |
+
{
|
51 |
+
// Log mem usage
|
52 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
53 |
+
|
54 |
+
// Check data feeds enabled
|
55 |
+
// Check feed of this type if config is enabled
|
56 |
+
if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') != 'enabled' ||
|
57 |
+
Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $feedType) != 'enabled')
|
58 |
+
{
|
59 |
+
Mage::throwException('Data feeds or feedtype ' . $feedType . ' not enabled for website: ' . $websiteId);
|
60 |
+
}
|
61 |
+
|
62 |
+
// Lookup up throttle param
|
63 |
+
$throttle = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/advanced/throttle');
|
64 |
+
|
65 |
+
// Build path of where to store feeds
|
66 |
+
$feedExportPath = Mage::getConfig()->getVarDir() . DS . Mybuys_Connector_Model_Generatefeeds::MBUYS_FEED_PATH;
|
67 |
+
// Check and create folder
|
68 |
+
$oIo = new Varien_Io_File();
|
69 |
+
$oIo->checkAndCreateFolder($feedExportPath);
|
70 |
+
|
71 |
+
// Create feed
|
72 |
+
// Generate just the one specific type of feed
|
73 |
+
$modelFeed = Mage::getModel('mybuys/feed_' . $feedType);
|
74 |
+
$modelFeed->generate($websiteId, $feedExportPath, $bBaselineFile, $throttle, $minEntityId, $bDone);
|
75 |
+
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
app/code/community/Mybuys/Connector/Model/Job.php
ADDED
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Job extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Job Types
|
15 |
+
*/
|
16 |
+
const TYPE_GENERATE_BASELINE = 1;
|
17 |
+
const TYPE_GENERATE_DAILY = 2;
|
18 |
+
const TYPE_TRANSFER = 3;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Feed Types
|
22 |
+
*/
|
23 |
+
const FEED_TYPE_CATEGORY = 'category';
|
24 |
+
const FEED_TYPE_PRODUCT = 'product';
|
25 |
+
const FEED_TYPE_SKU = 'sku';
|
26 |
+
const FEED_TYPE_TRANSACTION = 'transaction';
|
27 |
+
const FEED_TYPE_CROSSSELL = 'crosssell';
|
28 |
+
const FEED_TYPE_RATING = 'rating';
|
29 |
+
const FEED_TYPE_EMAIL_OPTIN = 'email_optin';
|
30 |
+
const FEED_TYPE_EMAIL_OPTOUT = 'email_optout';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Statuses
|
34 |
+
*/
|
35 |
+
const STATUS_SCHEDULED = 1;
|
36 |
+
const STATUS_RUNNING = 2;
|
37 |
+
const STATUS_COMPLETED = 3;
|
38 |
+
const STATUS_ERROR = 4;
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor
|
43 |
+
*/
|
44 |
+
public function _construct()
|
45 |
+
{
|
46 |
+
parent::_construct();
|
47 |
+
$this->_init('mybuys/job');
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Pull the next job to run from the queue and set status to running
|
52 |
+
*
|
53 |
+
* @returns Mybuys_Connector_Model_Job The next job object
|
54 |
+
*/
|
55 |
+
public static function getNextJobFromQueue()
|
56 |
+
{
|
57 |
+
// Log
|
58 |
+
Mage::log('Getting next job from the queue.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
59 |
+
|
60 |
+
// Create collection
|
61 |
+
$collection = Mage::getResourceModel('mybuys/job_collection');
|
62 |
+
|
63 |
+
// Retrieve our table name
|
64 |
+
$table = $collection->getTable('mybuys/job');
|
65 |
+
|
66 |
+
// DB Query to grab next job
|
67 |
+
$collection->getSelect()
|
68 |
+
->where('status = ' . Mybuys_Connector_Model_Job::STATUS_SCHEDULED . ' or status = ' . Mybuys_Connector_Model_Job::STATUS_RUNNING)
|
69 |
+
->where(Mybuys_Connector_Model_Job::STATUS_SCHEDULED . " not in (select status from {$table} mbj2 where mbj2.job_id = main_table.dependent_on_job_id) ")
|
70 |
+
->order('job_id')
|
71 |
+
->limit(1);
|
72 |
+
|
73 |
+
// Get next job and mark it as running
|
74 |
+
foreach ($collection as $job) {
|
75 |
+
// Log
|
76 |
+
Mage::log('Found job id: ' . $job->getJobId(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
77 |
+
// Set status and return job
|
78 |
+
$job->setStatus(Mybuys_Connector_Model_Job::STATUS_RUNNING);
|
79 |
+
$job->setStartedAt(Mage::getSingleton('core/date')->gmtDate());
|
80 |
+
$job->save();
|
81 |
+
return $job;
|
82 |
+
}
|
83 |
+
|
84 |
+
// Log
|
85 |
+
Mage::log('No jobs found.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
86 |
+
// Otherwise return false
|
87 |
+
return false;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Create a new job object
|
93 |
+
*
|
94 |
+
*/
|
95 |
+
public static function createJob($dependentOnJobId, $websiteId, $type, $feedType)
|
96 |
+
{
|
97 |
+
// Log
|
98 |
+
Mage::log('Scheduling new job.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
99 |
+
// Create new job object and init fields
|
100 |
+
$newJob = Mage::getModel('mybuys/job');
|
101 |
+
$newJob->setDependentOnJobId($dependentOnJobId);
|
102 |
+
$newJob->setMinEntityId(0);
|
103 |
+
$newJob->setWebsiteId($websiteId);
|
104 |
+
$newJob->setType($type);
|
105 |
+
$newJob->setFeedType($feedType);
|
106 |
+
$newJob->setScheduledAt(Mage::getSingleton('core/date')->gmtDate());
|
107 |
+
$newJob->setStatus(Mybuys_Connector_Model_Job::STATUS_SCHEDULED);
|
108 |
+
$newJob->save();
|
109 |
+
return $newJob;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Cleanup the job queue, removing all jobs that were created more than max age days ago
|
114 |
+
*
|
115 |
+
*/
|
116 |
+
public static function cleanupJobQueue()
|
117 |
+
{
|
118 |
+
// Log
|
119 |
+
Mage::log('Cleaning up the job queue.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
120 |
+
|
121 |
+
// Iterate websites and check configuration
|
122 |
+
$websites = Mage::app()->getWebsites(false, true);
|
123 |
+
foreach ($websites as $website) {
|
124 |
+
// Save website id
|
125 |
+
$websiteId = $website->getId();
|
126 |
+
|
127 |
+
// Lookup age days config settings
|
128 |
+
$maxAgeDays = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/advanced/max_job_age');
|
129 |
+
|
130 |
+
// log
|
131 |
+
Mage::log('Max job age (for website id: ' . $websiteId . ') in days: ' . $maxAgeDays, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
132 |
+
|
133 |
+
// Retrieve the write connection
|
134 |
+
$resource = Mage::getSingleton('core/resource');
|
135 |
+
$writeConnection = $resource->getConnection('core_write');
|
136 |
+
|
137 |
+
// Retrieve our table name
|
138 |
+
$table = $resource->getTableName('mybuys/job');
|
139 |
+
|
140 |
+
// Build query
|
141 |
+
$query = "DELETE FROM {$table} WHERE date(scheduled_at) < date_sub(curdate(), interval {$maxAgeDays} DAY) AND website_id = {$websiteId}";
|
142 |
+
|
143 |
+
// Execute the query
|
144 |
+
$writeConnection->query($query);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Purge all scheduled jobs
|
150 |
+
*
|
151 |
+
*/
|
152 |
+
public static function purgeAllJobs()
|
153 |
+
{
|
154 |
+
// Iterate websites and check configuration
|
155 |
+
$websites = Mage::app()->getWebsites(false, true);
|
156 |
+
foreach ($websites as $website) {
|
157 |
+
// Save website id
|
158 |
+
$websiteId = $website->getId();
|
159 |
+
|
160 |
+
// Retrieve the write connection
|
161 |
+
$resource = Mage::getSingleton('core/resource');
|
162 |
+
$writeConnection = $resource->getConnection('core_write');
|
163 |
+
|
164 |
+
// Retrieve our table name
|
165 |
+
$table = $resource->getTableName('mybuys/job');
|
166 |
+
|
167 |
+
// Build query
|
168 |
+
$query = "DELETE FROM {$table} WHERE website_id = {$websiteId}";
|
169 |
+
|
170 |
+
// Execute the query
|
171 |
+
$writeConnection->query($query);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Schedule all the necessary daily jobs for today, only do once per day based on configure schedule
|
177 |
+
*
|
178 |
+
*/
|
179 |
+
public static function scheduleAllDailyJobs()
|
180 |
+
{
|
181 |
+
// Iterate websites and check configuration
|
182 |
+
$websites = Mage::app()->getWebsites(false, true);
|
183 |
+
foreach ($websites as $website) {
|
184 |
+
if (self::_checkTime($website->getId())) {
|
185 |
+
// Schedule daily jobs for this website
|
186 |
+
Mybuys_Connector_Model_Job::scheduleJobs($website->getId(), false);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
private static function _checkTime($websiteId)
|
192 |
+
{
|
193 |
+
// Lookup configured time
|
194 |
+
$configTime = trim(Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/schedule/dailyfeedtime'));
|
195 |
+
// Log
|
196 |
+
Mage::log('Daily feed time configuration (for website id ' . $websiteId . '): "' . $configTime . '"', Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
197 |
+
|
198 |
+
// Lookup configured timezone
|
199 |
+
$timezone = Mage::app()->getWebsite($websiteId)->getConfig('general/locale/timezone');
|
200 |
+
// Get current time
|
201 |
+
$curDateTime = new DateTime("now", new DateTimeZone($timezone));
|
202 |
+
// Log
|
203 |
+
Mage::log('Current time: "' . $curDateTime->format('H:i:s') . '" timezone: "' . $curDateTime->getTimezone()->getName() . '"', Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
204 |
+
|
205 |
+
// Create time object from configured time
|
206 |
+
$configDateTime = new DateTime("now", new DateTimeZone($timezone));
|
207 |
+
$configDateTime->setTime(
|
208 |
+
intval(substr($configTime, 0, 2)),
|
209 |
+
intval(substr($configTime, 3, 2)),
|
210 |
+
intval(substr($configTime, 6, 2)));
|
211 |
+
// Log
|
212 |
+
Mage::log('Configured time: "' . $configDateTime->format('H:i:s') . '" timezone: "' . $configDateTime->getTimezone()->getName() . '"', Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
213 |
+
|
214 |
+
// Do time diff
|
215 |
+
$minutes = floor(($curDateTime->format('U') - $configDateTime->format('U')) / 60);
|
216 |
+
|
217 |
+
// Interpret result
|
218 |
+
if ($minutes >= -4 && $minutes <= 4) {
|
219 |
+
return true;
|
220 |
+
} else {
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Schedule all daily or baseline jobs for all websites to run immediately
|
227 |
+
*/
|
228 |
+
|
229 |
+
public static function scheduleJobsAllWebsites($bBaselineFile)
|
230 |
+
{
|
231 |
+
// Iterate websites and check configuration
|
232 |
+
$websites = Mage::app()->getWebsites(false, true);
|
233 |
+
foreach ($websites as $website) {
|
234 |
+
// Save website id
|
235 |
+
$websiteId = $website->getId();
|
236 |
+
|
237 |
+
// Schedule jobs for this website
|
238 |
+
Mybuys_Connector_Model_Job::scheduleJobs($websiteId, $bBaselineFile);
|
239 |
+
}
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Schedule baseline or incremental daily jobs to run immediately
|
245 |
+
*
|
246 |
+
*
|
247 |
+
*/
|
248 |
+
public static function scheduleJobs($websiteId, $bBaselineFile)
|
249 |
+
{
|
250 |
+
// Log
|
251 |
+
Mage::log('Scheduling jobs for website: ' . $websiteId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
252 |
+
Mage::log('All feeds for website set to: ' . Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled'), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
253 |
+
|
254 |
+
// Local to hold last job id
|
255 |
+
$lastJobId = null;
|
256 |
+
|
257 |
+
// Check if data feeds enabled
|
258 |
+
if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') != 'enabled') {
|
259 |
+
return;
|
260 |
+
}
|
261 |
+
|
262 |
+
// Create generate jobs for all enabled feeds
|
263 |
+
foreach (Mybuys_Connector_Model_Generatefeeds::getFeedTypes() as $curType) {
|
264 |
+
// Create feed job of this type if config is enabled
|
265 |
+
if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $curType) == 'enabled') {
|
266 |
+
// Check baseline or daily
|
267 |
+
$jobType = 0;
|
268 |
+
if ($bBaselineFile) {
|
269 |
+
$jobType = Mybuys_Connector_Model_Job::TYPE_GENERATE_BASELINE;
|
270 |
+
} else {
|
271 |
+
$jobType = Mybuys_Connector_Model_Job::TYPE_GENERATE_DAILY;
|
272 |
+
}
|
273 |
+
|
274 |
+
// Create feed job
|
275 |
+
$job = Mybuys_Connector_Model_Job::createJob($lastJobId, $websiteId, $jobType, $curType);
|
276 |
+
$job->save();
|
277 |
+
$lastJobId = $job->getJobId();
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
// Create transfer feeds job for this website
|
282 |
+
$job = Mybuys_Connector_Model_Job::createJob($lastJobId, $websiteId, Mybuys_Connector_Model_Job::TYPE_TRANSFER, NULL);
|
283 |
+
$job->save();
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Run job
|
288 |
+
*
|
289 |
+
*/
|
290 |
+
public function run()
|
291 |
+
{
|
292 |
+
try {
|
293 |
+
// Log
|
294 |
+
Mage::log('Running job: ' . $this->getJobId(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
295 |
+
Mage::log('Website Id: ' . $this->getWebsiteId(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
296 |
+
Mage::log('Dependent On Job Id: ' . $this->getDependentOnJobId(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
297 |
+
Mage::log('Min Entity Id: ' . $this->getMinEntityId(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
298 |
+
Mage::log('Type: ' . $this->getType(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
299 |
+
Mage::log('Feed Type: ' . $this->getFeedType(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
300 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
301 |
+
|
302 |
+
// Execute the job
|
303 |
+
$this->executeJob();
|
304 |
+
|
305 |
+
// Log
|
306 |
+
Mage::log('Job completed successfully.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
307 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
308 |
+
} catch (Exception $e) {
|
309 |
+
// Fail this job
|
310 |
+
$this->setStatus(Mybuys_Connector_Model_Job::STATUS_ERROR);
|
311 |
+
$this->setEndedAt(Mage::getSingleton('core/date')->gmtDate());
|
312 |
+
$this->setErrorMessage($e->getMessage());
|
313 |
+
$this->save();
|
314 |
+
// Log exception
|
315 |
+
Mage::logException($e);
|
316 |
+
Mage::log('Job failed with error:', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
317 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
318 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
319 |
+
// Send error email
|
320 |
+
Mage::helper('mybuys')->sendErrorEmail($this->getWebsiteId(), $e->getMessage());
|
321 |
+
}
|
322 |
+
|
323 |
+
return $this;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Execute this job
|
328 |
+
*
|
329 |
+
*/
|
330 |
+
protected function executeJob()
|
331 |
+
{
|
332 |
+
// Check data feeds enabled
|
333 |
+
if (Mage::app()->getWebsite($this->getWebsiteId())->getConfig('mybuys_datafeeds/general/allfeedsenabled') != 'enabled') {
|
334 |
+
Mage::throwException('Data feeds not enabled for website: ' . $this->getWebsiteId());
|
335 |
+
}
|
336 |
+
|
337 |
+
// Done flag
|
338 |
+
$bDone = false;
|
339 |
+
|
340 |
+
// Switch on job type
|
341 |
+
switch ($this->getType()) {
|
342 |
+
case Mybuys_Connector_Model_Job::TYPE_GENERATE_BASELINE:
|
343 |
+
// Call out to Mybuys_Connector_Model_Generatefeeds
|
344 |
+
// Send false param to generate incremental (automatic daily) data feeds
|
345 |
+
$genModel = Mage::getModel('mybuys/generatefeeds');
|
346 |
+
$minEntityId = $this->getMinEntityId();
|
347 |
+
$genModel->generateForWebsite($this->getWebsiteId(), true, $this->getFeedType(), $minEntityId, $bDone);
|
348 |
+
$this->setMinEntityId($minEntityId);
|
349 |
+
break;
|
350 |
+
case Mybuys_Connector_Model_Job::TYPE_GENERATE_DAILY:
|
351 |
+
// Call out to Mybuys_Connector_Model_Generatefeeds
|
352 |
+
// Send false param to generate incremental (automatic daily) data feeds
|
353 |
+
$genModel = Mage::getModel('mybuys/generatefeeds');
|
354 |
+
$minEntityId = $this->getMinEntityId();
|
355 |
+
$genModel->generateForWebsite($this->getWebsiteId(), false, $this->getFeedType(), $minEntityId, $bDone);
|
356 |
+
$this->setMinEntityId($minEntityId);
|
357 |
+
break;
|
358 |
+
case Mybuys_Connector_Model_Job::TYPE_TRANSFER:
|
359 |
+
// Call out to Mybuys_Connector_Model_Transferfeeds
|
360 |
+
$tranModel = Mage::getModel('mybuys/transferfeeds');
|
361 |
+
$tranModel->transfer($this->getWebsiteId());
|
362 |
+
$bDone = true;
|
363 |
+
break;
|
364 |
+
}
|
365 |
+
|
366 |
+
// Mark job as succeeded
|
367 |
+
if ($bDone) {
|
368 |
+
$this->setStatus(Mybuys_Connector_Model_Job::STATUS_COMPLETED);
|
369 |
+
$this->setEndedAt(Mage::getSingleton('core/date')->gmtDate());
|
370 |
+
}
|
371 |
+
// Save done status & or new min entity_id
|
372 |
+
$this->save();
|
373 |
+
|
374 |
+
}
|
375 |
+
}
|
app/code/community/Mybuys/Connector/Model/Mysql4/Job.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('mybuys/job', 'job_id');
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
app/code/community/Mybuys/Connector/Model/Mysql4/Job/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Mysql4_Job_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*/
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
$this->_init('mybuys/job');
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
app/code/community/Mybuys/Connector/Model/Observer.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Observer
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Generate and send new datafeed files
|
15 |
+
*
|
16 |
+
* @param Mage_Cron_Model_Schedule $schedule
|
17 |
+
* @return Mybuys_Connector_Model_Observer
|
18 |
+
*/
|
19 |
+
public function processDailyFeeds($schedule)
|
20 |
+
{
|
21 |
+
try {
|
22 |
+
// Log
|
23 |
+
Mage::log('**********************************************************', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
24 |
+
Mage::log('Data feeds cron process started...', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
25 |
+
Mage::log('Is Single Store Mode: ' . Mage::app()->isSingleStoreMode(), Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
26 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
27 |
+
Mage::log('**********************************************************', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
28 |
+
|
29 |
+
// Cleanup queue
|
30 |
+
$this->cleanupJobQueue();
|
31 |
+
|
32 |
+
// Log mem usage
|
33 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
34 |
+
|
35 |
+
// Schedule daily feed jobs for all websites
|
36 |
+
$this->scheduleJobs();
|
37 |
+
|
38 |
+
// Log mem usage
|
39 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
40 |
+
|
41 |
+
// Run 1 job
|
42 |
+
$this->runJob();
|
43 |
+
|
44 |
+
// Log
|
45 |
+
Mage::log('**********************************************************', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
46 |
+
Mage::log('Daily feeds cron process completed successfully.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
47 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
48 |
+
Mage::log('**********************************************************', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
49 |
+
}
|
50 |
+
catch(Exception $e) {
|
51 |
+
// Log exception
|
52 |
+
Mage::logException($e);
|
53 |
+
Mage::log('**********************************************************', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
54 |
+
Mage::log('Data feeds cron process failed with error:', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
55 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
56 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
57 |
+
Mage::log('**********************************************************', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Remove old entries from the job queue
|
65 |
+
*
|
66 |
+
*
|
67 |
+
*/
|
68 |
+
protected function cleanupJobQueue()
|
69 |
+
{
|
70 |
+
try {
|
71 |
+
Mybuys_Connector_Model_Job::cleanupJobQueue();
|
72 |
+
}
|
73 |
+
catch(Exception $e) {
|
74 |
+
// Log exception
|
75 |
+
Mage::logException($e);
|
76 |
+
Mage::log('Failed to cleaup job queue, error:', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
77 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
78 |
+
throw $e;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Schedule any daily feed jobs which are necessary when we hit the daily trigger time
|
84 |
+
*
|
85 |
+
*
|
86 |
+
*/
|
87 |
+
protected function scheduleJobs()
|
88 |
+
{
|
89 |
+
try {
|
90 |
+
Mybuys_Connector_Model_Job::scheduleAllDailyJobs();
|
91 |
+
}
|
92 |
+
catch(Exception $e) {
|
93 |
+
// Log exception
|
94 |
+
Mage::logException($e);
|
95 |
+
Mage::log('Failed to schedule daily jobs, error:', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
96 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
97 |
+
throw $e;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Grab the next job and run it, if it exists
|
103 |
+
*
|
104 |
+
*
|
105 |
+
*/
|
106 |
+
protected function runJob()
|
107 |
+
{
|
108 |
+
try {
|
109 |
+
$job = Mybuys_Connector_Model_Job::getNextJobFromQueue();
|
110 |
+
if($job !== false) {
|
111 |
+
$job->run();
|
112 |
+
}
|
113 |
+
}
|
114 |
+
catch(Exception $e) {
|
115 |
+
// Log exception
|
116 |
+
Mage::logException($e);
|
117 |
+
Mage::log('Failed to run job, error:', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
118 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
119 |
+
throw $e;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
app/code/community/Mybuys/Connector/Model/System/Config/EnableToggle.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_System_Config_EnableToggle
|
12 |
+
{
|
13 |
+
public function toOptionArray()
|
14 |
+
{
|
15 |
+
return array(
|
16 |
+
//array('value'=>'', 'label'=>''),
|
17 |
+
array('value'=>'enabled', 'label'=>Mage::helper('adminhtml')->__('Enabled')),
|
18 |
+
array('value'=>'disabled', 'label'=>Mage::helper('adminhtml')->__('Disabled')),
|
19 |
+
);
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Mybuys/Connector/Model/System/Config/ProductAttributes.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
*/
|
4 |
+
class Mybuys_Connector_Model_System_Config_ProductAttributes
|
5 |
+
{
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
|
9 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
10 |
+
//->addAttributeToSelect('*')
|
11 |
+
//->addAttributeToFilter('is_user_defined', 1)
|
12 |
+
->addVisibleFilter()
|
13 |
+
->addStoreLabel(Mage::app()->getStore()->getId())
|
14 |
+
->setOrder('main_table.attribute_id', 'asc')
|
15 |
+
// not in
|
16 |
+
->load();
|
17 |
+
$result = array();
|
18 |
+
foreach ($attributes as $_attribute) {
|
19 |
+
if ($_attribute->getIsUserDefined()) {
|
20 |
+
$result[] = array(
|
21 |
+
'value' => $_attribute["attribute_code"],
|
22 |
+
'label' => $_attribute["frontend_label"]
|
23 |
+
);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
return $result;
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Mybuys/Connector/Model/System/Validate/ProductAttributes.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
*/
|
4 |
+
class Mybuys_Connector_Model_System_Validate_ProductAttributes extends Mage_Core_Model_Config_Data
|
5 |
+
{
|
6 |
+
const ATTRIBUTE_LIMIT = 20;
|
7 |
+
|
8 |
+
public function save()
|
9 |
+
{
|
10 |
+
$limit = Mage::app()->getWebsite()->getConfig('mybuys_datafeeds/advanced/attribute_limit');
|
11 |
+
if (!$limit) {
|
12 |
+
$limit = self::ATTRIBUTE_LIMIT ;
|
13 |
+
}
|
14 |
+
|
15 |
+
$selections = $this->getValue(); //get the value from our config
|
16 |
+
|
17 |
+
if(sizeof($selections) > $limit) // more than 15 items selected
|
18 |
+
{
|
19 |
+
Mage::getSingleton('core/session')->addWarning(
|
20 |
+
Mage::helper('mybuys')->__(
|
21 |
+
"WARNING - Too many Product Custom Attributes selected for the product data feed.<br/>Only the first %s selected attributes were saved and applied to the feed.", $limit));
|
22 |
+
}
|
23 |
+
|
24 |
+
$this->setValue(array_slice($selections,0,$limit,true)); //only keep the first 15 items the user selected
|
25 |
+
return parent::save();
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Mybuys/Connector/Model/Transferfeeds.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Model_Transferfeeds
|
12 |
+
{
|
13 |
+
// Folder on MyBuys FTP is hardcoded in extension
|
14 |
+
const SFTP_FOLDER = '.';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Transfer data feeds to MyBuys, triggered by cron
|
18 |
+
*
|
19 |
+
* @param int|string $websiteId Id of the website for which to generate data feeds
|
20 |
+
*/
|
21 |
+
public function transfer($websiteId)
|
22 |
+
{
|
23 |
+
try {
|
24 |
+
// Log
|
25 |
+
Mage::log('Transferring data feeds for website with Id: ' . $websiteId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
26 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
27 |
+
|
28 |
+
// Check data feeds enabled
|
29 |
+
if(Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') != 'enabled') {
|
30 |
+
Mage::throwException('Data feeds not enabled for website: ' . $websiteId);
|
31 |
+
}
|
32 |
+
|
33 |
+
// Build list and transfer feeds for site
|
34 |
+
$fileList = $this->buildFileList($websiteId);
|
35 |
+
$bSuccess = $this->transferFileList($websiteId, $fileList);
|
36 |
+
if(!$bSuccess) {
|
37 |
+
Mage::throwException('Transfer file list failed!');
|
38 |
+
}
|
39 |
+
|
40 |
+
Mage::log('Sucessfully transferred data feeds for website.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
41 |
+
}
|
42 |
+
catch(Exception $e) {
|
43 |
+
Mage::log('Failed to transfer data feeds for website.', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
44 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
45 |
+
// Rethrow
|
46 |
+
throw $e;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Build list of files to transfer, based on enabled website
|
52 |
+
*
|
53 |
+
* @param int|string $websiteId Id of the website for which to generate data feeds
|
54 |
+
* @return array List of files to transfer for this website (full path & filename specified for each)
|
55 |
+
*/
|
56 |
+
protected function buildFileList($websiteId)
|
57 |
+
{
|
58 |
+
// Lookup feed path
|
59 |
+
$feedPath = Mage::getConfig()->getVarDir() . DS . Mybuys_Connector_Model_Generatefeeds::MBUYS_FEED_PATH;
|
60 |
+
|
61 |
+
// Log
|
62 |
+
Mage::log('Searching for feed files for website id: ' . $websiteId . ' here: ' . $feedPath, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
63 |
+
|
64 |
+
// Create websiteid match string
|
65 |
+
$websiteIdMatchString = '-websiteid-' . $websiteId;
|
66 |
+
|
67 |
+
// List to hold files we find
|
68 |
+
$fileList = array();
|
69 |
+
|
70 |
+
// Open feed directory
|
71 |
+
$dh = opendir($feedPath);
|
72 |
+
if ($dh === FALSE) {
|
73 |
+
Mage::throwException('Failed to open feed directory: ' . $feedPath);
|
74 |
+
}
|
75 |
+
|
76 |
+
// Iterate files in directory
|
77 |
+
while (($entry = readdir($dh)) !== FALSE) {
|
78 |
+
// Get full path
|
79 |
+
$fullpath = $feedPath . DS . $entry;
|
80 |
+
|
81 |
+
// Check if have a file (as opposed to directory or link)
|
82 |
+
if( is_file($fullpath) ) {
|
83 |
+
// Check if our file is for the correct websiteId
|
84 |
+
if(strpos($fullpath, $websiteIdMatchString) !== FALSE) {
|
85 |
+
// Add file to our list
|
86 |
+
$fileList[] = $fullpath;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// Close dir handle
|
92 |
+
closedir($dh);
|
93 |
+
|
94 |
+
// Log
|
95 |
+
Mage::log('Found ' . count($fileList) . ' feed files for website id: ' . $websiteId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
96 |
+
|
97 |
+
return $fileList;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Transfer this list of files to the SFTP site for MyBuys
|
102 |
+
*
|
103 |
+
* @param int|string $websiteId Id of the website for which to generate data feeds
|
104 |
+
* @param array $fileList List of file names (full path) to transfer
|
105 |
+
* @return bool Indicates if files successfully transfered or not
|
106 |
+
*/
|
107 |
+
protected function transferFileList($websiteId, array $fileList)
|
108 |
+
{
|
109 |
+
// Log
|
110 |
+
Mage::log('Transferring ' . count($fileList) . ' files for website id: ' . $websiteId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
111 |
+
|
112 |
+
// Assemble SFTP crednetials
|
113 |
+
try {
|
114 |
+
// Get hostname & port
|
115 |
+
$sftpHost = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/hostname');
|
116 |
+
$sftpPort = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/port');
|
117 |
+
// Get user credentials from config
|
118 |
+
$sftpUser = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/username');
|
119 |
+
$sftpPassword = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/password');
|
120 |
+
$sftpPassword = Mage::helper('core')->decrypt(trim($sftpPassword));
|
121 |
+
}
|
122 |
+
catch (Exception $e)
|
123 |
+
{
|
124 |
+
// Log
|
125 |
+
Mage::logException($e);
|
126 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
|
130 |
+
//TODO - Add debug infromation to the email that gets sent out
|
131 |
+
|
132 |
+
// Connect to server
|
133 |
+
$connection = Mage::helper('mybuys/sftpConnection');
|
134 |
+
/* @var $file Mybuys_Connector_Helper_SftpConnection */
|
135 |
+
$bSuccess = $connection->connect($sftpHost, $sftpPort, $sftpUser, $sftpPassword);
|
136 |
+
if(!$bSuccess) {
|
137 |
+
Mage::log('Failed to connect to MyBuys!', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
|
141 |
+
// Change to upload folder
|
142 |
+
$sftpFolder = self::SFTP_FOLDER;
|
143 |
+
$bSuccess = $connection->changeDir($sftpFolder);
|
144 |
+
if(!$bSuccess) {
|
145 |
+
Mage::log('Failed to change folders to: ' . $sftpFolder, Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
|
149 |
+
// Iterate file list and put each file
|
150 |
+
$bTransferSucceeded = true;
|
151 |
+
foreach($fileList as $curFile) {
|
152 |
+
// Log
|
153 |
+
Mage::log('Transferring file: ' . $curFile, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
154 |
+
Mage::log('Memory usage: ' . memory_get_usage(), Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
|
155 |
+
// Transfer file
|
156 |
+
$bSuccess = $connection->putAndDeleteFile($curFile);
|
157 |
+
if(!$bSuccess) {
|
158 |
+
Mage::log('Failed to transfer and delete file: ' . $curFile, Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
159 |
+
$bTransferSucceeded = false;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
// Close connection, dont check result
|
164 |
+
$connection->close();
|
165 |
+
|
166 |
+
// Check results
|
167 |
+
if(!$bTransferSucceeded) {
|
168 |
+
Mage::log('Some file transfers failed!', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
else {
|
172 |
+
Mage::log('Successfully transferred all files.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
173 |
+
return true;
|
174 |
+
}
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
}
|
179 |
+
|
app/code/community/Mybuys/Connector/controllers/Adminhtml/ExportController.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
public function indexAction()
|
15 |
+
{
|
16 |
+
$this->loadLayout()->_setActiveMenu("mybuys/export");
|
17 |
+
$this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Export baseline data feed
|
22 |
+
*/
|
23 |
+
public function exportoneAction()
|
24 |
+
{
|
25 |
+
// Validate configuration
|
26 |
+
try {
|
27 |
+
// Get ID from request
|
28 |
+
$id = $this->getRequest()->getParam('id');
|
29 |
+
Mage::helper('mybuys')->validateFeedConfiguration($id);
|
30 |
+
}
|
31 |
+
catch(Exception $e) {
|
32 |
+
// Display message
|
33 |
+
$this->_getSession()->addError($this->__($e->getMessage()));
|
34 |
+
|
35 |
+
// Redirect back to index
|
36 |
+
$this->_redirect('*/*/index');
|
37 |
+
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
+
try {
|
42 |
+
// Get ID from request
|
43 |
+
$id = $this->getRequest()->getParam('id');
|
44 |
+
// Log
|
45 |
+
Mage::log('Scheduling immediate baseline data feeds for website Id: ' . $id, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
46 |
+
|
47 |
+
// Schedule all feeds for this site
|
48 |
+
Mybuys_Connector_Model_Job::scheduleJobs($id, true);
|
49 |
+
|
50 |
+
// Log
|
51 |
+
Mage::log('Successfully scheduled feeds.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
52 |
+
}
|
53 |
+
catch(Exception $e) {
|
54 |
+
// Log exception
|
55 |
+
Mage::logException($e);
|
56 |
+
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
57 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
58 |
+
}
|
59 |
+
|
60 |
+
// Display message once job scheduled
|
61 |
+
$this->_getSession()->addSuccess($this->__('Baseline feed generation and transfer has been scheduled for website ID ' . $id . '.'));
|
62 |
+
|
63 |
+
// Redirect back to index
|
64 |
+
$this->_redirect('*/*/index');
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Export all baseline data feeds
|
69 |
+
*/
|
70 |
+
public function exportallAction()
|
71 |
+
{
|
72 |
+
// Validate configuration
|
73 |
+
try {
|
74 |
+
Mage::helper('mybuys')->validateFeedConfiguration();
|
75 |
+
}
|
76 |
+
catch(Exception $e) {
|
77 |
+
// Display message
|
78 |
+
$this->_getSession()->addError($this->__($e->getMessage()));
|
79 |
+
|
80 |
+
// Redirect back to index
|
81 |
+
$this->_redirect('*/*/index');
|
82 |
+
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
try {
|
87 |
+
// Get ID from request
|
88 |
+
$id = $this->getRequest()->getParam('id');
|
89 |
+
// Log
|
90 |
+
Mage::log('Scheduling immediate baseline data feeds for all websites.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
91 |
+
|
92 |
+
// Schedule all feeds for this site
|
93 |
+
Mybuys_Connector_Model_Job::scheduleJobsAllWebsites(true);
|
94 |
+
|
95 |
+
// Log
|
96 |
+
Mage::log('Successfully scheduled feeds.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
97 |
+
}
|
98 |
+
catch(Exception $e) {
|
99 |
+
// Log exception
|
100 |
+
Mage::logException($e);
|
101 |
+
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
102 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
103 |
+
}
|
104 |
+
|
105 |
+
// Display message once job scheduled
|
106 |
+
$this->_getSession()->addSuccess($this->__('Baseline feed generation and transfer has been scheduled all websites.'));
|
107 |
+
|
108 |
+
// Redirect back to index
|
109 |
+
$this->_redirect('*/*/index');
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
app/code/community/Mybuys/Connector/controllers/Adminhtml/JobController.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Mybuys_Connector_Adminhtml_JobController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
public function indexAction()
|
15 |
+
{
|
16 |
+
$this->loadLayout()->_setActiveMenu("mybuys/job");
|
17 |
+
$this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Export all baseline data feeds
|
22 |
+
*/
|
23 |
+
public function exportallAction()
|
24 |
+
{
|
25 |
+
// Validate configuration
|
26 |
+
try {
|
27 |
+
Mage::helper('mybuys')->validateFeedConfiguration();
|
28 |
+
} catch (Exception $e) {
|
29 |
+
// Display message
|
30 |
+
$this->_getSession()->addError($this->__($e->getMessage()));
|
31 |
+
|
32 |
+
// Redirect back to index
|
33 |
+
$this->_redirect('*/*/index');
|
34 |
+
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
|
38 |
+
try {
|
39 |
+
// Log
|
40 |
+
Mage::log('Scheduling immediate baseline data feeds for all websites.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
41 |
+
|
42 |
+
// Schedule all feeds for this site
|
43 |
+
Mybuys_Connector_Model_Job::scheduleJobsAllWebsites(true);
|
44 |
+
|
45 |
+
// Log
|
46 |
+
Mage::log('Successfully scheduled feeds.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
47 |
+
} catch (Exception $e) {
|
48 |
+
// Log exception
|
49 |
+
Mage::logException($e);
|
50 |
+
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
51 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
52 |
+
}
|
53 |
+
|
54 |
+
// Display message once job scheduled
|
55 |
+
$this->_getSession()->addSuccess($this->__('Baseline feed generation and transfer has been scheduled all websites.'));
|
56 |
+
|
57 |
+
// Redirect back to index
|
58 |
+
$this->_redirect('*/*/index');
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Purge all outstanding jobs
|
63 |
+
*/
|
64 |
+
|
65 |
+
public function purgeallAction()
|
66 |
+
{
|
67 |
+
|
68 |
+
try {
|
69 |
+
// Get ID from request
|
70 |
+
$id = $this->getRequest()->getParam('id');
|
71 |
+
// Log
|
72 |
+
Mage::log('Purging all jobs.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
73 |
+
|
74 |
+
// Purge all job records
|
75 |
+
Mage::getModel('mybuys/job')->purgeAllJobs();
|
76 |
+
|
77 |
+
// Log
|
78 |
+
Mage::log('Successfully purged all jobs.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
79 |
+
} catch (Exception $e) {
|
80 |
+
// Log exception
|
81 |
+
// Display message once job scheduled
|
82 |
+
$this->_getSession()->addSuccess($this->__('Failed to clear job queue.'));
|
83 |
+
Mage::logException($e);
|
84 |
+
Mage::log('Failed to purge jobs.', Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
85 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Mybuys_Connector_Helper_Data::LOG_FILE);
|
86 |
+
}
|
87 |
+
|
88 |
+
// Display message once job scheduled
|
89 |
+
$this->_getSession()->addSuccess($this->__('Job queue has been cleared.'));
|
90 |
+
|
91 |
+
// Redirect back to index
|
92 |
+
$this->_redirect('*/*/index');
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Purge all outstanding jobs
|
97 |
+
*/
|
98 |
+
|
99 |
+
public function massDeleteAction()
|
100 |
+
{
|
101 |
+
{
|
102 |
+
$jobIds = $this->getRequest()->getParam('job_id');
|
103 |
+
if (!is_array($jobIds)) {
|
104 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mybuys')->__('Please select jobs(s) to delete.'));
|
105 |
+
} else {
|
106 |
+
try {
|
107 |
+
$jobModel = Mage::getModel('mybuys/job');
|
108 |
+
foreach ($jobIds as $jobId) {
|
109 |
+
Mage::log('Mass delete - Deleting job id ' . $jobId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
110 |
+
// delete the job
|
111 |
+
$jobModel->load($jobId)->delete();
|
112 |
+
}
|
113 |
+
} catch (Exception $e) {
|
114 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
119 |
+
Mage::helper('mybuys')->__(
|
120 |
+
'Total of %d record(s) were deleted.', count($jobIds)
|
121 |
+
)
|
122 |
+
);
|
123 |
+
|
124 |
+
Mage::log('Mass delete - ' . count($jobIds) . ' jobs deleted.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
125 |
+
|
126 |
+
$this->_redirect('*/*/index');
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
public function massRunAction()
|
131 |
+
{
|
132 |
+
{
|
133 |
+
$jobIds = $this->getRequest()->getParam('job_id');
|
134 |
+
if (!is_array($jobIds)) {
|
135 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mybuys')->__('Please select jobs(s) to execute.'));
|
136 |
+
} else {
|
137 |
+
try {
|
138 |
+
$jobModel = Mage::getModel('mybuys/job');
|
139 |
+
foreach ($jobIds as $jobId) {
|
140 |
+
Mage::log('Mass execute - Execute job id ' . $jobId, Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
141 |
+
|
142 |
+
// run the job
|
143 |
+
$jobModel->load($jobId)
|
144 |
+
->setStartedAt(Mage::getSingleton('core/date')->gmtDate())
|
145 |
+
->save()
|
146 |
+
->run();
|
147 |
+
}
|
148 |
+
} catch (Exception $e) {
|
149 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
154 |
+
Mage::helper('mybuys')->__(
|
155 |
+
'Total of %d jobs(s) were executed.', count($jobIds)
|
156 |
+
)
|
157 |
+
);
|
158 |
+
|
159 |
+
Mage::log('Mass execute - ' . count($jobIds) . ' jobs executed.', Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
|
160 |
+
|
161 |
+
$this->_redirect('*/*/index');
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
}
|
app/code/community/Mybuys/Connector/etc/adminhtml.xml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* MyBuys Magento Connector
|
5 |
+
*
|
6 |
+
* @category Mybuys
|
7 |
+
* @package Mybuys_Connector
|
8 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
9 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<!-- MyBuys menu definition -->
|
14 |
+
<menu>
|
15 |
+
<mybuys module="mybuys">
|
16 |
+
<title>MyBuys</title>
|
17 |
+
<sort_order>85</sort_order>
|
18 |
+
<children>
|
19 |
+
<export module="mybuys">
|
20 |
+
<title>Generate Baseline Feeds</title>
|
21 |
+
<sort_order>0</sort_order>
|
22 |
+
<action>mybuys/adminhtml_export</action>
|
23 |
+
</export>
|
24 |
+
<job module="mybuys">
|
25 |
+
<title>Data Feed Queue</title>
|
26 |
+
<sort_order>0</sort_order>
|
27 |
+
<action>mybuys/adminhtml_job</action>
|
28 |
+
</job>
|
29 |
+
</children>
|
30 |
+
</mybuys>
|
31 |
+
</menu>
|
32 |
+
|
33 |
+
<!-- Config sections permission -->
|
34 |
+
<acl>
|
35 |
+
<resources>
|
36 |
+
<admin>
|
37 |
+
<children>
|
38 |
+
<system>
|
39 |
+
<children>
|
40 |
+
<config>
|
41 |
+
<children>
|
42 |
+
<mybuys_datafeeds translate="title" module="mybuys">
|
43 |
+
<title>MyBuys Data Feeds Configuration Section</title>
|
44 |
+
<sort_order>1</sort_order>
|
45 |
+
</mybuys_datafeeds>
|
46 |
+
<mybuys_websitecode translate="title" module="mybuys">
|
47 |
+
<title>MyBuys Website Code Section</title>
|
48 |
+
<sort_order>2</sort_order>
|
49 |
+
</mybuys_websitecode>
|
50 |
+
</children>
|
51 |
+
</config>
|
52 |
+
</children>
|
53 |
+
</system>
|
54 |
+
</children>
|
55 |
+
</admin>
|
56 |
+
</resources>
|
57 |
+
</acl>
|
58 |
+
|
59 |
+
<!-- Menu permissions -->
|
60 |
+
<acl>
|
61 |
+
<resources>
|
62 |
+
<admin>
|
63 |
+
<children>
|
64 |
+
<mybuys translate="title" module="mybuys">
|
65 |
+
<title>MyBuys</title>
|
66 |
+
<sort_order>1000</sort_order>
|
67 |
+
<children>
|
68 |
+
<export translate="title">
|
69 |
+
<title></title>
|
70 |
+
</export>
|
71 |
+
</children>
|
72 |
+
</mybuys>
|
73 |
+
</children>
|
74 |
+
</admin>
|
75 |
+
</resources>
|
76 |
+
</acl>
|
77 |
+
</config>
|
app/code/community/Mybuys/Connector/etc/config.xml
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* MyBuys Magento Connector
|
5 |
+
*
|
6 |
+
* @category Mybuys
|
7 |
+
* @package Mybuys_Connector
|
8 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
9 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
|
14 |
+
<modules>
|
15 |
+
<Mybuys_Connector>
|
16 |
+
<version>1.0.7</version>
|
17 |
+
</Mybuys_Connector>
|
18 |
+
</modules>
|
19 |
+
|
20 |
+
<global>
|
21 |
+
<helpers>
|
22 |
+
<mybuys>
|
23 |
+
<class>Mybuys_Connector_Helper</class>
|
24 |
+
</mybuys>
|
25 |
+
</helpers>
|
26 |
+
|
27 |
+
<blocks>
|
28 |
+
<mybuys>
|
29 |
+
<class>Mybuys_Connector_Block</class>
|
30 |
+
</mybuys>
|
31 |
+
</blocks>
|
32 |
+
<models>
|
33 |
+
<mybuys>
|
34 |
+
<class>Mybuys_Connector_Model</class>
|
35 |
+
<resourceModel>mybuys_mysql4</resourceModel>
|
36 |
+
</mybuys>
|
37 |
+
<mybuys_mysql4>
|
38 |
+
<class>Mybuys_Connector_Model_Mysql4</class>
|
39 |
+
<entities>
|
40 |
+
<job>
|
41 |
+
<table>mybuys_job</table>
|
42 |
+
</job>
|
43 |
+
</entities>
|
44 |
+
</mybuys_mysql4>
|
45 |
+
</models>
|
46 |
+
<resources>
|
47 |
+
<mybuys_setup>
|
48 |
+
<setup>
|
49 |
+
<module>Mybuys_Connector</module>
|
50 |
+
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
|
51 |
+
</setup>
|
52 |
+
<connection>
|
53 |
+
<use>core_setup</use>
|
54 |
+
</connection>
|
55 |
+
</mybuys_setup>
|
56 |
+
<mybuys_write>
|
57 |
+
<connection>
|
58 |
+
<use>core_write</use>
|
59 |
+
</connection>
|
60 |
+
</mybuys_write>
|
61 |
+
<mybuys_read>
|
62 |
+
<connection>
|
63 |
+
<use>core_read</use>
|
64 |
+
</connection>
|
65 |
+
</mybuys_read>
|
66 |
+
</resources>
|
67 |
+
</global>
|
68 |
+
|
69 |
+
<admin>
|
70 |
+
<routers>
|
71 |
+
<mybuys>
|
72 |
+
<use>admin</use>
|
73 |
+
<args>
|
74 |
+
<module>Mybuys_Connector</module>
|
75 |
+
<frontName>mybuys</frontName>
|
76 |
+
</args>
|
77 |
+
</mybuys>
|
78 |
+
</routers>
|
79 |
+
</admin>
|
80 |
+
|
81 |
+
<frontend>
|
82 |
+
<layout>
|
83 |
+
<updates>
|
84 |
+
<mybuys>
|
85 |
+
<file>mybuys/websitecode.xml</file>
|
86 |
+
</mybuys>
|
87 |
+
</updates>
|
88 |
+
</layout>
|
89 |
+
</frontend>
|
90 |
+
|
91 |
+
<adminhtml>
|
92 |
+
<layout>
|
93 |
+
<updates>
|
94 |
+
<mybuys>
|
95 |
+
<file>mybuys.xml</file>
|
96 |
+
</mybuys>
|
97 |
+
</updates>
|
98 |
+
</layout>
|
99 |
+
</adminhtml>
|
100 |
+
|
101 |
+
<crontab>
|
102 |
+
<jobs>
|
103 |
+
<mybuys_processdailyfeeds>
|
104 |
+
<schedule>
|
105 |
+
<cron_expr>0,5,10,15,20,25,30,35,40,45,50,55 * * * *</cron_expr>
|
106 |
+
</schedule>
|
107 |
+
<run>
|
108 |
+
<model>mybuys/observer::processDailyFeeds</model>
|
109 |
+
</run>
|
110 |
+
</mybuys_processdailyfeeds>
|
111 |
+
</jobs>
|
112 |
+
</crontab>
|
113 |
+
|
114 |
+
<default>
|
115 |
+
<mybuys_datafeeds>
|
116 |
+
<general>
|
117 |
+
<allfeedsenabled>disabled</allfeedsenabled>
|
118 |
+
</general>
|
119 |
+
<connect>
|
120 |
+
<hostname>f.p.mybuys.com</hostname>
|
121 |
+
<port>20022</port>
|
122 |
+
<username></username>
|
123 |
+
<password></password>
|
124 |
+
</connect>
|
125 |
+
<schedule>
|
126 |
+
<dailyfeedtime/>
|
127 |
+
</schedule>
|
128 |
+
<notification>
|
129 |
+
<emails></emails>
|
130 |
+
</notification>
|
131 |
+
<feedsenabled>
|
132 |
+
<category>enabled</category>
|
133 |
+
<category_attributes></category_attributes>
|
134 |
+
<product>enabled</product>
|
135 |
+
<product_attributes></product_attributes>
|
136 |
+
<sku>enabled</sku>
|
137 |
+
<transaction>enabled</transaction>
|
138 |
+
<crosssell>disabled</crosssell>
|
139 |
+
<rating>disabled</rating>
|
140 |
+
<email_optin>disabled</email_optin>
|
141 |
+
<email_optout>disabled</email_optout>
|
142 |
+
</feedsenabled>
|
143 |
+
<advanced>
|
144 |
+
<max_job_age>7</max_job_age>
|
145 |
+
<throttle>0</throttle>
|
146 |
+
<!-- change only if needed - attribute_limit values larger than 30 may cause problems with MySQL -->
|
147 |
+
<attribute_limit>20</attribute_limit>
|
148 |
+
</advanced>
|
149 |
+
</mybuys_datafeeds>
|
150 |
+
<mybuys_websitecode>
|
151 |
+
<general>
|
152 |
+
<identifier></identifier>
|
153 |
+
<website_code>disabled</website_code>
|
154 |
+
</general>
|
155 |
+
<button>
|
156 |
+
<mybuys_button>disabled</mybuys_button>
|
157 |
+
</button>
|
158 |
+
<recommendation>
|
159 |
+
<recommendation>disabled</recommendation>
|
160 |
+
<homepage>disabled</homepage>
|
161 |
+
<cat_high>disabled</cat_high>
|
162 |
+
<cat_leaf>disabled</cat_leaf>
|
163 |
+
<product_detail>disabled</product_detail>
|
164 |
+
<search_results>disabled</search_results>
|
165 |
+
<add_to_cart>disabled</add_to_cart>
|
166 |
+
<checkout>disabled</checkout>
|
167 |
+
<order_confirmation>disabled</order_confirmation>
|
168 |
+
</recommendation>
|
169 |
+
</mybuys_websitecode>
|
170 |
+
</default>
|
171 |
+
</config>
|
app/code/community/Mybuys/Connector/etc/system.xml
ADDED
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* MyBuys Magento Connector
|
5 |
+
*
|
6 |
+
* @category Mybuys
|
7 |
+
* @package Mybuys_Connector
|
8 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
9 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
|
13 |
+
<config>
|
14 |
+
<tabs>
|
15 |
+
<mybuys translate="label" module="mybuys">
|
16 |
+
<label><![CDATA[<div style="text-transform:none;padding-left:0px;">MyBuys</div>]]></label>
|
17 |
+
<sort_order>150</sort_order>
|
18 |
+
</mybuys>
|
19 |
+
</tabs>
|
20 |
+
|
21 |
+
<sections>
|
22 |
+
<mybuys_datafeeds translate="label" module="mybuys">
|
23 |
+
<label>Data Feeds Configuration</label>
|
24 |
+
<tab>mybuys</tab>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>3310</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>1</show_in_store>
|
30 |
+
<groups>
|
31 |
+
<general translate="label">
|
32 |
+
<label>General</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>1</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
<fields>
|
39 |
+
<allfeedsenabled translate="label">
|
40 |
+
<label>Data Feeds Enabled</label>
|
41 |
+
<frontend_type>select</frontend_type>
|
42 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
43 |
+
<sort_order>1</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
<comment>Enable/disable all data feeds</comment>
|
48 |
+
</allfeedsenabled>
|
49 |
+
</fields>
|
50 |
+
</general>
|
51 |
+
<connect translate="label">
|
52 |
+
<label>SFTP Connectivity</label>
|
53 |
+
<frontend_type>text</frontend_type>
|
54 |
+
<sort_order>2</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>1</show_in_store>
|
58 |
+
<fields>
|
59 |
+
<hostname translate="label">
|
60 |
+
<label>Hostname</label>
|
61 |
+
<frontend_type>text</frontend_type>
|
62 |
+
<sort_order>2</sort_order>
|
63 |
+
<show_in_default>0</show_in_default>
|
64 |
+
<show_in_website>1</show_in_website>
|
65 |
+
<show_in_store>0</show_in_store>
|
66 |
+
<comment>Enter Hostname provided by MyBuys</comment>
|
67 |
+
</hostname>
|
68 |
+
<port translate="label">
|
69 |
+
<label>Port Number</label>
|
70 |
+
<frontend_type>text</frontend_type>
|
71 |
+
<sort_order>2</sort_order>
|
72 |
+
<show_in_default>0</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>0</show_in_store>
|
75 |
+
<validate>validate-number</validate>
|
76 |
+
<comment>Enter the port number provided by MyBuys</comment>
|
77 |
+
</port>
|
78 |
+
<username translate="label">
|
79 |
+
<label>Username</label>
|
80 |
+
<frontend_type>text</frontend_type>
|
81 |
+
<sort_order>3</sort_order>
|
82 |
+
<show_in_default>0</show_in_default>
|
83 |
+
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>0</show_in_store>
|
85 |
+
<comment>Enter SFTP username provided by MyBuys</comment>
|
86 |
+
</username>
|
87 |
+
<password translate="label">
|
88 |
+
<label>Password</label>
|
89 |
+
<frontend_type>obscure</frontend_type>
|
90 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
91 |
+
<sort_order>4</sort_order>
|
92 |
+
<show_in_default>0</show_in_default>
|
93 |
+
<show_in_website>1</show_in_website>
|
94 |
+
<show_in_store>0</show_in_store>
|
95 |
+
<comment>Enter SFTP account password provided by MyBuys</comment>
|
96 |
+
</password>
|
97 |
+
</fields>
|
98 |
+
</connect>
|
99 |
+
<schedule translate="label">
|
100 |
+
<label>Data Feed Schedule</label>
|
101 |
+
<frontend_type>text</frontend_type>
|
102 |
+
<sort_order>3</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
<show_in_website>1</show_in_website>
|
105 |
+
<show_in_store>1</show_in_store>
|
106 |
+
<fields>
|
107 |
+
<dailyfeedtime translate="label comment" >
|
108 |
+
<label>Time of day to run Data Feeds</label>
|
109 |
+
<frontend_type>Time</frontend_type>
|
110 |
+
<sort_order>1</sort_order>
|
111 |
+
<show_in_default>0</show_in_default>
|
112 |
+
<show_in_website>1</show_in_website>
|
113 |
+
<show_in_store>0</show_in_store>
|
114 |
+
<comment>Hour-----Minute-----Second (Server Time)</comment>
|
115 |
+
</dailyfeedtime>
|
116 |
+
</fields>
|
117 |
+
</schedule>
|
118 |
+
<notification translate="label">
|
119 |
+
<label>Error Email Notifications</label>
|
120 |
+
<frontend_type>text</frontend_type>
|
121 |
+
<sort_order>4</sort_order>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>1</show_in_store>
|
125 |
+
<fields>
|
126 |
+
<emails translate="label">
|
127 |
+
<label>Email Error Notifications</label>
|
128 |
+
<frontend_type>text</frontend_type>
|
129 |
+
<sort_order>1</sort_order>
|
130 |
+
<show_in_default>0</show_in_default>
|
131 |
+
<show_in_website>1</show_in_website>
|
132 |
+
<show_in_store>0</show_in_store>
|
133 |
+
<comment>Enter a list of email addresses separated by commas. (user1@domain.com,user2@domain.com,user3@otherdomain.com)</comment>
|
134 |
+
</emails>
|
135 |
+
</fields>
|
136 |
+
</notification>
|
137 |
+
<feedsenabled translate="label">
|
138 |
+
<label>Data Feeds</label>
|
139 |
+
<frontend_type>text</frontend_type>
|
140 |
+
<sort_order>5</sort_order>
|
141 |
+
<show_in_default>1</show_in_default>
|
142 |
+
<show_in_website>1</show_in_website>
|
143 |
+
<show_in_store>1</show_in_store>
|
144 |
+
<!--<expanded>1</expanded>-->
|
145 |
+
<!-- <comment>This comment goes on the top of the Group</comment> -->
|
146 |
+
<fields>
|
147 |
+
|
148 |
+
<notice translate="label">
|
149 |
+
<frontend_type>Text</frontend_type>
|
150 |
+
<frontend_model>mybuys/adminhtml_system_config_commentText</frontend_model> <!-- render comment as text -->
|
151 |
+
<comment><![CDATA[
|
152 |
+
To configure <b>Data Feeds</b>, please select a <b>website</b> scope from the <i>Current Configuration Scope</i> dropdown
|
153 |
+
]]>
|
154 |
+
</comment>
|
155 |
+
<sort_order>0</sort_order>
|
156 |
+
<show_in_default>1</show_in_default>
|
157 |
+
<show_in_website>0</show_in_website>
|
158 |
+
<show_in_store>1</show_in_store>
|
159 |
+
</notice>
|
160 |
+
|
161 |
+
<category translate="label">
|
162 |
+
<label>Category Feed</label>
|
163 |
+
<frontend_type>select</frontend_type>
|
164 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
165 |
+
<sort_order>0</sort_order>
|
166 |
+
<show_in_default>0</show_in_default>
|
167 |
+
<show_in_website>1</show_in_website>
|
168 |
+
<show_in_store>0</show_in_store>
|
169 |
+
</category>
|
170 |
+
<product translate="label">
|
171 |
+
<label>Product Feed</label>
|
172 |
+
<frontend_type>select</frontend_type>
|
173 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
174 |
+
<sort_order>2</sort_order>
|
175 |
+
<show_in_default>0</show_in_default>
|
176 |
+
<show_in_website>1</show_in_website>
|
177 |
+
<show_in_store>0</show_in_store>
|
178 |
+
</product>
|
179 |
+
<product_attributes translate="label">
|
180 |
+
<label>Product Custom Attributes</label>
|
181 |
+
<frontend_type>multiselect</frontend_type>
|
182 |
+
<source_model>mybuys/system_config_productAttributes</source_model>
|
183 |
+
<backend_model>mybuys/system_validate_productAttributes</backend_model>
|
184 |
+
<sort_order>3</sort_order>
|
185 |
+
<show_in_default>0</show_in_default>
|
186 |
+
<show_in_website>1</show_in_website>
|
187 |
+
<show_in_store>0</show_in_store>
|
188 |
+
<comment>Select up to 20 custom product attributes to include in product feed. If more than 20 items are selected, then only the first 20 will be saved and included in the feed.</comment>
|
189 |
+
</product_attributes>
|
190 |
+
<sku translate="label">
|
191 |
+
<label>SKU Feed</label>
|
192 |
+
<frontend_type>select</frontend_type>
|
193 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
194 |
+
<sort_order>4</sort_order>
|
195 |
+
<show_in_default>0</show_in_default>
|
196 |
+
<show_in_website>1</show_in_website>
|
197 |
+
<show_in_store>0</show_in_store>
|
198 |
+
</sku>
|
199 |
+
<transaction translate="label">
|
200 |
+
<label>Transactions Feed</label>
|
201 |
+
<frontend_type>select</frontend_type>
|
202 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
203 |
+
<sort_order>5</sort_order>
|
204 |
+
<show_in_default>0</show_in_default>
|
205 |
+
<show_in_website>1</show_in_website>
|
206 |
+
<show_in_store>0</show_in_store>
|
207 |
+
</transaction>
|
208 |
+
<crosssell translate="label">
|
209 |
+
<label>Cross Sells Feed</label>
|
210 |
+
<frontend_type>select</frontend_type>
|
211 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
212 |
+
<sort_order>6</sort_order>
|
213 |
+
<show_in_default>0</show_in_default>
|
214 |
+
<show_in_website>1</show_in_website>
|
215 |
+
<show_in_store>0</show_in_store>
|
216 |
+
</crosssell>
|
217 |
+
<rating translate="label">
|
218 |
+
<label>Ratings Feed</label>
|
219 |
+
<frontend_type>select</frontend_type>
|
220 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
221 |
+
<sort_order>7</sort_order>
|
222 |
+
<show_in_default>0</show_in_default>
|
223 |
+
<show_in_website>1</show_in_website>
|
224 |
+
<show_in_store>0</show_in_store>
|
225 |
+
</rating>
|
226 |
+
<email_optin translate="label">
|
227 |
+
<label>Email Opt-in Feed</label>
|
228 |
+
<frontend_type>select</frontend_type>
|
229 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
230 |
+
<sort_order>8</sort_order>
|
231 |
+
<show_in_default>0</show_in_default>
|
232 |
+
<show_in_website>1</show_in_website>
|
233 |
+
<show_in_store>0</show_in_store>
|
234 |
+
</email_optin>
|
235 |
+
<email_optout translate="label">
|
236 |
+
<label>Email Opt-out Feed</label>
|
237 |
+
<frontend_type>select</frontend_type>
|
238 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
239 |
+
<sort_order>9</sort_order>
|
240 |
+
<show_in_default>0</show_in_default>
|
241 |
+
<show_in_website>1</show_in_website>
|
242 |
+
<show_in_store>0</show_in_store>
|
243 |
+
</email_optout>
|
244 |
+
</fields>
|
245 |
+
</feedsenabled>
|
246 |
+
<advanced translate="label">
|
247 |
+
<label>Advanced Feed Configuration</label>
|
248 |
+
<frontend_type>text</frontend_type>
|
249 |
+
<sort_order>9</sort_order>
|
250 |
+
<show_in_default>0</show_in_default>
|
251 |
+
<show_in_website>1</show_in_website>
|
252 |
+
<show_in_store>0</show_in_store>
|
253 |
+
<fields>
|
254 |
+
<max_job_age translate="label">
|
255 |
+
<label>Maximum Job Age (Days)</label>
|
256 |
+
<frontend_type>text</frontend_type>
|
257 |
+
<sort_order>1</sort_order>
|
258 |
+
<show_in_default>0</show_in_default>
|
259 |
+
<show_in_website>1</show_in_website>
|
260 |
+
<show_in_store>0</show_in_store>
|
261 |
+
<comment>Maximum age for jobs in the data feed job queue. Jobs older than this number of days will be deleted</comment>
|
262 |
+
</max_job_age>
|
263 |
+
<throttle translate="label">
|
264 |
+
<label>Feed Gen Throttle</label>
|
265 |
+
<frontend_type>text</frontend_type>
|
266 |
+
<sort_order>2</sort_order>
|
267 |
+
<show_in_default>0</show_in_default>
|
268 |
+
<show_in_website>1</show_in_website>
|
269 |
+
<show_in_store>0</show_in_store>
|
270 |
+
<comment>Feed generation record count throttle parameter. Only this many records will be exported in a single job run. (0 = No throttling)</comment>
|
271 |
+
</throttle>
|
272 |
+
</fields>
|
273 |
+
</advanced>
|
274 |
+
</groups>
|
275 |
+
</mybuys_datafeeds>
|
276 |
+
|
277 |
+
<mybuys_websitecode translate="label" module="mybuys">
|
278 |
+
<label>MyBuys Website Code</label>
|
279 |
+
<tab>mybuys</tab>
|
280 |
+
<frontend_type>text</frontend_type>
|
281 |
+
<sort_order>3410</sort_order>
|
282 |
+
<show_in_default>1</show_in_default>
|
283 |
+
<show_in_website>1</show_in_website>
|
284 |
+
<show_in_store>1</show_in_store>
|
285 |
+
<groups>
|
286 |
+
<general translate="label">
|
287 |
+
<label>General</label>
|
288 |
+
<frontend_type>text</frontend_type>
|
289 |
+
<sort_order>1</sort_order>
|
290 |
+
<show_in_default>1</show_in_default>
|
291 |
+
<show_in_website>1</show_in_website>
|
292 |
+
<show_in_store>1</show_in_store>
|
293 |
+
<fields>
|
294 |
+
<identifier translate="label">
|
295 |
+
<label>Client Identifier</label>
|
296 |
+
<frontend_type>text</frontend_type>
|
297 |
+
<sort_order>0</sort_order>
|
298 |
+
<show_in_default>1</show_in_default>
|
299 |
+
<show_in_website>1</show_in_website>
|
300 |
+
<show_in_store>1</show_in_store>
|
301 |
+
<comment>Enter your client ID provided by MyBuys</comment>
|
302 |
+
</identifier>
|
303 |
+
<website_code translate="label">
|
304 |
+
<label>All Website Code</label>
|
305 |
+
<frontend_type>select</frontend_type>
|
306 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
307 |
+
<sort_order>1</sort_order>
|
308 |
+
<show_in_default>1</show_in_default>
|
309 |
+
<show_in_website>1</show_in_website>
|
310 |
+
<show_in_store>1</show_in_store>
|
311 |
+
<comment>Enable/disable website code</comment>
|
312 |
+
</website_code>
|
313 |
+
</fields>
|
314 |
+
</general>
|
315 |
+
<button translate="label">
|
316 |
+
<label>MyBuys Sign-Up Button</label>
|
317 |
+
<frontend_type>text</frontend_type>
|
318 |
+
<sort_order>3</sort_order>
|
319 |
+
<show_in_default>1</show_in_default>
|
320 |
+
<show_in_website>1</show_in_website>
|
321 |
+
<show_in_store>1</show_in_store>
|
322 |
+
<fields>
|
323 |
+
<mybuys_button translate="label">
|
324 |
+
<label>MyBuys Sign-Up Button</label>
|
325 |
+
<frontend_type>select</frontend_type>
|
326 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
327 |
+
<sort_order>3</sort_order>
|
328 |
+
<show_in_default>1</show_in_default>
|
329 |
+
<show_in_website>1</show_in_website>
|
330 |
+
<show_in_store>1</show_in_store>
|
331 |
+
<comment>Enable/disable MyBuys sign-up button</comment>
|
332 |
+
</mybuys_button>
|
333 |
+
</fields>
|
334 |
+
</button>
|
335 |
+
<recommendation translate="label">
|
336 |
+
<label>Recommendation Zones</label>
|
337 |
+
<frontend_type>text</frontend_type>
|
338 |
+
<sort_order>4</sort_order>
|
339 |
+
<show_in_default>1</show_in_default>
|
340 |
+
<show_in_website>1</show_in_website>
|
341 |
+
<show_in_store>1</show_in_store>
|
342 |
+
<fields>
|
343 |
+
<homepage translate="label">
|
344 |
+
<label>Homepage</label>
|
345 |
+
<frontend_type>select</frontend_type>
|
346 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
347 |
+
<sort_order>1</sort_order>
|
348 |
+
<show_in_default>1</show_in_default>
|
349 |
+
<show_in_website>1</show_in_website>
|
350 |
+
<show_in_store>1</show_in_store>
|
351 |
+
<comment>Enable/disable home recommendations</comment>
|
352 |
+
</homepage>
|
353 |
+
<cat_high translate="label">
|
354 |
+
<label>High Category Level</label>
|
355 |
+
<frontend_type>select</frontend_type>
|
356 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
357 |
+
<sort_order>2</sort_order>
|
358 |
+
<show_in_default>1</show_in_default>
|
359 |
+
<show_in_website>1</show_in_website>
|
360 |
+
<show_in_store>1</show_in_store>
|
361 |
+
<comment>Enable/disable high level category recommendations</comment>
|
362 |
+
</cat_high>
|
363 |
+
<cat_leaf translate="label">
|
364 |
+
<label>Leaf Level Category</label>
|
365 |
+
<frontend_type>select</frontend_type>
|
366 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
367 |
+
<sort_order>3</sort_order>
|
368 |
+
<show_in_default>1</show_in_default>
|
369 |
+
<show_in_website>1</show_in_website>
|
370 |
+
<show_in_store>1</show_in_store>
|
371 |
+
<comment>Enable/disable leaf level category recommendations</comment>
|
372 |
+
</cat_leaf >
|
373 |
+
<product_detail translate="label">
|
374 |
+
<label>Product Detail</label>
|
375 |
+
<frontend_type>select</frontend_type>
|
376 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
377 |
+
<sort_order>4</sort_order>
|
378 |
+
<show_in_default>1</show_in_default>
|
379 |
+
<show_in_website>1</show_in_website>
|
380 |
+
<show_in_store>1</show_in_store>
|
381 |
+
<comment>Enable/disable product detail recommendations</comment>
|
382 |
+
</product_detail>
|
383 |
+
<product_review translate="label">
|
384 |
+
<label>Product Review</label>
|
385 |
+
<frontend_type>select</frontend_type>
|
386 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
387 |
+
<sort_order>5</sort_order>
|
388 |
+
<show_in_default>1</show_in_default>
|
389 |
+
<show_in_website>1</show_in_website>
|
390 |
+
<show_in_store>1</show_in_store>
|
391 |
+
<comment>Enable/disable product detail recommendations</comment>
|
392 |
+
</product_review>
|
393 |
+
<search_results translate="label">
|
394 |
+
<label>Search Result</label>
|
395 |
+
<frontend_type>select</frontend_type>
|
396 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
397 |
+
<sort_order>6</sort_order>
|
398 |
+
<show_in_default>1</show_in_default>
|
399 |
+
<show_in_website>1</show_in_website>
|
400 |
+
<show_in_store>1</show_in_store>
|
401 |
+
<comment>Enable/disable search result recommendations</comment>
|
402 |
+
</search_results>
|
403 |
+
<add_to_cart translate="label">
|
404 |
+
<label>Add To Cart</label>
|
405 |
+
<frontend_type>select</frontend_type>
|
406 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
407 |
+
<sort_order>7</sort_order>
|
408 |
+
<show_in_default>1</show_in_default>
|
409 |
+
<show_in_website>1</show_in_website>
|
410 |
+
<show_in_store>1</show_in_store>
|
411 |
+
<comment>Enable/disable add-to-cart recommendations</comment>
|
412 |
+
</add_to_cart>
|
413 |
+
<!--
|
414 |
+
<wishlist translate="label">
|
415 |
+
<label>Wishlist</label>
|
416 |
+
<frontend_type>select</frontend_type>
|
417 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
418 |
+
<sort_order>8</sort_order>
|
419 |
+
<show_in_default>1</show_in_default>
|
420 |
+
<show_in_website>1</show_in_website>
|
421 |
+
<show_in_store>1</show_in_store>
|
422 |
+
<comment>Enable/disable wishlist recommendations</comment>
|
423 |
+
</wishlist>
|
424 |
+
-->
|
425 |
+
<checkout translate="label">
|
426 |
+
<label>Shopping Cart and Checkout</label>
|
427 |
+
<frontend_type>select</frontend_type>
|
428 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
429 |
+
<sort_order>9</sort_order>
|
430 |
+
<show_in_default>1</show_in_default>
|
431 |
+
<show_in_website>1</show_in_website>
|
432 |
+
<show_in_store>1</show_in_store>
|
433 |
+
<comment>Enable/disable checkout recommendations</comment>
|
434 |
+
</checkout>
|
435 |
+
<order_confirmation translate="label">
|
436 |
+
<label>Order Confirmaiton</label>
|
437 |
+
<frontend_type>select</frontend_type>
|
438 |
+
<source_model>mybuys/system_config_enableToggle</source_model>
|
439 |
+
<sort_order>10</sort_order>
|
440 |
+
<show_in_default>1</show_in_default>
|
441 |
+
<show_in_website>1</show_in_website>
|
442 |
+
<show_in_store>1</show_in_store>
|
443 |
+
<comment>Enable/disable order confirmation recommendations</comment>
|
444 |
+
</order_confirmation>
|
445 |
+
</fields>
|
446 |
+
</recommendation>
|
447 |
+
</groups>
|
448 |
+
</mybuys_websitecode>
|
449 |
+
</sections>
|
450 |
+
</config>
|
app/code/community/Mybuys/Connector/sql/mybuys_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MyBuys Magento Connector
|
4 |
+
*
|
5 |
+
* @category Mybuys
|
6 |
+
* @package Mybuys_Connector
|
7 |
+
* @website http://www.mybuys.com <http://www.mybuys.com/>
|
8 |
+
* @copyright Copyright (C) 2009-2012 MyBuys, Inc. All Rights Reserved.
|
9 |
+
*/
|
10 |
+
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
|
14 |
+
// Exports
|
15 |
+
$installer->run("
|
16 |
+
DROP TABLE IF EXISTS `mybuys_job`;
|
17 |
+
|
18 |
+
CREATE TABLE `mybuys_job` (
|
19 |
+
`job_id` int unsigned NOT NULL AUTO_INCREMENT,
|
20 |
+
`website_id` smallint(5) unsigned NOT NULL,
|
21 |
+
`dependent_on_job_id` int unsigned,
|
22 |
+
`min_entity_id` int unsigned,
|
23 |
+
`type` varchar(40) NOT NULL,
|
24 |
+
`feed_type` varchar(40) NOT NULL,
|
25 |
+
`status` int(11) NOT NULL,
|
26 |
+
`scheduled_at` datetime DEFAULT NULL,
|
27 |
+
`started_at` datetime DEFAULT NULL,
|
28 |
+
`ended_at` datetime DEFAULT NULL,
|
29 |
+
`error_message` varchar(64) NOT NULL,
|
30 |
+
PRIMARY KEY (`job_id`),
|
31 |
+
INDEX `indx_export_type` (`type`),
|
32 |
+
INDEX `indx_export_entity` (`feed_type`),
|
33 |
+
INDEX `indx_export_status` (`status`)
|
34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
35 |
+
");
|
36 |
+
|
37 |
+
$installer->endSetup();
|
38 |
+
|
app/design/adminhtml/default/default/layout/mybuys.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* StoreFront Consulting MyBuys Magento Module
|
5 |
+
*
|
6 |
+
* @category Mybuys
|
7 |
+
* @package Mybuys_Connector
|
8 |
+
* @author StoreFront Consulting, Inc.
|
9 |
+
* @website http://www.storefrontconsulting.com
|
10 |
+
* @copyright Copyright (C) 2009-2012 StoreFront Consulting, Inc. All Rights Reserved.
|
11 |
+
*/
|
12 |
+
-->
|
13 |
+
<layout version="0.1.0">
|
14 |
+
<mybuys_adminhtml_export_index>
|
15 |
+
<reference name="content">
|
16 |
+
<block type="mybuys/adminhtml_export" name="export" />
|
17 |
+
</reference>
|
18 |
+
</mybuys_adminhtml_export_index>
|
19 |
+
|
20 |
+
<mybuys_adminhtml_job_index>
|
21 |
+
<reference name="content">
|
22 |
+
<block type="mybuys/adminhtml_job" name="export" />
|
23 |
+
</reference>
|
24 |
+
</mybuys_adminhtml_job_index>
|
25 |
+
</layout>
|
app/design/frontend/base/default/layout/mybuys/websitecode.xml
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
|
4 |
+
<!-- DEFAULT -->
|
5 |
+
<default>
|
6 |
+
<reference name="head">
|
7 |
+
<block type="core/template" name="mybuys_head_links" before="-" template="mybuys/websitecode/header.phtml"/>
|
8 |
+
<action method="addCss"><stylesheet>css/recommendation_zone.css</stylesheet></action>
|
9 |
+
</reference>
|
10 |
+
<reference name="before_body_end">
|
11 |
+
<block type="core/template" name="mybuys_init" after="-" template="mybuys/websitecode/init.phtml"/>
|
12 |
+
</reference>
|
13 |
+
</default>
|
14 |
+
|
15 |
+
<!-- HOME PAGE -->
|
16 |
+
<cms_index_index>
|
17 |
+
<reference name="content">
|
18 |
+
<block type="core/template" name="mybuys_home" before="-" template="mybuys/websitecode/params/home.phtml" />
|
19 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_home.phtml" />
|
20 |
+
</reference>
|
21 |
+
</cms_index_index>
|
22 |
+
|
23 |
+
<!-- HIGH LEVEL CATEGORY -->
|
24 |
+
<catalog_category_layered translate="label">
|
25 |
+
<reference name="content">
|
26 |
+
<block type="catalog/product_list" name="mybuys_category_high" before="-" template="mybuys/websitecode/params/cat_high_level.phtml" />
|
27 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone_high" after="category.products" template="mybuys/websitecode/recomendationzone/zone_cat_high.phtml" />
|
28 |
+
</reference>
|
29 |
+
</catalog_category_layered>
|
30 |
+
|
31 |
+
<!-- LEAF CATEGORY -->
|
32 |
+
<catalog_category_layered_nochildren translate="label">
|
33 |
+
<reference name="content">
|
34 |
+
<remove name="mybuys_category_high"/>
|
35 |
+
<remove name="mybuys_recomendationzone_high"/>
|
36 |
+
<block type="catalog/product_list" name="mybuys_category_leaf" before="-" template="mybuys/websitecode/params/cat_leaf.phtml" />
|
37 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone_leaf" after="category.products" template="mybuys/websitecode/recomendationzone/zone_cat_leaf.phtml" />
|
38 |
+
</reference>
|
39 |
+
</catalog_category_layered_nochildren>
|
40 |
+
|
41 |
+
<!-- PRODUCT VIEW -->
|
42 |
+
<catalog_product_view translate="label">
|
43 |
+
<reference name="content">
|
44 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_product_detail.phtml" />
|
45 |
+
<block type="enterprise_targetrule/catalog_product_list_related" name="mybuys_targetrule_related" before="-" template="mybuys/websitecode/params/target_rule_related.phtml" />
|
46 |
+
<block type="enterprise_targetrule/catalog_product_list_upsell" name="mybuys_targetrule_upsell" before="-" template="mybuys/websitecode/params/target_rule_upsell.phtml" />
|
47 |
+
<block type="mybuys/category" name="mybuys_product_view" before="-" template="mybuys/websitecode/params/product.phtml" />
|
48 |
+
</reference>
|
49 |
+
<reference name="product.info.addto">
|
50 |
+
<action method="setTemplate"><template>mybuys/websitecode/button.phtml</template></action>
|
51 |
+
</reference>
|
52 |
+
</catalog_product_view>
|
53 |
+
|
54 |
+
<!-- PRODUCT REVIEW -->
|
55 |
+
<review_product_list translate="label">
|
56 |
+
<reference name="content">
|
57 |
+
<block type="mybuys/category" name="mybuys_product_review" before="-" template="mybuys/websitecode/params/product_review.phtml" />
|
58 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_product_review.phtml" />
|
59 |
+
</reference>
|
60 |
+
</review_product_list>
|
61 |
+
|
62 |
+
<!-- SEARCH RESULT -->
|
63 |
+
<catalogsearch_result_index translate="label">
|
64 |
+
<reference name="content">
|
65 |
+
<block type="catalog/product_list" name="mybuys_search" before="-" template="mybuys/websitecode/params/search.phtml" />
|
66 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_search_result.phtml" />
|
67 |
+
</reference>
|
68 |
+
</catalogsearch_result_index>
|
69 |
+
|
70 |
+
<!-- SHOPPING CART -->
|
71 |
+
<checkout_cart_index translate="label">
|
72 |
+
<reference name="content">
|
73 |
+
<block type="mybuys/category" name="mybuys_cart" before="-" template="mybuys/websitecode/params/checkout.phtml" />
|
74 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_checkout.phtml" />
|
75 |
+
</reference>
|
76 |
+
</checkout_cart_index>
|
77 |
+
|
78 |
+
<!-- WISHLIST -->
|
79 |
+
<wishlist_index_index translate="label">
|
80 |
+
<reference name="content">
|
81 |
+
<block type="core/template" name="mybuys_wishlist" before="-" template="mybuys/websitecode/params/wishlist.phtml" />
|
82 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_wishlist.phtml" />
|
83 |
+
</reference>
|
84 |
+
</wishlist_index_index>
|
85 |
+
|
86 |
+
<!-- CHECKOUT ONEPAGE -->
|
87 |
+
<checkout_onepage_index translate="label">
|
88 |
+
<reference name="content">
|
89 |
+
<block type="mybuys/category" name="mybuys_checkout" after="-" template="mybuys/websitecode/params/checkout.phtml" />
|
90 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_checkout.phtml" />
|
91 |
+
</reference>
|
92 |
+
</checkout_onepage_index>
|
93 |
+
|
94 |
+
<!-- CHECKOUT ONEPAGE SUCCESS -->
|
95 |
+
<checkout_onepage_success translate="label">
|
96 |
+
<reference name="content">
|
97 |
+
<block type="mybuys/category" name="mybuys_success" after="-" template="mybuys/websitecode/params/confirmation.phtml" />
|
98 |
+
<block type="mybuys/zone" name="mybuys_recomendationzone" after="-" template="mybuys/websitecode/recomendationzone/zone_order_confirmation.phtml" />
|
99 |
+
</reference>
|
100 |
+
</checkout_onepage_success>
|
101 |
+
|
102 |
+
|
103 |
+
</layout>
|
104 |
+
|
105 |
+
|
app/design/frontend/base/default/template/mybuys/websitecode/button.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $_product = $this->getProduct(); ?>
|
2 |
+
<ul class="add-to-links">
|
3 |
+
|
4 |
+
<?php // wish list may not exist in some old Magento versions, so test for it ?>
|
5 |
+
<?php if(method_exists($this->helper('wishlist'),'getAddUrl')) : ?>
|
6 |
+
<?php $_wishlistSubmitUrl = $this->helper('wishlist')->getAddUrl($_product); ?>
|
7 |
+
<?php if ($this->helper('wishlist')->isAllow()) : ?>
|
8 |
+
<li><a href="<?php echo $_wishlistSubmitUrl ?>" onclick="productAddToCartForm.submitLight(this, this.href); return false;" class="link-compare"><?php echo $this->__('Update Wishlist') ?></a></li>
|
9 |
+
<?php endif; ?>
|
10 |
+
<?php endif; ?>
|
11 |
+
|
12 |
+
<?php $_compareUrl = $this->helper('catalog/product_compare')->getAddUrl($_product); ?>
|
13 |
+
<?php if($_compareUrl) : ?>
|
14 |
+
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
|
15 |
+
<?php endif; ?>
|
16 |
+
</ul>
|
app/design/frontend/base/default/template/mybuys/websitecode/header.phtml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php if (Mage::app()->getStore()->isCurrentlySecure()) : ?>
|
3 |
+
<link href="https://t.p.mybuys.com/css/mbstyles.css" type="text/css" rel="stylesheet" id="mybuysstyles" />
|
4 |
+
<script type="text/javascript" src="https://t.p.mybuys.com/js/mybuys3.js"></script>
|
5 |
+
<script type="text/javascript" src="https://t.p.mybuys.com/clients/<?php echo Mage::getStoreConfig('mybuys_websitecode/general/identifier'); ?>/js/setup.js"></script>
|
6 |
+
<?php else : ?>
|
7 |
+
<link href="http://t.p.mybuys.com/css/mbstyles.css" type="text/css" rel="stylesheet" id="mybuysstyles" />
|
8 |
+
<script type="text/javascript" src="http://t.p.mybuys.com/js/mybuys3.js"></script>
|
9 |
+
<script type="text/javascript" src="http://t.p.mybuys.com/clients/<?php echo Mage::getStoreConfig('mybuys_websitecode/general/identifier'); ?>/js/setup.js"></script>
|
10 |
+
<?php endif; ?>
|
11 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/init.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<script type="text/javascript">
|
3 |
+
mybuys.initPage();
|
4 |
+
</script>
|
5 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/cat_high_level.phtml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php $collection = $this->getLoadedProductCollection(); ?>
|
3 |
+
<?php $catId = Mage::getSingleton('catalog/layer')->getCurrentCategory()->getId(); ?>
|
4 |
+
<script type="text/javascript">
|
5 |
+
mybuys.setPageType("HIGH_LEVEL_CATEGORY");
|
6 |
+
mybuys.set("categoryid","<?php echo $catId; ?>");
|
7 |
+
</script>
|
8 |
+
|
9 |
+
<?php if(Mage::getStoreConfig('mybuys_websitecode/recommendation/recommendation') && Mage::getStoreConfig('mybuys_websitecode/recommendation/cat_high') && count($collection)>0 ) : ?>
|
10 |
+
<script type="text/javascript">
|
11 |
+
<?php
|
12 |
+
foreach ($collection as $product)
|
13 |
+
{
|
14 |
+
echo 'mybuys.addItemPresentOnPage("'.$product->getId().'");';
|
15 |
+
}
|
16 |
+
?>
|
17 |
+
</script>
|
18 |
+
<?php endif; ?>
|
19 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/cat_leaf.phtml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php $collection = $this->getLoadedProductCollection(); ?>
|
3 |
+
<?php $catId = Mage::getSingleton('catalog/layer')->getCurrentCategory()->getId(); ?>
|
4 |
+
|
5 |
+
<script type="text/javascript">
|
6 |
+
mybuys.setPageType("CATEGORY");
|
7 |
+
mybuys.set("categoryid","<?php echo $catId; ?>");
|
8 |
+
</script>
|
9 |
+
|
10 |
+
<?php if(Mage::getStoreConfig('mybuys_websitecode/recommendation/recommendation') && Mage::getStoreConfig('mybuys_websitecode/recommendation/cat_leaf') && count($collection)>0 ) : ?>
|
11 |
+
<script type="text/javascript">
|
12 |
+
<?php
|
13 |
+
foreach ($collection as $product)
|
14 |
+
{
|
15 |
+
echo 'mybuys.addItemPresentOnPage("'.$product->getId().'");';
|
16 |
+
}
|
17 |
+
?>
|
18 |
+
</script>
|
19 |
+
<?php endif; ?>
|
20 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/checkout.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php $_quote = Mage::getSingleton('checkout/session')->getQuote(); ?>
|
3 |
+
<?php $orderEmail = $_quote->getCustomerEmail(); ?>
|
4 |
+
<?php $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($orderEmail); ?>
|
5 |
+
<?php $_totals = $_quote->getTotals(); ?>
|
6 |
+
<?php $_subtotal = $_totals["subtotal"]->getValue(); ?>
|
7 |
+
|
8 |
+
<script type="text/javascript">
|
9 |
+
mybuys.setPageType("SHOPPING_CART");
|
10 |
+
mybuys.set("email","<?php echo $orderEmail ?>");
|
11 |
+
mybuys.set("amount","<?php echo money_format('%.2n',$_subtotal) ?>");
|
12 |
+
mybuys.set("optin","<?php echo $subscriber->isSubscribed()?"y":"n";?>");
|
13 |
+
</script>
|
14 |
+
|
15 |
+
<script type="text/javascript">
|
16 |
+
<?php $cartItems = $_quote->getAllItems(); ?>
|
17 |
+
<?php foreach ($cartItems as $item) : ?>
|
18 |
+
<?php $product = $item->getProduct(); ?>
|
19 |
+
<?php if($item->getParentItem()) : ?>
|
20 |
+
<?php if($item->getParentItem()->getProduct()->getTypeId() == 'bundle') : ?>
|
21 |
+
mybuys.addCartItemQtySubtotal("<?php echo $product->getId(); ?>","<?php echo $item->getQty(); ?>","0.00");
|
22 |
+
<?php else: ?>
|
23 |
+
mybuys.addCartItemQtySubtotal("<?php echo $product->getId(); ?>","<?php echo $item->getQty(); ?>","<?php echo money_format('%.2n',$item->getRowTotal()); ?>");
|
24 |
+
<?php endif; ?>
|
25 |
+
<?php else: ?>
|
26 |
+
mybuys.addCartItemQtySubtotal("<?php echo $product->getId(); ?>","<?php echo $item->getQty(); ?>","<?php echo money_format('%.2n',$item->getRowTotal()); ?>");
|
27 |
+
<?php endif; ?>
|
28 |
+
<?php endforeach; ?>
|
29 |
+
</script>
|
30 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/confirmation.phtml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php $_orderId = Mage::getSingleton('checkout/session')->getLastOrderId(); ?>
|
3 |
+
<?php $_order = Mage::getModel('sales/order')->load($_orderId); ?>
|
4 |
+
<?php $orderEmail = $_order->getCustomerEmail(); ?>
|
5 |
+
<?php $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($orderEmail); ?>
|
6 |
+
<?php $_items = $_order->getAllItems(); ?>
|
7 |
+
|
8 |
+
<script type="text/javascript">
|
9 |
+
mybuys.setPageType("ORDER_CONFIRMATION");
|
10 |
+
mybuys.set("email","<?php echo $orderEmail; ?>");
|
11 |
+
mybuys.set("orderid","<?php echo $_orderId ?>");
|
12 |
+
mybuys.set("amount","<?php echo money_format('%.2n',$_order->getSubtotal()); ?>");
|
13 |
+
mybuys.set("optin","<?php echo $subscriber->isSubscribed()?"y":"n";?>");
|
14 |
+
</script>
|
15 |
+
|
16 |
+
<?php $version = explode(".",Mage::getVersion()); ?>
|
17 |
+
|
18 |
+
<?php if ($version[1] == 7 || $version[1] == 12 ) : ?>
|
19 |
+
<script type="text/javascript">
|
20 |
+
<?php foreach($_items as $item) : ?>
|
21 |
+
<?php $product = $item->getProduct(); ?>
|
22 |
+
<?php if($item->getParentItem()) : ?>
|
23 |
+
<?php if($item->getParentItem()->getProductType() == 'bundle') : ?>
|
24 |
+
mybuys.addOrderItemQtySubtotal("<?php echo $product->getId() ?>","<?php echo (int)$item->getQtyOrdered() ?>","0.00");
|
25 |
+
<?php else: ?>
|
26 |
+
mybuys.addOrderItemQtySubtotal("<?php echo $product->getId() ?>","<?php echo (int)$item->getQtyOrdered() ?>","<?php echo money_format('%.2n',$item->getRowTotal()); ?>");
|
27 |
+
<?php endif; ?>
|
28 |
+
<?php else: ?>
|
29 |
+
mybuys.addOrderItemQtySubtotal("<?php echo $product->getId() ?>","<?php echo (int)$item->getQtyOrdered() ?>","<?php echo money_format('%.2n',$item->getRowTotal()); ?>");
|
30 |
+
<?php endif; ?>
|
31 |
+
<?php endforeach; ?>
|
32 |
+
</script>
|
33 |
+
|
34 |
+
<?php else: ?>
|
35 |
+
<script type="text/javascript">
|
36 |
+
<?php foreach($_items as $item) : ?>
|
37 |
+
<?php $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$item->getSku()); ?>
|
38 |
+
<?php if($item->getParentItem()) : ?>
|
39 |
+
<?php if($item->getParentItem()->getProductType() == 'bundle') : ?>
|
40 |
+
mybuys.addOrderItemQtySubtotal("<?php echo $item->getProductId(); ?>","<?php echo (int)$item->getQtyOrdered() ?>","0.00");
|
41 |
+
<?php else: ?>
|
42 |
+
mybuys.addOrderItemQtySubtotal("<?php echo $item->getProductId(); ?>","<?php echo (int)$item->getQtyOrdered() ?>","<?php echo money_format('%.2n',$item->getRowTotal()); ?>");
|
43 |
+
<?php endif; ?>
|
44 |
+
<?php else: ?>
|
45 |
+
mybuys.addOrderItemQtySubtotal("<?php echo $item->getProductId(); ?>","<?php echo (int)$item->getQtyOrdered() ?>","<?php echo money_format('%.2n',$item->getRowTotal()); ?>");
|
46 |
+
<?php endif; ?>
|
47 |
+
<?php endforeach; ?>
|
48 |
+
</script>
|
49 |
+
<?php endif; ?>
|
50 |
+
|
51 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/home.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<script type="text/javascript">
|
3 |
+
mybuys.setPageType("HOME");
|
4 |
+
</script>
|
5 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/product.phtml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php $currentProduct = Mage::registry('current_product'); ?>
|
3 |
+
<?php $relatedProducts = $currentProduct->getRelatedProductCollection(); ?>
|
4 |
+
<?php $upsell_products = $currentProduct->getUpSellProductCollection(); ?>
|
5 |
+
<?php if(Mage::getStoreConfig('catalog/frontend/flat_catalog_product') != true){
|
6 |
+
$relatedProducts->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)->addStoreFilter();
|
7 |
+
$upsell_products->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)->addStoreFilter();
|
8 |
+
} ?>
|
9 |
+
|
10 |
+
<script type="text/javascript">
|
11 |
+
mybuys.setPageType("PRODUCT_DETAILS");
|
12 |
+
mybuys.set("productid","<?php echo $currentProduct->getId() ?>");
|
13 |
+
</script>
|
14 |
+
|
15 |
+
<script type="text/javascript">
|
16 |
+
/* current product being viewed */
|
17 |
+
mybuys.addItemPresentOnPage("<?php echo $currentProduct->getId() ?>");
|
18 |
+
</script>
|
19 |
+
<?php $version = explode(".",Mage::getVersion()); ?>
|
20 |
+
<?php if ($version[1] <= 7 ) : ?>
|
21 |
+
<?php if($this->zoneEnabled()) : ?>
|
22 |
+
<script type="text/javascript">
|
23 |
+
/* related products */
|
24 |
+
mybuys.addItemPresentOnPage("<?php echo $currentProduct->getId() ?>");
|
25 |
+
<?php foreach ($relatedProducts as $product) : ?>
|
26 |
+
<?php if($product->isVisibleInCatalog()) : ?>
|
27 |
+
mybuys.addItemPresentOnPage("<?php echo $product->getId() ?>");
|
28 |
+
<?php endif; ?>
|
29 |
+
<?php endforeach; ?>
|
30 |
+
/* end related products */
|
31 |
+
/* upsell products */
|
32 |
+
<?php foreach ($upsell_products as $product) : ?>
|
33 |
+
<?php if($product->isVisibleInCatalog()) : ?>
|
34 |
+
mybuys.addItemPresentOnPage("<?php echo $product->getId() ?>");
|
35 |
+
<?php endif; ?>
|
36 |
+
<?php endforeach; ?>
|
37 |
+
/* end upsell products */
|
38 |
+
</script>
|
39 |
+
<?php endif; ?>
|
40 |
+
<?php endif; ?>
|
41 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/product_review.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<?php $productId = Mage::registry('current_product')->getId(); ?>
|
3 |
+
<script type="text/javascript">
|
4 |
+
mybuys.setPageType("RATINGS");
|
5 |
+
mybuys.set("productID","<?php echo $productId ?>");
|
6 |
+
</script>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/search.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
|
3 |
+
<?php $mb_collection = $this->getLoadedProductCollection(); ?>
|
4 |
+
<?php $mb_searchResult = Mage::helper('catalogsearch')->getEscapedQueryText(); ?>
|
5 |
+
<script type="text/javascript">
|
6 |
+
mybuys.setPageType("SEARCH_RESULTS");
|
7 |
+
mybuys.set("keywords", "<?php echo $mb_searchResult; ?>");
|
8 |
+
</script>
|
9 |
+
|
10 |
+
<script type="text/javascript">
|
11 |
+
<?php foreach ($mb_collection as $_product) : ?>
|
12 |
+
mybuys.addItemPresentOnPage("<?php echo $_product->getId(); ?>");
|
13 |
+
<?php endforeach; ?>
|
14 |
+
</script>
|
15 |
+
|
16 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/target_rule_related.phtml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $version = explode(".",Mage::getVersion()); ?>
|
2 |
+
<?php if ($version[1] > 7 ) : ?>
|
3 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
4 |
+
<script type="text/javascript">
|
5 |
+
/* related products on page */
|
6 |
+
<?php foreach($this->getItemCollection() as $_item): ?>
|
7 |
+
<?php if($_item->isVisibleInCatalog()) : ?>
|
8 |
+
mybuys.addItemPresentOnPage("<?php echo $_item->getId() ?>");
|
9 |
+
<?php endif; ?>
|
10 |
+
<?php endforeach; ?>
|
11 |
+
</script>
|
12 |
+
<?php endif; ?>
|
13 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/target_rule_upsell.phtml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $version = explode(".",Mage::getVersion()); ?>
|
2 |
+
<?php if ($version[1] > 7 ) : ?>
|
3 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
4 |
+
<script type="text/javascript">
|
5 |
+
/* upsell products on page */
|
6 |
+
<?php foreach($this->getItemCollection() as $_item): ?>
|
7 |
+
<?php if($_item->isVisibleInCatalog()) : ?>
|
8 |
+
mybuys.addItemPresentOnPage("<?php echo $_item->getId() ?>");
|
9 |
+
<?php endif; ?>
|
10 |
+
<?php endforeach; ?>
|
11 |
+
</script>
|
12 |
+
<?php endif; ?>
|
13 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/params/wishlist.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (Mage::getStoreConfig('mybuys_websitecode/general/website_code') == 'enabled') : ?>
|
2 |
+
<script type="text/javascript">
|
3 |
+
mybuys.setPageType("MY_PAGE");
|
4 |
+
</script>
|
5 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_add_to_cart.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('add_to_cart')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_cat_high.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('cat_high')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_cat_leaf.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('cat_leaf')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_checkout.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('checkout')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_home.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('homepage')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_order_confirmation.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('order_confirmation')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_product_detail.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('product_detail')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_product_review.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('product_review')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_search_result.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('search_results')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/mybuys/websitecode/recomendationzone/zone_wishlist.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->zonesEnabled() && $this->getZoneStatus('wishlist')) : ?>
|
2 |
+
<div id="recommendation-zone-wrapper">
|
3 |
+
<!-- MyBuys Web Recommendation Zone -->
|
4 |
+
<div mybuyszone="1"></div>
|
5 |
+
<!-- End MyBuys Web Recommendation Zone -->
|
6 |
+
</div>
|
7 |
+
<?php endif; ?>
|
app/etc/modules/Mybuys_Connector.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Mybuys_Connector>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>1.0.7</version>
|
8 |
+
</Mybuys_Connector>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>MyBuys_Personalization_Extension</name>
|
4 |
+
<version>1.0.9</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Commercial Software License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>MyBuys Website Code & Data Feed Integration</summary>
|
10 |
+
<description>MyBuys Website Code & Data Feed Integration</description>
|
11 |
+
<notes>MyBuys Website Code & Data Feed Integration</notes>
|
12 |
+
<authors><author><name>Greg Croasdill</name><user>groggu</user><email>gregc@human-element.com</email></author></authors>
|
13 |
+
<date>2013-06-06</date>
|
14 |
+
<time>17:13:36</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Mybuys"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="Export"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="4056faae479f352288851a8fc1eb447b"/></dir></dir><file name="Grid.php" hash="5f520715c3cfa6bf87ab2b463098a30b"/></dir><file name="Export.php" hash="1f06f862f7566bc8c165daf7f0facbc7"/><dir name="Job"><file name="Grid.php" hash="13e933e78627574e5ed1bb5bdb64a746"/></dir><file name="Job.php" hash="d13d344495fa89bdcff21a5f0f53b862"/><dir name="System"><dir name="Config"><file name="CommentText.php" hash="db2cc6c36627fee8064b7b7a59d8957a"/><file name="Date.php" hash="2dc607fa0895ba8b88c2dff7805f96b1"/><dir name="Form"><dir name="Field"><file name="Date.php" hash="302347c855b30cc11045d3de9ba137aa"/></dir></dir></dir></dir></dir><file name="Category.php" hash="79cb522bd8edfc6b03e01ba60363c9f2"/><file name="Zone.php" hash="786209aa1dbe54a837336e332ede80c2"/></dir><dir name="Helper"><file name="Data.php" hash="03bb78727c25d9288511bb2547ac4b96"/><file name="SftpConnection.php" hash="c8e6d57971e7098279aead19af301f19"/><file name="Tsvfile.php" hash="37e394160868890f10f759119da612da"/></dir><dir name="Model"><dir name="Feed"><file name="Base.php" hash="41e674c3dace9560c1c6ef6741a6705e"/><file name="Category.php" hash="e77711c3264c8adf940d7cd818bd155a"/><file name="Crosssell.php" hash="6326f873bd6f8101e1761528a04c1e2e"/><dir name="Email"><file name="Optin.php" hash="a162449f61473bf99d0bbcaeda170725"/><file name="Optout.php" hash="02fd55fb25eb9a3d8ae8a94be63d4f09"/></dir><file name="Product.php" hash="01bcf8bd051986142431bdc3769137cf"/><file name="Rating.php" hash="afa2525e2e6445b8be37cb8ed1e8cd7b"/><file name="Sku.php" hash="0fc043ea0a096484da9a08d5d27243ee"/><file name="Transaction.php" hash="ac71f59f121f9bd3da90d323efa6d659"/></dir><file name="Generatefeeds.php" hash="9f590d931966486761d52891042973bd"/><file name="Job.php" hash="1784faa53fe78fab5f723a8d8e41d9db"/><dir name="Mysql4"><dir name="Job"><file name="Collection.php" hash="9990fbd66abbfc6ceaa621178fb4e660"/></dir><file name="Job.php" hash="9701e2bd09c20230d72bd4f2ada0644d"/></dir><file name="Observer.php" hash="c91c7653b5885658217f428f432e1469"/><dir name="System"><dir name="Config"><file name="EnableToggle.php" hash="abefbe5e7e238cb8f30c10e9a7ab41f7"/><file name="ProductAttributes.php" hash="cf51c552ec604cf97832e43a38341e35"/></dir><dir name="Validate"><file name="ProductAttributes.php" hash="4c6720eb5358df9ceb0ba2aca828a76a"/></dir></dir><file name="Transferfeeds.php" hash="b3b5e1fe70f5579a2b966b7d379c22ca"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="3510e2bddcec137a8a70c4cb2630d5dd"/><file name="JobController.php" hash="ec8f487f0f6d5c24e55cd97ebcc6019e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="4be070d4ce9036999d45688d10e7ce1b"/><file name="config.xml" hash="0580ddf7d6de000aa04ff6601dd54b81"/><file name="system.xml" hash="bdfc121691ed9da965cc8cd261ded5e9"/></dir><dir name="sql"><dir name="mybuys_setup"><file name="mysql4-install-0.1.0.php" hash="b6bac0c8b7114d2ea82ec475b04f79cf"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mybuys_Connector.xml" hash="272d35663d0041a35d06e84efe590f22"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="recommendation_zone.css" hash="95918555ee7ccbc6e40743891eafe394"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mybuys.xml" hash="3f89770cb6104ae758199745a621c933"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="mybuys"><file name="websitecode.xml" hash="1cd86dee003a2d704a5b8c2d3041608f"/></dir></dir><dir name="template"><dir name="mybuys"><dir name="websitecode"><file name="button.phtml" hash="ba0c05073295c03e68a6a66da14e366d"/><file name="header.phtml" hash="dba97f865250cbd90e0426242401f673"/><file name="init.phtml" hash="8ee89b0e9c240e4ebd31b83aa344b564"/><dir name="params"><file name="cat_high_level.phtml" hash="f552d4289a057ccd482bcc6d4545da60"/><file name="cat_leaf.phtml" hash="ee14b555386fc925528fd92f2610293d"/><file name="checkout.phtml" hash="3cd6fdd56a123d926e98e660c19e33c7"/><file name="confirmation.phtml" hash="a79f164398e53cc907ccf322b7653e83"/><file name="home.phtml" hash="c4d8335c1f22dbf0cca4b5dab1a08a07"/><file name="product.phtml" hash="0b599ca72c82820901ce52bc74545f64"/><file name="product_review.phtml" hash="0e60d20e757f6e2ad2edbb39d5e1bc3e"/><file name="search.phtml" hash="be7b8cb51dfe49b31a9fafc0483b4805"/><file name="target_rule_related.phtml" hash="542669310cbd16d70d477b25fd014129"/><file name="target_rule_upsell.phtml" hash="6e2d929139d38d18e30bf9976cb91080"/><file name="wishlist.phtml" hash="e1ff61f7239ff9bd51e03b2b03c967ea"/></dir><dir name="recomendationzone"><file name="zone_add_to_cart.phtml" hash="b1e2751108e0d6e8133cdbeaced2a255"/><file name="zone_cat_high.phtml" hash="f0e64b8f75daa395f6c5df5dcf8cc8b3"/><file name="zone_cat_leaf.phtml" hash="633c51ae079174086c9ae9b1a8686c3a"/><file name="zone_checkout.phtml" hash="9c358c3d1357c976da67716ef4c5c5f6"/><file name="zone_home.phtml" hash="8694c9ceab4321800fff8859333aaee1"/><file name="zone_order_confirmation.phtml" hash="1634f70d7913bfb45a5f13d412804295"/><file name="zone_product_detail.phtml" hash="858aac3194c854a0dd71908e3702cd21"/><file name="zone_product_review.phtml" hash="6c5a12fd9ee2d9e0e48816517e9205dd"/><file name="zone_search_result.phtml" hash="5dc464f4cd9e0d16ccf7415dfa0dfe3a"/><file name="zone_wishlist.phtml" hash="a1f19396df0eb67c86f7f609cfffdc79"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/base/default/css/recommendation_zone.css
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#recommendation-zone-wrapper {
|
2 |
+
text-align:center;
|
3 |
+
margin:auto;padding:10px;
|
4 |
+
float:left; width:100%;
|
5 |
+
margin-top:20px;
|
6 |
+
margin:auto;
|
7 |
+
}
|