Version Notes
MAJOR HIGHLIGHTS AND IMPROVEMENTS
- Compatible with Magento Enterprise versions 1.11.x to 1.14.x
- Performance increased
FIXES
- Access Control List issue
- Issues fixed to enhance performance
Download this release
Release Info
Developer | Amar |
Extension | Reflektion_Individualization_Extension |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.5
- app/code/community/Reflektion/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export.php +21 -11
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/Grid.php +107 -70
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/Grid/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/Grid/Renderer/Action.php +18 -9
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Job.php +14 -6
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Job/Grid.php +134 -81
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/System/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/System/Config/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Block/Adminhtml/System/Config/CommentText.php +10 -5
- app/code/community/Reflektion/Catalogexport/Helper/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Helper/Csvfile.php +56 -31
- app/code/community/Reflektion/Catalogexport/Helper/Data.php +49 -27
- app/code/community/Reflektion/Catalogexport/Helper/SftpConnection.php +132 -49
- app/code/community/Reflektion/Catalogexport/Model/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Model/Feed/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Model/Feed/Base.php +116 -55
- app/code/community/Reflektion/Catalogexport/Model/Feed/Product.php +71 -58
- app/code/community/Reflektion/Catalogexport/Model/Generatefeeds.php +37 -22
- app/code/community/Reflektion/Catalogexport/Model/Job.php +205 -87
- app/code/community/Reflektion/Catalogexport/Model/Layout.php +11 -8
- app/code/community/Reflektion/Catalogexport/Model/Mysql4/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Model/Mysql4/Job.php +9 -5
- app/code/community/Reflektion/Catalogexport/Model/Mysql4/Job/Collection.php +9 -5
- app/code/community/Reflektion/Catalogexport/Model/Observer.php +132 -39
- app/code/community/Reflektion/Catalogexport/Model/System/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/Model/System/Config/Cron.php +26 -15
- app/code/community/Reflektion/Catalogexport/Model/System/Config/EnableToggle.php +18 -7
- app/code/community/Reflektion/Catalogexport/Model/System/Config/ProductAttributes.php +18 -14
- app/code/community/Reflektion/Catalogexport/Model/System/Validate/ProductAttributes.php +20 -10
- app/code/community/Reflektion/Catalogexport/Model/Transferfeeds.php +131 -47
- app/code/community/Reflektion/Catalogexport/controllers/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/controllers/Adminhtml/ExportController.php +56 -15
- app/code/community/Reflektion/Catalogexport/controllers/Adminhtml/JobController.php +94 -48
- app/code/community/Reflektion/Catalogexport/etc/adminhtml.xml +4 -1
- app/code/community/Reflektion/Catalogexport/etc/config.xml +1 -1
- app/code/community/Reflektion/Catalogexport/etc/system.xml +2 -2
- app/code/community/Reflektion/Catalogexport/sql/.DS_Store +0 -0
- app/code/community/Reflektion/Catalogexport/sql/reflektion_setup/mysql4-install-1.0.0.php +103 -23
- app/etc/modules/Reflektion_Catalogexport.xml +1 -1
- package.xml +24 -15
app/code/community/Reflektion/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export.php
CHANGED
@@ -8,28 +8,38 @@
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Admin export grid layout load
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Block_Adminhtml_Export extends Mage_Adminhtml_Block_Widget_Grid_Container
|
|
|
12 |
|
13 |
-
public function __construct() {
|
14 |
|
|
|
|
|
15 |
$this->_controller = "adminhtml_export";
|
16 |
$this->_blockGroup = "reflektion";
|
17 |
$this->_headerText = Mage::helper("reflektion")->__("Generate Data Feeds");
|
18 |
parent::__construct();
|
19 |
-
}
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
// Remove add button
|
23 |
$this->_removeButton('add');
|
24 |
|
25 |
// Export all button
|
26 |
-
$this->_addButton(
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
return parent::_prepareLayout();
|
33 |
-
}
|
34 |
|
35 |
-
}
|
|
|
|
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Admin export grid layout load
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Block_Adminhtml_Export extends Mage_Adminhtml_Block_Widget_Grid_Container
|
12 |
+
{
|
13 |
|
|
|
14 |
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
$this->_controller = "adminhtml_export";
|
18 |
$this->_blockGroup = "reflektion";
|
19 |
$this->_headerText = Mage::helper("reflektion")->__("Generate Data Feeds");
|
20 |
parent::__construct();
|
|
|
21 |
|
22 |
+
}//end __construct()
|
23 |
+
|
24 |
+
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
// Remove add button
|
28 |
$this->_removeButton('add');
|
29 |
|
30 |
// Export all button
|
31 |
+
$this->_addButton(
|
32 |
+
'exportall',
|
33 |
+
array(
|
34 |
+
'label' => 'Export Feeds For All Sites',
|
35 |
+
'onclick' => 'setLocation(\''.$this->getUrl('*/*/exportall').'\')',
|
36 |
+
'class' => 'exportall',
|
37 |
+
)
|
38 |
+
);
|
39 |
|
40 |
return parent::_prepareLayout();
|
|
|
41 |
|
42 |
+
}//end _prepareLayout()
|
43 |
+
|
44 |
+
|
45 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/Grid.php
CHANGED
@@ -6,18 +6,24 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Prepare collection and select columns
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Block_Adminhtml_Export_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
parent::__construct();
|
15 |
$this->setId("exportGrid");
|
16 |
$this->setDefaultDir("ASC");
|
17 |
$this->setSaveParametersInSession(true);
|
18 |
-
}
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
// Collection for each data feed for each website
|
22 |
$collection = new Varien_Data_Collection();
|
23 |
|
@@ -25,88 +31,119 @@ class Reflektion_Catalogexport_Block_Adminhtml_Export_Grid extends Mage_Adminhtm
|
|
25 |
$websites = Mage::app()->getWebsites(false, true);
|
26 |
foreach ($websites as $website) {
|
27 |
$websiteId = $website->getId();
|
28 |
-
|
29 |
-
if (Mage::app()->getWebsite($websiteId)->getConfig('reflektion_datafeeds/general/allfeedsenabled') == 'enabled') {
|
30 |
-
|
31 |
$feedTypes = '';
|
32 |
foreach (Reflektion_Catalogexport_Model_Generatefeeds::getFeedTypes() as $curFeedType) {
|
33 |
-
if (
|
34 |
if (strlen($feedTypes) > 0) {
|
35 |
$feedTypes .= ', ';
|
36 |
}
|
|
|
37 |
$feedTypes .= $curFeedType;
|
38 |
}
|
39 |
}
|
40 |
-
|
41 |
-
$
|
|
|
42 |
|
43 |
// Grid item
|
44 |
$newItem = $collection->getNewEmptyItem();
|
45 |
-
$newItem->setData(
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
$collection->addItem($newItem);
|
54 |
-
}
|
55 |
-
}
|
56 |
|
57 |
$this->setCollection($collection);
|
58 |
return $this;
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
)
|
73 |
-
|
74 |
-
$this->addColumn(
|
75 |
-
'
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
)
|
91 |
-
|
92 |
-
$this->addColumn(
|
93 |
-
'
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
'
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
return parent::_prepareColumns();
|
106 |
-
}
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
109 |
return $this->getUrl("*/*/exportone", array("id" => $row->getId()));
|
110 |
-
}
|
111 |
|
112 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Prepare collection and select columns
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Block_Adminhtml_Export_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
parent::__construct();
|
18 |
$this->setId("exportGrid");
|
19 |
$this->setDefaultDir("ASC");
|
20 |
$this->setSaveParametersInSession(true);
|
|
|
21 |
|
22 |
+
}//end __construct()
|
23 |
+
|
24 |
+
|
25 |
+
protected function _prepareCollection()
|
26 |
+
{
|
27 |
// Collection for each data feed for each website
|
28 |
$collection = new Varien_Data_Collection();
|
29 |
|
31 |
$websites = Mage::app()->getWebsites(false, true);
|
32 |
foreach ($websites as $website) {
|
33 |
$websiteId = $website->getId();
|
34 |
+
if ($website->getConfig('reflektion_datafeeds/general/allfeedsenabled') == 'enabled') {
|
|
|
|
|
35 |
$feedTypes = '';
|
36 |
foreach (Reflektion_Catalogexport_Model_Generatefeeds::getFeedTypes() as $curFeedType) {
|
37 |
+
if ($website->getConfig('reflektion_datafeeds/feedsenabled/'.$curFeedType) == 'enabled') {
|
38 |
if (strlen($feedTypes) > 0) {
|
39 |
$feedTypes .= ', ';
|
40 |
}
|
41 |
+
|
42 |
$feedTypes .= $curFeedType;
|
43 |
}
|
44 |
}
|
45 |
+
|
46 |
+
$sftpUser = $website->getConfig('reflektion_datafeeds/connect/username');
|
47 |
+
$sftpDestination = $website->getConfig('reflektion_datafeeds/connect/hostname');
|
48 |
|
49 |
// Grid item
|
50 |
$newItem = $collection->getNewEmptyItem();
|
51 |
+
$newItem->setData(
|
52 |
+
array(
|
53 |
+
'id' => $website->getId(),
|
54 |
+
'website_name' => $website->getName(),
|
55 |
+
'website_code' => $website->getCode(),
|
56 |
+
'feeds' => $feedTypes,
|
57 |
+
'sftp_destination' => $sftpDestination,
|
58 |
+
'sftp_user' => $sftpUser,
|
59 |
+
)
|
60 |
+
);
|
61 |
$collection->addItem($newItem);
|
62 |
+
}//end if
|
63 |
+
}//end foreach
|
64 |
|
65 |
$this->setCollection($collection);
|
66 |
return $this;
|
67 |
+
|
68 |
+
}//end _prepareCollection()
|
69 |
+
|
70 |
+
|
71 |
+
protected function _prepareColumns()
|
72 |
+
{
|
73 |
+
$this->addColumn(
|
74 |
+
'id',
|
75 |
+
array(
|
76 |
+
'header' => Mage::helper('reflektion')->__('Website ID'),
|
77 |
+
'width' => '50px',
|
78 |
+
'index' => 'id',
|
79 |
+
)
|
80 |
+
);
|
81 |
+
|
82 |
+
$this->addColumn(
|
83 |
+
'website_name',
|
84 |
+
array(
|
85 |
+
'header' => Mage::helper('reflektion')->__('Website Name'),
|
86 |
+
'width' => '110px',
|
87 |
+
'index' => 'website_name',
|
88 |
+
)
|
89 |
+
);
|
90 |
+
|
91 |
+
$this->addColumn(
|
92 |
+
'website_code',
|
93 |
+
array(
|
94 |
+
'header' => Mage::helper('reflektion')->__('Website Code'),
|
95 |
+
'width' => '100px',
|
96 |
+
'index' => 'website_code',
|
97 |
+
)
|
98 |
+
);
|
99 |
+
|
100 |
+
$this->addColumn(
|
101 |
+
'feeds',
|
102 |
+
array(
|
103 |
+
'header' => Mage::helper('reflektion')->__('Feeds to Send'),
|
104 |
+
'width' => '320px',
|
105 |
+
'index' => 'feeds',
|
106 |
+
)
|
107 |
+
);
|
108 |
+
|
109 |
+
$this->addColumn(
|
110 |
+
'sftp_destination',
|
111 |
+
array(
|
112 |
+
'header' => Mage::helper('reflektion')->__('SFTP Destination'),
|
113 |
+
'width' => '140px',
|
114 |
+
'index' => 'sftp_destination',
|
115 |
+
)
|
116 |
+
);
|
117 |
+
|
118 |
+
$this->addColumn(
|
119 |
+
'sftp_user',
|
120 |
+
array(
|
121 |
+
'header' => Mage::helper('reflektion')->__('SFTP User'),
|
122 |
+
'width' => '100px',
|
123 |
+
'index' => 'sftp_user',
|
124 |
+
)
|
125 |
+
);
|
126 |
+
|
127 |
+
$this->addColumn(
|
128 |
+
'action',
|
129 |
+
array(
|
130 |
+
'header' => Mage::helper('reflektion')->__('Action'),
|
131 |
+
'filter' => false,
|
132 |
+
'sortable' => false,
|
133 |
+
'renderer' => 'reflektion/adminhtml_export_grid_renderer_action',
|
134 |
+
)
|
135 |
+
);
|
136 |
|
137 |
return parent::_prepareColumns();
|
|
|
138 |
|
139 |
+
}//end _prepareColumns()
|
140 |
+
|
141 |
+
|
142 |
+
public function getRowUrl($row)
|
143 |
+
{
|
144 |
return $this->getUrl("*/*/exportone", array("id" => $row->getId()));
|
|
|
145 |
|
146 |
+
}//end getRowUrl()
|
147 |
+
|
148 |
+
|
149 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/Grid/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Export/Grid/Renderer/Action.php
CHANGED
@@ -6,16 +6,25 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Render action to generate data feed queue
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Block_Adminhtml_Export_Grid_Renderer_Action extends
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
return parent::render($row);
|
19 |
-
}
|
20 |
|
21 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Render action to generate data feed queue
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Block_Adminhtml_Export_Grid_Renderer_Action extends
|
12 |
+
Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
13 |
+
{
|
14 |
|
15 |
+
|
16 |
+
public function render(Varien_Object $row)
|
17 |
+
{
|
18 |
+
$this->getColumn()->setActions(
|
19 |
+
array(array(
|
20 |
+
'url' => $this->getUrl('*/*/exportone', array('id' => $row->getId())),
|
21 |
+
'caption' => Mage::helper('reflektion')->__('Export Feed For '.$row->getWebsiteName()),
|
22 |
+
),
|
23 |
+
)
|
24 |
+
);
|
25 |
return parent::render($row);
|
|
|
26 |
|
27 |
+
}//end render()
|
28 |
+
|
29 |
+
|
30 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Job.php
CHANGED
@@ -8,20 +8,28 @@
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Admin jobs queue grid layout load
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Block_Adminhtml_Job extends Mage_Adminhtml_Block_Widget_Grid_Container
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
|
15 |
$this->_controller = "adminhtml_job";
|
16 |
$this->_blockGroup = "reflektion";
|
17 |
$this->_headerText = Mage::helper("reflektion")->__("Data Feeds Job Queue");
|
18 |
parent::__construct();
|
19 |
-
}
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
// Remove add button
|
23 |
$this->_removeButton('add');
|
24 |
return parent::_prepareLayout();
|
25 |
-
}
|
26 |
|
27 |
-
}
|
|
|
|
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Admin jobs queue grid layout load
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Block_Adminhtml_Job extends Mage_Adminhtml_Block_Widget_Grid_Container
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
|
18 |
$this->_controller = "adminhtml_job";
|
19 |
$this->_blockGroup = "reflektion";
|
20 |
$this->_headerText = Mage::helper("reflektion")->__("Data Feeds Job Queue");
|
21 |
parent::__construct();
|
|
|
22 |
|
23 |
+
}//end __construct()
|
24 |
+
|
25 |
+
|
26 |
+
protected function _prepareLayout()
|
27 |
+
{
|
28 |
// Remove add button
|
29 |
$this->_removeButton('add');
|
30 |
return parent::_prepareLayout();
|
|
|
31 |
|
32 |
+
}//end _prepareLayout()
|
33 |
+
|
34 |
+
|
35 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/Job/Grid.php
CHANGED
@@ -6,11 +6,14 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Prepare collection and select columns
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Block_Adminhtml_Job_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
parent::__construct();
|
15 |
$this->setId("jobGrid");
|
16 |
$this->setDefaultSort('job_id');
|
@@ -19,113 +22,163 @@ class Reflektion_Catalogexport_Block_Adminhtml_Job_Grid extends Mage_Adminhtml_B
|
|
19 |
if (Mage::registry('preparedFilter')) {
|
20 |
$this->setDefaultFilter(Mage::registry('preparedFilter'));
|
21 |
}
|
22 |
-
}
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
$filterArr = Mage::registry('preparedFilter');
|
26 |
-
if (($column->getId() === 'store_id' || $column->getId() === 'status')
|
|
|
|
|
27 |
$_inNin = explode(',', $column->getFilter()->getValue());
|
28 |
-
$inNin
|
29 |
foreach ($_inNin as $k => $v) {
|
30 |
if (is_string($v) && strlen(trim($v))) {
|
31 |
$inNin[] = trim($v);
|
32 |
}
|
33 |
}
|
|
|
34 |
if (count($inNin) > 1 && in_array($inNin[0], array('in', 'nin'))) {
|
35 |
-
$in
|
36 |
$values = array_slice($inNin, 1);
|
37 |
$this->getCollection()->addFieldToFilter($column->getId(), array($in => $values));
|
38 |
} else {
|
39 |
parent::_addColumnFilterToCollection($column);
|
40 |
}
|
41 |
-
}
|
|
|
|
|
42 |
$this->getCollection()->addFieldToFilter($column->getId(), $filterArr[$column->getId()]);
|
43 |
} else {
|
44 |
parent::_addColumnFilterToCollection($column);
|
45 |
-
}
|
46 |
return $this;
|
47 |
-
}
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
$collection = Mage::getResourceModel('reflektion/job_collection');
|
51 |
$this->setCollection($collection);
|
52 |
return parent::_prepareCollection();
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$this->addColumn(
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
'
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED => Mage::helper('reflektion')->__('Scheduled'),
|
103 |
-
Reflektion_Catalogexport_Model_Job::STATUS_RUNNING
|
104 |
Reflektion_Catalogexport_Model_Job::STATUS_COMPLETED => Mage::helper('reflektion')->__('Completed'),
|
105 |
-
Reflektion_Catalogexport_Model_Job::STATUS_ERROR
|
106 |
-
Reflektion_Catalogexport_Model_Job::STATUS_MANUAL
|
107 |
-
|
108 |
-
|
|
|
109 |
return parent::_prepareColumns();
|
110 |
-
}
|
111 |
|
112 |
-
|
|
|
|
|
|
|
|
|
113 |
$this->setMassactionIdField('job_id');
|
114 |
$this->getMassactionBlock()->setFormFieldName('job_id');
|
115 |
|
116 |
-
$this->getMassactionBlock()->addItem(
|
117 |
-
'
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
return $this;
|
129 |
-
}
|
130 |
|
131 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Prepare collection and select columns
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Block_Adminhtml_Job_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
parent::__construct();
|
18 |
$this->setId("jobGrid");
|
19 |
$this->setDefaultSort('job_id');
|
22 |
if (Mage::registry('preparedFilter')) {
|
23 |
$this->setDefaultFilter(Mage::registry('preparedFilter'));
|
24 |
}
|
|
|
25 |
|
26 |
+
}//end __construct()
|
27 |
+
|
28 |
+
|
29 |
+
protected function _addColumnFilterToCollection($column)
|
30 |
+
{
|
31 |
$filterArr = Mage::registry('preparedFilter');
|
32 |
+
if (($column->getId() === 'store_id' || $column->getId() === 'status')
|
33 |
+
&& $column->getFilter()->getValue() && (strpos($column->getFilter()->getValue(), ',') !== false)
|
34 |
+
) {
|
35 |
$_inNin = explode(',', $column->getFilter()->getValue());
|
36 |
+
$inNin = array();
|
37 |
foreach ($_inNin as $k => $v) {
|
38 |
if (is_string($v) && strlen(trim($v))) {
|
39 |
$inNin[] = trim($v);
|
40 |
}
|
41 |
}
|
42 |
+
|
43 |
if (count($inNin) > 1 && in_array($inNin[0], array('in', 'nin'))) {
|
44 |
+
$in = $inNin[0];
|
45 |
$values = array_slice($inNin, 1);
|
46 |
$this->getCollection()->addFieldToFilter($column->getId(), array($in => $values));
|
47 |
} else {
|
48 |
parent::_addColumnFilterToCollection($column);
|
49 |
}
|
50 |
+
} else if (is_array($filterArr) && array_key_exists($column->getId(), $filterArr)
|
51 |
+
&& isset($filterArr[$column->getId()])
|
52 |
+
) {
|
53 |
$this->getCollection()->addFieldToFilter($column->getId(), $filterArr[$column->getId()]);
|
54 |
} else {
|
55 |
parent::_addColumnFilterToCollection($column);
|
56 |
+
}//end if
|
57 |
return $this;
|
|
|
58 |
|
59 |
+
}//end _addColumnFilterToCollection()
|
60 |
+
|
61 |
+
|
62 |
+
protected function _prepareCollection()
|
63 |
+
{
|
64 |
$collection = Mage::getResourceModel('reflektion/job_collection');
|
65 |
$this->setCollection($collection);
|
66 |
return parent::_prepareCollection();
|
67 |
+
|
68 |
+
}//end _prepareCollection()
|
69 |
+
|
70 |
+
|
71 |
+
protected function _prepareColumns()
|
72 |
+
{
|
73 |
+
$this->addColumn(
|
74 |
+
'job_id',
|
75 |
+
array(
|
76 |
+
'header' => Mage::helper('reflektion')->__('Job ID'),
|
77 |
+
'index' => 'job_id',
|
78 |
+
)
|
79 |
+
);
|
80 |
+
$this->addColumn(
|
81 |
+
'website_id',
|
82 |
+
array(
|
83 |
+
'header' => Mage::helper('reflektion')->__('Website ID'),
|
84 |
+
'index' => 'website_id',
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$this->addColumn(
|
89 |
+
'type',
|
90 |
+
array(
|
91 |
+
'header' => Mage::helper('reflektion')->__('Job Type'),
|
92 |
+
'index' => 'type',
|
93 |
+
'type' => 'options',
|
94 |
+
'options' => array(
|
95 |
+
Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_BASELINE
|
96 |
+
=> Mage::helper('reflektion')->__('Manual Feed'),
|
97 |
+
Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_DAILY
|
98 |
+
=> Mage::helper('reflektion')->__('Daily Feed'),
|
99 |
+
Reflektion_Catalogexport_Model_Job::TYPE_TRANSFER
|
100 |
+
=> Mage::helper('reflektion')->__('Transfer File'),
|
101 |
+
Reflektion_Catalogexport_Model_Job::TYPE_TRANSFER_MANUAL
|
102 |
+
=> Mage::helper('reflektion')->__('Transfer File Manual'),
|
103 |
+
),
|
104 |
+
)
|
105 |
+
);
|
106 |
+
|
107 |
+
$this->addColumn(
|
108 |
+
'feed_type',
|
109 |
+
array(
|
110 |
+
'header' => Mage::helper('reflektion')->__('Feed Type'),
|
111 |
+
'index' => 'feed_type',
|
112 |
+
)
|
113 |
+
);
|
114 |
+
|
115 |
+
$this->addColumn(
|
116 |
+
'scheduled_at',
|
117 |
+
array(
|
118 |
+
'header' => Mage::helper('reflektion')->__('Scheduled'),
|
119 |
+
'type' => 'datetime',
|
120 |
+
'index' => 'scheduled_at',
|
121 |
+
)
|
122 |
+
);
|
123 |
+
|
124 |
+
$this->addColumn(
|
125 |
+
'ended_at',
|
126 |
+
array(
|
127 |
+
'header' => Mage::helper('reflektion')->__('Completed'),
|
128 |
+
'type' => 'datetime',
|
129 |
+
'width' => '160px',
|
130 |
+
'index' => 'ended_at',
|
131 |
+
)
|
132 |
+
);
|
133 |
+
|
134 |
+
$this->addColumn(
|
135 |
+
'status',
|
136 |
+
array(
|
137 |
+
'header' => Mage::helper('reflektion')->__('Status'),
|
138 |
+
'width' => '100px',
|
139 |
+
'index' => 'status',
|
140 |
+
'type' => 'options',
|
141 |
+
'options' => array(
|
142 |
Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED => Mage::helper('reflektion')->__('Scheduled'),
|
143 |
+
Reflektion_Catalogexport_Model_Job::STATUS_RUNNING => Mage::helper('reflektion')->__('Running'),
|
144 |
Reflektion_Catalogexport_Model_Job::STATUS_COMPLETED => Mage::helper('reflektion')->__('Completed'),
|
145 |
+
Reflektion_Catalogexport_Model_Job::STATUS_ERROR => Mage::helper('reflektion')->__('Error'),
|
146 |
+
Reflektion_Catalogexport_Model_Job::STATUS_MANUAL => Mage::helper('reflektion')->__('Manual'),
|
147 |
+
),
|
148 |
+
)
|
149 |
+
);
|
150 |
return parent::_prepareColumns();
|
|
|
151 |
|
152 |
+
}//end _prepareColumns()
|
153 |
+
|
154 |
+
|
155 |
+
protected function _prepareMassaction()
|
156 |
+
{
|
157 |
$this->setMassactionIdField('job_id');
|
158 |
$this->getMassactionBlock()->setFormFieldName('job_id');
|
159 |
|
160 |
+
$this->getMassactionBlock()->addItem(
|
161 |
+
'delete',
|
162 |
+
array(
|
163 |
+
'label' => Mage::helper('reflektion')->__('Delete'),
|
164 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
165 |
+
'confirm' => Mage::helper('reflektion')->__('Delete selected job(s)?'),
|
166 |
+
)
|
167 |
+
);
|
168 |
+
|
169 |
+
$this->getMassactionBlock()->addItem(
|
170 |
+
'execute',
|
171 |
+
array(
|
172 |
+
'label' => Mage::helper('reflektion')->__('Run Job'),
|
173 |
+
'url' => $this->getUrl('*/*/massRun'),
|
174 |
+
'confirm' => Mage::helper('reflektion')
|
175 |
+
->__('Run selected job(s)? Note that running multiple and/or jobs may impact site performance.'),
|
176 |
+
)
|
177 |
+
);
|
178 |
|
179 |
return $this;
|
|
|
180 |
|
181 |
+
}//end _prepareMassaction()
|
182 |
+
|
183 |
+
|
184 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/System/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/System/Config/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Block/Adminhtml/System/Config/CommentText.php
CHANGED
@@ -8,11 +8,16 @@
|
|
8 |
* @description To add comment in system config fields
|
9 |
*/
|
10 |
|
11 |
-
class Reflektion_Catalogexport_Block_Adminhtml_System_Config_CommentText
|
12 |
-
|
13 |
{
|
14 |
-
|
|
|
|
|
15 |
{
|
16 |
return $element->getComment();
|
17 |
-
|
18 |
-
}
|
|
|
|
|
|
8 |
* @description To add comment in system config fields
|
9 |
*/
|
10 |
|
11 |
+
class Reflektion_Catalogexport_Block_Adminhtml_System_Config_CommentText
|
12 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
13 |
{
|
14 |
+
|
15 |
+
|
16 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
17 |
{
|
18 |
return $element->getComment();
|
19 |
+
|
20 |
+
}//end render()
|
21 |
+
|
22 |
+
|
23 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Helper/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Helper/Csvfile.php
CHANGED
@@ -6,9 +6,10 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description CSV files operations - create, open, reopen, close and write
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
|
12 |
|
13 |
private $_filename;
|
14 |
private $_handle;
|
@@ -16,28 +17,34 @@ class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
16 |
private $_errorMessage;
|
17 |
private $_columnHeaders;
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$this->
|
|
|
|
|
23 |
$this->_errorMessage = null;
|
24 |
-
|
|
|
|
|
25 |
|
26 |
/**
|
27 |
* Open file
|
28 |
-
*
|
29 |
-
* @param
|
30 |
-
* @
|
|
|
31 |
*/
|
32 |
-
public function open($filename, array $columnHeaders)
|
|
|
33 |
$this->_columnHeaders = $columnHeaders;
|
34 |
-
$this->_filename
|
35 |
|
36 |
try {
|
37 |
// Open file
|
38 |
$this->_handle = fopen($this->_filename, 'w');
|
39 |
// Build header row string
|
40 |
-
$rowString = implode(",", $this->encodeFields($columnHeaders))
|
41 |
// Write row to file
|
42 |
$result = fwrite($this->_handle, $rowString);
|
43 |
} catch (Exception $e) {
|
@@ -46,16 +53,20 @@ class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
46 |
}
|
47 |
|
48 |
return true;
|
49 |
-
|
|
|
|
|
50 |
|
51 |
/**
|
52 |
* Re Open existing file
|
|
|
53 |
* @param string $filename fully qualified filename + path. (directory must be writable)
|
54 |
-
* @return
|
55 |
*/
|
56 |
-
public function reopen($filename, array $columnHeaders)
|
|
|
57 |
$this->_columnHeaders = $columnHeaders;
|
58 |
-
$this->_filename
|
59 |
|
60 |
try {
|
61 |
// Reopen file
|
@@ -66,12 +77,15 @@ class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
66 |
}
|
67 |
|
68 |
return true;
|
69 |
-
|
|
|
|
|
70 |
|
71 |
/**
|
72 |
* Close file
|
73 |
*/
|
74 |
-
public function close()
|
|
|
75 |
try {
|
76 |
fclose($this->_handle);
|
77 |
} catch (Exception $e) {
|
@@ -80,15 +94,19 @@ class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
80 |
}
|
81 |
|
82 |
return true;
|
83 |
-
|
|
|
|
|
84 |
|
85 |
/**
|
86 |
* Write row to file
|
87 |
*
|
88 |
-
* @param array $rowValues An associative array of columns => values, cells for columns not included in this
|
89 |
-
*
|
|
|
90 |
*/
|
91 |
-
public function writeRow(array $rowValues)
|
|
|
92 |
try {
|
93 |
// Filter
|
94 |
$selectedRowValues = array();
|
@@ -99,10 +117,11 @@ class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
99 |
$selectedRowValues[] = "";
|
100 |
}
|
101 |
}
|
|
|
102 |
// Convert to utf8
|
103 |
$convertedRowValues = $this->encodeFields($selectedRowValues);
|
104 |
// Build row string
|
105 |
-
$rowString = implode(",", $convertedRowValues)
|
106 |
// Write row to file
|
107 |
$result = fwrite($this->_handle, $rowString);
|
108 |
// Check result
|
@@ -112,29 +131,35 @@ class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
|
112 |
} catch (Exception $e) {
|
113 |
Mage::logException($e);
|
114 |
return false;
|
115 |
-
}
|
116 |
|
117 |
return true;
|
118 |
-
|
|
|
|
|
119 |
|
120 |
/**
|
121 |
* Convert strings in array to Utf8 and encode for CSV file usage
|
|
|
122 |
* @param array $values
|
123 |
-
* @return
|
124 |
*/
|
125 |
-
private function encodeFields(array $values)
|
|
|
126 |
$converted = array();
|
127 |
foreach ($values as $value) {
|
128 |
// Encode in utf8
|
129 |
$newVal = utf8_encode($value);
|
130 |
$newVal = str_replace('"', '""', $newVal);
|
131 |
// Delimiter
|
132 |
-
$newVal = '"'
|
133 |
// Converted array
|
134 |
array_push($converted, $newVal);
|
135 |
}
|
136 |
|
137 |
return $converted;
|
138 |
-
}
|
139 |
|
140 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description CSV files operations - create, open, reopen, close and write
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Helper_Csvfile extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
|
14 |
private $_filename;
|
15 |
private $_handle;
|
17 |
private $_errorMessage;
|
18 |
private $_columnHeaders;
|
19 |
|
20 |
+
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->_filename = null;
|
24 |
+
$this->_handle = null;
|
25 |
+
$this->_path = null;
|
26 |
$this->_errorMessage = null;
|
27 |
+
|
28 |
+
}//end __construct()
|
29 |
+
|
30 |
|
31 |
/**
|
32 |
* Open file
|
33 |
+
*
|
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 |
// Open file
|
45 |
$this->_handle = fopen($this->_filename, 'w');
|
46 |
// Build header row string
|
47 |
+
$rowString = implode(",", $this->encodeFields($columnHeaders))."\r\n";
|
48 |
// Write row to file
|
49 |
$result = fwrite($this->_handle, $rowString);
|
50 |
} catch (Exception $e) {
|
53 |
}
|
54 |
|
55 |
return true;
|
56 |
+
|
57 |
+
}//end open()
|
58 |
+
|
59 |
|
60 |
/**
|
61 |
* Re Open existing file
|
62 |
+
*
|
63 |
* @param string $filename fully qualified filename + path. (directory must be writable)
|
64 |
+
* @return boolean
|
65 |
*/
|
66 |
+
public function reopen($filename, array $columnHeaders)
|
67 |
+
{
|
68 |
$this->_columnHeaders = $columnHeaders;
|
69 |
+
$this->_filename = $filename;
|
70 |
|
71 |
try {
|
72 |
// Reopen file
|
77 |
}
|
78 |
|
79 |
return true;
|
80 |
+
|
81 |
+
}//end reopen()
|
82 |
+
|
83 |
|
84 |
/**
|
85 |
* Close file
|
86 |
*/
|
87 |
+
public function close()
|
88 |
+
{
|
89 |
try {
|
90 |
fclose($this->_handle);
|
91 |
} catch (Exception $e) {
|
94 |
}
|
95 |
|
96 |
return true;
|
97 |
+
|
98 |
+
}//end close()
|
99 |
+
|
100 |
|
101 |
/**
|
102 |
* Write row to file
|
103 |
*
|
104 |
+
* @param array $rowValues An associative array of columns => values, cells for columns not included in this
|
105 |
+
* row are left empty
|
106 |
+
* @return boolean
|
107 |
*/
|
108 |
+
public function writeRow(array $rowValues)
|
109 |
+
{
|
110 |
try {
|
111 |
// Filter
|
112 |
$selectedRowValues = array();
|
117 |
$selectedRowValues[] = "";
|
118 |
}
|
119 |
}
|
120 |
+
|
121 |
// Convert to utf8
|
122 |
$convertedRowValues = $this->encodeFields($selectedRowValues);
|
123 |
// Build row string
|
124 |
+
$rowString = implode(",", $convertedRowValues)."\r\n";
|
125 |
// Write row to file
|
126 |
$result = fwrite($this->_handle, $rowString);
|
127 |
// Check result
|
131 |
} catch (Exception $e) {
|
132 |
Mage::logException($e);
|
133 |
return false;
|
134 |
+
}//end try
|
135 |
|
136 |
return true;
|
137 |
+
|
138 |
+
}//end writeRow()
|
139 |
+
|
140 |
|
141 |
/**
|
142 |
* Convert strings in array to Utf8 and encode for CSV file usage
|
143 |
+
*
|
144 |
* @param array $values
|
145 |
+
* @return array $converted
|
146 |
*/
|
147 |
+
private function encodeFields(array $values)
|
148 |
+
{
|
149 |
$converted = array();
|
150 |
foreach ($values as $value) {
|
151 |
// Encode in utf8
|
152 |
$newVal = utf8_encode($value);
|
153 |
$newVal = str_replace('"', '""', $newVal);
|
154 |
// Delimiter
|
155 |
+
$newVal = '"'.$newVal.'"';
|
156 |
// Converted array
|
157 |
array_push($converted, $newVal);
|
158 |
}
|
159 |
|
160 |
return $converted;
|
|
|
161 |
|
162 |
+
}//end encodeFields()
|
163 |
+
|
164 |
+
|
165 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Helper/Data.php
CHANGED
@@ -6,27 +6,32 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
*
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Helper_Data extends Mage_Core_Helper_Abstract
|
|
|
12 |
|
13 |
const LOG_FILE = 'reflektion.log';
|
14 |
|
15 |
/*
|
16 |
-
|
17 |
-
|
18 |
*/
|
19 |
|
20 |
-
|
|
|
|
|
21 |
$force = $force ||
|
22 |
(Mage::getStoreConfig('reflektion_datafeeds/advanced/force_logging') !== "disabled");
|
23 |
Mage::log($message, $level, $file, $force);
|
24 |
-
|
|
|
|
|
25 |
|
26 |
/**
|
27 |
* Validate feed configuration settings for one website or all websites
|
28 |
*/
|
29 |
-
public function validateFeedConfiguration($websiteId = null)
|
|
|
30 |
$websites = array();
|
31 |
if ($websiteId) {
|
32 |
$websites[] = $websiteId;
|
@@ -37,57 +42,71 @@ class Reflektion_Catalogexport_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
//Track if feeds enabled for any website
|
41 |
$bFeedsEnabled = false;
|
42 |
foreach ($websites as $curWebsiteId) {
|
43 |
// If config is enabled
|
44 |
-
|
|
|
45 |
$bFeedsEnabled = true;
|
46 |
|
47 |
try {
|
48 |
// Get hostname, port & credentials
|
49 |
-
$
|
50 |
-
$
|
51 |
-
$
|
52 |
-
$
|
|
|
|
|
|
|
53 |
} catch (Exception $e) {
|
54 |
Mage::logException($e);
|
55 |
-
Mage::helper('reflektion')
|
56 |
-
|
|
|
|
|
|
|
57 |
}
|
|
|
58 |
// Check SFTP credentials
|
59 |
if (strlen($sftpHost) <= 0) {
|
60 |
-
Mage::throwException('SFTP host ('
|
61 |
}
|
|
|
62 |
if (strlen($sftpPort) <= 0 || $sftpPort < 1 || $sftpPort > 65535) {
|
63 |
-
Mage::throwException('SFTP port ('
|
64 |
}
|
|
|
65 |
if (strlen($sftpUser) <= 0) {
|
66 |
-
Mage::throwException('SFTP user ('
|
67 |
}
|
|
|
68 |
if (strlen($sftpPassword) <= 0) {
|
69 |
-
Mage::throwException('SFTP password is invalid for website id: '
|
70 |
}
|
71 |
-
}
|
72 |
-
}
|
73 |
|
74 |
// Send error message
|
75 |
if (!$bFeedsEnabled) {
|
76 |
Mage::throwException('Data feeds not enabled');
|
77 |
}
|
78 |
-
|
|
|
|
|
79 |
|
80 |
/**
|
81 |
* Description To get the Categories list with breadcrum
|
82 |
*/
|
83 |
-
function getTreeCategories($parentId)
|
|
|
84 |
|
85 |
-
$allCats
|
86 |
->addAttributeToSelect('*')
|
87 |
->addAttributeToFilter('is_active', '1')
|
88 |
->addAttributeToFilter('include_in_menu', '1')
|
89 |
->addAttributeToFilter('parent_id', array('eq' => $parentId));
|
90 |
-
|
91 |
foreach ($allCats as $category) {
|
92 |
$this->str .= $category->getName();
|
93 |
$this->allCat[$category->getId()] = $this->str;
|
@@ -99,7 +118,10 @@ class Reflektion_Catalogexport_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
99 |
$this->str = '';
|
100 |
}
|
101 |
}
|
|
|
102 |
return $this->allCat;
|
103 |
-
}
|
104 |
|
105 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
|
|
9 |
*/
|
10 |
+
class Reflektion_Catalogexport_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
|
13 |
const LOG_FILE = 'reflektion.log';
|
14 |
|
15 |
/*
|
16 |
+
* Example of how logging should be done in this extension :
|
17 |
+
* Mage::helper('reflektion')->log($message, Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
18 |
*/
|
19 |
|
20 |
+
|
21 |
+
public function log($message, $level = null, $file = null, $force = false)
|
22 |
+
{
|
23 |
$force = $force ||
|
24 |
(Mage::getStoreConfig('reflektion_datafeeds/advanced/force_logging') !== "disabled");
|
25 |
Mage::log($message, $level, $file, $force);
|
26 |
+
|
27 |
+
}//end log()
|
28 |
+
|
29 |
|
30 |
/**
|
31 |
* Validate feed configuration settings for one website or all websites
|
32 |
*/
|
33 |
+
public function validateFeedConfiguration($websiteId = null)
|
34 |
+
{
|
35 |
$websites = array();
|
36 |
if ($websiteId) {
|
37 |
$websites[] = $websiteId;
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
// Track if feeds enabled for any website
|
46 |
$bFeedsEnabled = false;
|
47 |
foreach ($websites as $curWebsiteId) {
|
48 |
// If config is enabled
|
49 |
+
$configEn = 'reflektion_datafeeds/general/allfeedsenabled';
|
50 |
+
if (Mage::app()->getWebsite($curWebsiteId)->getConfig($configEn) == 'enabled') {
|
51 |
$bFeedsEnabled = true;
|
52 |
|
53 |
try {
|
54 |
// Get hostname, port & credentials
|
55 |
+
$websiteConf = Mage::app()->getWebsite($curWebsiteId);
|
56 |
+
$sftpHost = $websiteConf->getConfig('reflektion_datafeeds/connect/hostname');
|
57 |
+
$sftpPort = $websiteConf->getConfig('reflektion_datafeeds/connect/port');
|
58 |
+
$sftpUser = $websiteConf->getConfig('reflektion_datafeeds/connect/username');
|
59 |
+
$sftpPassword = Mage::helper('core')->decrypt(
|
60 |
+
$websiteConf->getConfig('reflektion_datafeeds/connect/password')
|
61 |
+
);
|
62 |
} catch (Exception $e) {
|
63 |
Mage::logException($e);
|
64 |
+
Mage::helper('reflektion')
|
65 |
+
->log($e->getMessage(), Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
66 |
+
Mage::throwException(
|
67 |
+
'Error looking up feed transfer connectivity parameters for website id: '.$curWebsiteId
|
68 |
+
);
|
69 |
}
|
70 |
+
|
71 |
// Check SFTP credentials
|
72 |
if (strlen($sftpHost) <= 0) {
|
73 |
+
Mage::throwException('SFTP host ('.$sftpHost.') is invalid for website id: '.$curWebsiteId);
|
74 |
}
|
75 |
+
|
76 |
if (strlen($sftpPort) <= 0 || $sftpPort < 1 || $sftpPort > 65535) {
|
77 |
+
Mage::throwException('SFTP port ('.$sftpPort.') is invalid for website id: '.$curWebsiteId);
|
78 |
}
|
79 |
+
|
80 |
if (strlen($sftpUser) <= 0) {
|
81 |
+
Mage::throwException('SFTP user ('.$sftpUser.') is invalid for website id: '.$curWebsiteId);
|
82 |
}
|
83 |
+
|
84 |
if (strlen($sftpPassword) <= 0) {
|
85 |
+
Mage::throwException('SFTP password is invalid for website id: '.$curWebsiteId);
|
86 |
}
|
87 |
+
}//end if
|
88 |
+
}//end foreach
|
89 |
|
90 |
// Send error message
|
91 |
if (!$bFeedsEnabled) {
|
92 |
Mage::throwException('Data feeds not enabled');
|
93 |
}
|
94 |
+
|
95 |
+
}//end validateFeedConfiguration()
|
96 |
+
|
97 |
|
98 |
/**
|
99 |
* Description To get the Categories list with breadcrum
|
100 |
*/
|
101 |
+
public function getTreeCategories($parentId)
|
102 |
+
{
|
103 |
|
104 |
+
$allCats = Mage::getModel('catalog/category')->getCollection()
|
105 |
->addAttributeToSelect('*')
|
106 |
->addAttributeToFilter('is_active', '1')
|
107 |
->addAttributeToFilter('include_in_menu', '1')
|
108 |
->addAttributeToFilter('parent_id', array('eq' => $parentId));
|
109 |
+
$this->str = '';
|
110 |
foreach ($allCats as $category) {
|
111 |
$this->str .= $category->getName();
|
112 |
$this->allCat[$category->getId()] = $this->str;
|
118 |
$this->str = '';
|
119 |
}
|
120 |
}
|
121 |
+
|
122 |
return $this->allCat;
|
|
|
123 |
|
124 |
+
}//end getTreeCategories()
|
125 |
+
|
126 |
+
|
127 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Helper/SftpConnection.php
CHANGED
@@ -6,22 +6,26 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description SFTP connect, transfer and close functions
|
10 |
* - Using magento library phpseclib
|
11 |
*/
|
12 |
-
require_once
|
13 |
|
14 |
-
class Reflektion_Catalogexport_Helper_SftpConnection extends Mage_Core_Helper_Abstract
|
|
|
15 |
|
16 |
const SFTP_TIMEOUT = 20;
|
17 |
|
18 |
private $_oConnection = null;
|
19 |
|
|
|
20 |
/**
|
21 |
* Connect
|
22 |
-
*
|
|
|
23 |
*/
|
24 |
-
public function connect($host, $port, $user, $pw)
|
|
|
25 |
|
26 |
try {
|
27 |
if (isset($this->_oConnection)) {
|
@@ -29,10 +33,10 @@ class Reflektion_Catalogexport_Helper_SftpConnection extends Mage_Core_Helper_Ab
|
|
29 |
}
|
30 |
|
31 |
// Config values
|
32 |
-
$sServer
|
33 |
-
$sServer
|
34 |
-
$sPort
|
35 |
-
$sPort
|
36 |
$sUsername = $user;
|
37 |
$sUsername = ($sUsername ? trim($sUsername) : '');
|
38 |
$sPassword = $pw;
|
@@ -40,36 +44,54 @@ class Reflektion_Catalogexport_Helper_SftpConnection extends Mage_Core_Helper_Ab
|
|
40 |
|
41 |
// Check credentials
|
42 |
if (!strlen($sServer)) {
|
43 |
-
Mage::throwException('Invalid SFTP host: '
|
44 |
}
|
|
|
45 |
if (!strlen($sPort) || !ctype_digit($sPort)) {
|
46 |
-
Mage::throwException('Invalid SFTP port: '
|
47 |
}
|
|
|
48 |
if (!strlen($sUsername)) {
|
49 |
-
Mage::throwException('Invalid SFTP user: '
|
50 |
}
|
|
|
51 |
if (!strlen($sPassword)) {
|
52 |
-
Mage::throwException('Invalid SFTP password: '
|
53 |
}
|
|
|
54 |
$this->_oConnection = new Net_SFTP($sServer, $sPort, self::SFTP_TIMEOUT);
|
55 |
if (!$this->_oConnection->login($sUsername, $sPassword)) {
|
56 |
-
Mage::throwException(
|
|
|
|
|
57 |
}
|
58 |
|
59 |
return true;
|
60 |
} catch (Exception $e) {
|
61 |
Mage::logException($e);
|
62 |
-
Mage::helper('reflektion')->log(
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
return false;
|
66 |
-
|
|
|
|
|
67 |
|
68 |
/**
|
69 |
* Close
|
70 |
-
*
|
|
|
71 |
*/
|
72 |
-
public function close()
|
|
|
73 |
try {
|
74 |
// Close connection
|
75 |
if (isset($this->_oConnection)) {
|
@@ -81,124 +103,185 @@ class Reflektion_Catalogexport_Helper_SftpConnection extends Mage_Core_Helper_Ab
|
|
81 |
}
|
82 |
} catch (Exception $e) {
|
83 |
Mage::logException($e);
|
84 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
return false;
|
88 |
-
|
|
|
|
|
89 |
|
90 |
/**
|
91 |
* Is connected
|
92 |
-
*
|
|
|
93 |
*/
|
94 |
-
public function isConnected()
|
|
|
95 |
return (isset($this->_oConnection));
|
96 |
-
|
|
|
|
|
97 |
|
98 |
/**
|
99 |
* Change directory
|
100 |
-
*
|
|
|
101 |
* @return boolean
|
102 |
*/
|
103 |
-
public function changeDir($sDir)
|
|
|
104 |
try {
|
105 |
if (!$this->isConnected()) {
|
106 |
return false;
|
107 |
}
|
|
|
108 |
return $this->_oConnection->chdir($sDir);
|
109 |
} catch (Exception $e) {
|
110 |
Mage::logException($e);
|
111 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
return false;
|
115 |
-
|
|
|
|
|
116 |
|
117 |
/**
|
118 |
* Make directory
|
|
|
119 |
* @param string directory
|
120 |
-
* @return
|
121 |
*/
|
122 |
-
public function makeDir($sDir)
|
|
|
123 |
try {
|
124 |
// Close connection
|
125 |
if (!$this->isConnected()) {
|
126 |
return false;
|
127 |
}
|
|
|
128 |
return $this->_oConnection->mkdir($sDir);
|
129 |
} catch (Exception $e) {
|
130 |
Mage::logException($e);
|
131 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
|
134 |
return false;
|
135 |
-
|
|
|
|
|
136 |
|
137 |
/**
|
138 |
* List files
|
|
|
139 |
* @param string directory
|
140 |
-
* @return
|
141 |
*/
|
142 |
-
public function listFiles($sDir = '.')
|
|
|
143 |
try {
|
144 |
// Close connection
|
145 |
if (!$this->isConnected()) {
|
146 |
return false;
|
147 |
}
|
|
|
148 |
return $this->_oConnection->nlist($sDir);
|
149 |
} catch (Exception $e) {
|
150 |
Mage::logException($e);
|
151 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
return false;
|
155 |
-
|
|
|
|
|
156 |
|
157 |
/**
|
158 |
* Transfer file
|
|
|
159 |
* @param string Local file path
|
160 |
-
* @return
|
161 |
*/
|
162 |
-
public function putFile($sLocalFilePath)
|
|
|
163 |
try {
|
164 |
// Close connection
|
165 |
if (!$this->isConnected()) {
|
166 |
return false;
|
167 |
}
|
168 |
-
|
|
|
|
|
169 |
// Transfer
|
170 |
$bSuccess = $this->_oConnection->put($sFilename, $sLocalFilePath, NET_SFTP_LOCAL_FILE);
|
171 |
if (!$bSuccess) {
|
172 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
173 |
}
|
|
|
174 |
return $bSuccess;
|
175 |
} catch (Exception $e) {
|
176 |
Mage::logException($e);
|
177 |
-
Mage::helper('reflektion')->log(
|
178 |
-
|
|
|
|
|
|
|
|
|
179 |
|
180 |
return false;
|
181 |
-
|
|
|
|
|
182 |
|
183 |
/**
|
184 |
* Transfer file and delete when successful as one atomic operation
|
|
|
185 |
* @param string Local file path
|
186 |
-
* @return
|
187 |
*/
|
188 |
-
public function putAndDeleteFile($sLocalFilePath)
|
|
|
189 |
try {
|
190 |
$bSuccess = $this->putFile($sLocalFilePath);
|
191 |
if ($bSuccess) {
|
192 |
$oIo = new Varien_Io_File();
|
193 |
$oIo->rm($sLocalFilePath);
|
194 |
}
|
|
|
195 |
return $bSuccess;
|
196 |
} catch (Exception $e) {
|
197 |
Mage::logException($e);
|
198 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
199 |
}
|
200 |
|
201 |
return false;
|
202 |
-
}
|
203 |
|
204 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description SFTP connect, transfer and close functions
|
10 |
* - Using magento library phpseclib
|
11 |
*/
|
12 |
+
require_once 'phpseclib/Net/SFTP.php';
|
13 |
|
14 |
+
class Reflektion_Catalogexport_Helper_SftpConnection extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
|
17 |
const SFTP_TIMEOUT = 20;
|
18 |
|
19 |
private $_oConnection = null;
|
20 |
|
21 |
+
|
22 |
/**
|
23 |
* Connect
|
24 |
+
*
|
25 |
+
* @return boolean
|
26 |
*/
|
27 |
+
public function connect($host, $port, $user, $pw)
|
28 |
+
{
|
29 |
|
30 |
try {
|
31 |
if (isset($this->_oConnection)) {
|
33 |
}
|
34 |
|
35 |
// Config values
|
36 |
+
$sServer = $host;
|
37 |
+
$sServer = ($sServer ? trim($sServer) : '');
|
38 |
+
$sPort = $port;
|
39 |
+
$sPort = ($sPort ? trim($sPort) : '');
|
40 |
$sUsername = $user;
|
41 |
$sUsername = ($sUsername ? trim($sUsername) : '');
|
42 |
$sPassword = $pw;
|
44 |
|
45 |
// Check credentials
|
46 |
if (!strlen($sServer)) {
|
47 |
+
Mage::throwException('Invalid SFTP host: '.$sServer);
|
48 |
}
|
49 |
+
|
50 |
if (!strlen($sPort) || !ctype_digit($sPort)) {
|
51 |
+
Mage::throwException('Invalid SFTP port: '.$sPort);
|
52 |
}
|
53 |
+
|
54 |
if (!strlen($sUsername)) {
|
55 |
+
Mage::throwException('Invalid SFTP user: '.$sUsername);
|
56 |
}
|
57 |
+
|
58 |
if (!strlen($sPassword)) {
|
59 |
+
Mage::throwException('Invalid SFTP password: '.$sPassword);
|
60 |
}
|
61 |
+
|
62 |
$this->_oConnection = new Net_SFTP($sServer, $sPort, self::SFTP_TIMEOUT);
|
63 |
if (!$this->_oConnection->login($sUsername, $sPassword)) {
|
64 |
+
Mage::throwException(
|
65 |
+
sprintf(__("Unable to open SFTP connection as %s@%s %s", $sUsername, $sServer, $sPassword))
|
66 |
+
);
|
67 |
}
|
68 |
|
69 |
return true;
|
70 |
} catch (Exception $e) {
|
71 |
Mage::logException($e);
|
72 |
+
Mage::helper('reflektion')->log(
|
73 |
+
$e->getMessage(),
|
74 |
+
Zend_Log::ERR,
|
75 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
76 |
+
);
|
77 |
+
Mage::helper('reflektion')->log(
|
78 |
+
"SFTP reported error is ".$e,
|
79 |
+
Zend_Log::INFO,
|
80 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
81 |
+
);
|
82 |
+
}//end try
|
83 |
return false;
|
84 |
+
|
85 |
+
}//end connect()
|
86 |
+
|
87 |
|
88 |
/**
|
89 |
* Close
|
90 |
+
*
|
91 |
+
* @return boolean
|
92 |
*/
|
93 |
+
public function close()
|
94 |
+
{
|
95 |
try {
|
96 |
// Close connection
|
97 |
if (isset($this->_oConnection)) {
|
103 |
}
|
104 |
} catch (Exception $e) {
|
105 |
Mage::logException($e);
|
106 |
+
Mage::helper('reflektion')->log(
|
107 |
+
$e->getMessage(),
|
108 |
+
Zend_Log::ERR,
|
109 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
110 |
+
);
|
111 |
}
|
112 |
|
113 |
return false;
|
114 |
+
|
115 |
+
}//end close()
|
116 |
+
|
117 |
|
118 |
/**
|
119 |
* Is connected
|
120 |
+
*
|
121 |
+
* @return boolean
|
122 |
*/
|
123 |
+
public function isConnected()
|
124 |
+
{
|
125 |
return (isset($this->_oConnection));
|
126 |
+
|
127 |
+
}//end isConnected()
|
128 |
+
|
129 |
|
130 |
/**
|
131 |
* Change directory
|
132 |
+
*
|
133 |
+
* @param string directory
|
134 |
* @return boolean
|
135 |
*/
|
136 |
+
public function changeDir($sDir)
|
137 |
+
{
|
138 |
try {
|
139 |
if (!$this->isConnected()) {
|
140 |
return false;
|
141 |
}
|
142 |
+
|
143 |
return $this->_oConnection->chdir($sDir);
|
144 |
} catch (Exception $e) {
|
145 |
Mage::logException($e);
|
146 |
+
Mage::helper('reflektion')->log(
|
147 |
+
$e->getMessage(),
|
148 |
+
Zend_Log::ERR,
|
149 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
150 |
+
);
|
151 |
}
|
152 |
|
153 |
return false;
|
154 |
+
|
155 |
+
}//end changeDir()
|
156 |
+
|
157 |
|
158 |
/**
|
159 |
* Make directory
|
160 |
+
*
|
161 |
* @param string directory
|
162 |
+
* @return boolean
|
163 |
*/
|
164 |
+
public function makeDir($sDir)
|
165 |
+
{
|
166 |
try {
|
167 |
// Close connection
|
168 |
if (!$this->isConnected()) {
|
169 |
return false;
|
170 |
}
|
171 |
+
|
172 |
return $this->_oConnection->mkdir($sDir);
|
173 |
} catch (Exception $e) {
|
174 |
Mage::logException($e);
|
175 |
+
Mage::helper('reflektion')->log(
|
176 |
+
$e->getMessage(),
|
177 |
+
Zend_Log::ERR,
|
178 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
179 |
+
);
|
180 |
}
|
181 |
|
182 |
return false;
|
183 |
+
|
184 |
+
}//end makeDir()
|
185 |
+
|
186 |
|
187 |
/**
|
188 |
* List files
|
189 |
+
*
|
190 |
* @param string directory
|
191 |
+
* @return array
|
192 |
*/
|
193 |
+
public function listFiles($sDir = '.')
|
194 |
+
{
|
195 |
try {
|
196 |
// Close connection
|
197 |
if (!$this->isConnected()) {
|
198 |
return false;
|
199 |
}
|
200 |
+
|
201 |
return $this->_oConnection->nlist($sDir);
|
202 |
} catch (Exception $e) {
|
203 |
Mage::logException($e);
|
204 |
+
Mage::helper('reflektion')->log(
|
205 |
+
$e->getMessage(),
|
206 |
+
Zend_Log::ERR,
|
207 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
208 |
+
);
|
209 |
}
|
210 |
|
211 |
return false;
|
212 |
+
|
213 |
+
}//end listFiles()
|
214 |
+
|
215 |
|
216 |
/**
|
217 |
* Transfer file
|
218 |
+
*
|
219 |
* @param string Local file path
|
220 |
+
* @return boolean
|
221 |
*/
|
222 |
+
public function putFile($sLocalFilePath)
|
223 |
+
{
|
224 |
try {
|
225 |
// Close connection
|
226 |
if (!$this->isConnected()) {
|
227 |
return false;
|
228 |
}
|
229 |
+
|
230 |
+
$sFilename = basename($sLocalFilePath);
|
231 |
+
// Get filename
|
232 |
// Transfer
|
233 |
$bSuccess = $this->_oConnection->put($sFilename, $sLocalFilePath, NET_SFTP_LOCAL_FILE);
|
234 |
if (!$bSuccess) {
|
235 |
+
Mage::helper('reflektion')->log(
|
236 |
+
'SFTP Error: '.$this->_oConnection->getLastSFTPError(),
|
237 |
+
Zend_Log::ERR,
|
238 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
239 |
+
);
|
240 |
}
|
241 |
+
|
242 |
return $bSuccess;
|
243 |
} catch (Exception $e) {
|
244 |
Mage::logException($e);
|
245 |
+
Mage::helper('reflektion')->log(
|
246 |
+
$e->getMessage(),
|
247 |
+
Zend_Log::ERR,
|
248 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
249 |
+
);
|
250 |
+
}//end try
|
251 |
|
252 |
return false;
|
253 |
+
|
254 |
+
}//end putFile()
|
255 |
+
|
256 |
|
257 |
/**
|
258 |
* Transfer file and delete when successful as one atomic operation
|
259 |
+
*
|
260 |
* @param string Local file path
|
261 |
+
* @return boolean
|
262 |
*/
|
263 |
+
public function putAndDeleteFile($sLocalFilePath)
|
264 |
+
{
|
265 |
try {
|
266 |
$bSuccess = $this->putFile($sLocalFilePath);
|
267 |
if ($bSuccess) {
|
268 |
$oIo = new Varien_Io_File();
|
269 |
$oIo->rm($sLocalFilePath);
|
270 |
}
|
271 |
+
|
272 |
return $bSuccess;
|
273 |
} catch (Exception $e) {
|
274 |
Mage::logException($e);
|
275 |
+
Mage::helper('reflektion')->log(
|
276 |
+
$e->getMessage(),
|
277 |
+
Zend_Log::ERR,
|
278 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
279 |
+
);
|
280 |
}
|
281 |
|
282 |
return false;
|
|
|
283 |
|
284 |
+
}//end putAndDeleteFile()
|
285 |
+
|
286 |
+
|
287 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Model/Feed/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Model/Feed/Base.php
CHANGED
@@ -6,27 +6,27 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Base file to manage attributes while exporting
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
12 |
-
|
13 |
-
protected $_optionValueMap
|
14 |
protected $_attrSetIdToName = array();
|
15 |
|
16 |
-
protected function _initAttributeSets($storeId = 0) {
|
17 |
-
$optionValueTable = Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value');
|
18 |
-
$sql = "select option_id, value from $optionValueTable where store_id=$storeId";
|
19 |
-
$attributeValues = Mage::getSingleton('core/resource')
|
20 |
-
->getConnection('default_read')
|
21 |
-
->fetchAll($sql);
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
foreach ($attributeValues as $values) {
|
25 |
$this->_attrSetIdToName[$values['option_id']] = $values['value'];
|
26 |
}
|
27 |
|
28 |
return $this;
|
29 |
-
|
|
|
|
|
30 |
|
31 |
/**
|
32 |
* Add custom attributes selected by magento admin to query
|
@@ -35,9 +35,14 @@ class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
|
35 |
* @param $customAttribs Comma separated list of attribute codes
|
36 |
* @param $fieldMap Reference to fieldmap where attribute codes should also be added
|
37 |
*/
|
38 |
-
protected function addCustomAttributes($collection, $customAttribs, &$fieldMap)
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
41 |
if (strlen(trim($customAttribs)) > 0) {
|
42 |
foreach (explode(',', $customAttribs) as $curAttrib) {
|
43 |
$curAttrib = trim($curAttrib);
|
@@ -46,23 +51,35 @@ class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
|
46 |
if ($_attribute === false) {
|
47 |
Mage::throwException("Attribte not found: {$curAttrib}");
|
48 |
}
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
if ($_attribute->getFrontendInput() == "select" || $_attribute->getFrontendInput() == "multiselect") {
|
52 |
-
Mage::helper('reflektion')->log(
|
53 |
-
|
|
|
|
|
|
|
|
|
54 |
}
|
|
|
55 |
// Attribute to select
|
56 |
$collection
|
57 |
-
|
58 |
-
|
59 |
// Attribute to map
|
60 |
-
$fieldMap['custom_'
|
61 |
-
}
|
62 |
-
}
|
63 |
|
64 |
return $collection;
|
65 |
-
|
|
|
|
|
66 |
|
67 |
/**
|
68 |
* Generate one feed for this website and store feed file at the specified path
|
@@ -70,34 +87,54 @@ class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
|
70 |
* @param $websiteId Id of the website for which to generate data feed file
|
71 |
* @param $exportPath Path to the folder where data feed files should be stored
|
72 |
* @param $bBaselineFile Should this file be a baseline file or an automated daily file
|
73 |
-
* @param $minEntityId Number representing minimum value for entity Id to export -
|
|
|
74 |
* @param $bDone Indicates when the feed generation is done
|
75 |
*/
|
76 |
-
public function generate($websiteId, $exportPath, $bBaselineFile, &$minEntityId, &$bDone)
|
77 |
-
|
78 |
-
Mage::helper('reflektion')->log(
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
$bDone = false;
|
83 |
|
84 |
-
$
|
85 |
|
86 |
-
$incrementalDate = date("Y-m-d-H-m-s", time());
|
87 |
-
|
88 |
$websiteName = parse_url(Mage::app()->getWebsite($websiteId)->getDefaultStore()->getBaseUrl(), PHP_URL_HOST);
|
89 |
|
90 |
-
// file generate
|
91 |
-
$filename = $exportPath
|
92 |
|
93 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
94 |
|
95 |
$collection = $this->getFeedCollection($websiteId);
|
96 |
|
97 |
-
|
98 |
if (!$bBaselineFile) {
|
99 |
-
$collection = $this->addIncrementalFilter($collection
|
100 |
}
|
|
|
101 |
$headerColumns = array_values($this->getFieldMap());
|
102 |
// Create output file
|
103 |
$file = Mage::helper('reflektion/csvfile');
|
@@ -105,23 +142,32 @@ class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
|
105 |
$bSuccess = $file->open($filename, $headerColumns);
|
106 |
|
107 |
if (!$bSuccess) {
|
108 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
109 |
return false;
|
110 |
}
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
113 |
$this->_initAttributeSets();
|
114 |
-
$rootCatId
|
115 |
$catlistHtml = Mage::helper('reflektion')->getTreeCategories($rootCatId);
|
116 |
foreach ($collection as $curRow) {
|
117 |
$curRowData = $curRow->getData();
|
118 |
-
$rowValues
|
119 |
|
120 |
foreach ($this->getFieldMap() as $mapKey => $mapValue) {
|
121 |
// If the attribute is a select or multiselect then we need to translate the
|
122 |
// option id value into the display value
|
123 |
if (array_key_exists($mapKey, $this->_optionValueMap)) {
|
124 |
-
$items
|
125 |
$attrList = array();
|
126 |
foreach ($items as $item) {
|
127 |
if (array_key_exists($item, $this->_attrSetIdToName)) {
|
@@ -130,35 +176,44 @@ class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
|
130 |
$attrList[] = "";
|
131 |
}
|
132 |
}
|
|
|
133 |
$rowValues[$mapValue] = implode(",", $attrList);
|
134 |
} else {
|
135 |
if ($mapKey == "category_ids") {
|
136 |
$arrayTempCat = array();
|
137 |
-
$arrayCats
|
138 |
foreach ($arrayCats as $arrayCat) {
|
139 |
-
|
140 |
-
|
|
|
141 |
}
|
|
|
142 |
$curRowData[$mapKey] = implode(" | ", $arrayTempCat);
|
143 |
}
|
|
|
144 |
if (array_key_exists($mapKey, $curRowData)) {
|
145 |
$rowValues[$mapValue] = $curRowData[$mapKey];
|
146 |
} else {
|
147 |
$rowValues[$mapValue] = "";
|
148 |
}
|
149 |
-
}
|
150 |
-
}
|
151 |
|
152 |
$bSuccess = $file->writeRow($rowValues);
|
153 |
if (!$bSuccess) {
|
154 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
155 |
$file->close();
|
156 |
return false;
|
157 |
}
|
158 |
|
159 |
// Collect last entity Id and generate new minEntityId param
|
160 |
-
$minEntityId = $curRow->getEntityId() + 1;
|
161 |
-
}
|
|
|
162 |
// Check if export is done
|
163 |
if (count($collection) > 0) {
|
164 |
$bDone = true;
|
@@ -166,9 +221,15 @@ class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
|
166 |
|
167 |
$bSuccess = $file->close();
|
168 |
if (!$bSuccess) {
|
169 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
170 |
return false;
|
171 |
}
|
172 |
-
}
|
173 |
|
174 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Base file to manage attributes while exporting
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_Feed_Base extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
protected $_optionValueMap = array();
|
14 |
protected $_attrSetIdToName = array();
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
protected function _initAttributeSets($storeId = 0)
|
18 |
+
{
|
19 |
+
$attributeValues = Mage::getModel('eav/entity_attribute_option')
|
20 |
+
->getCollection()->setStoreFilter($storeId);
|
21 |
+
// create an array
|
22 |
foreach ($attributeValues as $values) {
|
23 |
$this->_attrSetIdToName[$values['option_id']] = $values['value'];
|
24 |
}
|
25 |
|
26 |
return $this;
|
27 |
+
|
28 |
+
}//end _initAttributeSets()
|
29 |
+
|
30 |
|
31 |
/**
|
32 |
* Add custom attributes selected by magento admin to query
|
35 |
* @param $customAttribs Comma separated list of attribute codes
|
36 |
* @param $fieldMap Reference to fieldmap where attribute codes should also be added
|
37 |
*/
|
38 |
+
protected function addCustomAttributes($collection, $customAttribs, &$fieldMap)
|
39 |
+
{
|
40 |
+
Mage::helper('reflektion')->log(
|
41 |
+
"Adding custom attributes include in query: {$customAttribs}",
|
42 |
+
Zend_Log::INFO,
|
43 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
44 |
+
);
|
45 |
+
// Check if we have any custom attributes
|
46 |
if (strlen(trim($customAttribs)) > 0) {
|
47 |
foreach (explode(',', $customAttribs) as $curAttrib) {
|
48 |
$curAttrib = trim($curAttrib);
|
51 |
if ($_attribute === false) {
|
52 |
Mage::throwException("Attribte not found: {$curAttrib}");
|
53 |
}
|
54 |
+
|
55 |
+
Mage::helper('reflektion')->log(
|
56 |
+
"Adding attribute to query: {$curAttrib}",
|
57 |
+
Zend_Log::DEBUG,
|
58 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
59 |
+
);
|
60 |
|
61 |
if ($_attribute->getFrontendInput() == "select" || $_attribute->getFrontendInput() == "multiselect") {
|
62 |
+
Mage::helper('reflektion')->log(
|
63 |
+
"Note - Attribute needs translation",
|
64 |
+
Zend_Log::DEBUG,
|
65 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
66 |
+
);
|
67 |
+
$this->_optionValueMap['custom_'.$curAttrib] = true;
|
68 |
}
|
69 |
+
|
70 |
// Attribute to select
|
71 |
$collection
|
72 |
+
->addExpressionAttributeToSelect('custom_'.$curAttrib, "{{".$curAttrib."}}", $curAttrib)
|
73 |
+
->addAttributeToSelect($curAttrib);
|
74 |
// Attribute to map
|
75 |
+
$fieldMap['custom_'.$curAttrib] = 'custom_'.$curAttrib;
|
76 |
+
}//end foreach
|
77 |
+
}//end if
|
78 |
|
79 |
return $collection;
|
80 |
+
|
81 |
+
}//end addCustomAttributes()
|
82 |
+
|
83 |
|
84 |
/**
|
85 |
* Generate one feed for this website and store feed file at the specified path
|
87 |
* @param $websiteId Id of the website for which to generate data feed file
|
88 |
* @param $exportPath Path to the folder where data feed files should be stored
|
89 |
* @param $bBaselineFile Should this file be a baseline file or an automated daily file
|
90 |
+
* @param $minEntityId Number representing minimum value for entity Id to export -
|
91 |
+
* This acts as a placeholder for where the feed export left off
|
92 |
* @param $bDone Indicates when the feed generation is done
|
93 |
*/
|
94 |
+
public function generate($websiteId, $exportPath, $bBaselineFile, &$minEntityId, &$bDone)
|
95 |
+
{
|
96 |
+
Mage::helper('reflektion')->log(
|
97 |
+
'Generating '.$this->getFileNameKey().' data feed for website with Id: '.$websiteId,
|
98 |
+
Zend_Log::INFO,
|
99 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
100 |
+
);
|
101 |
+
Mage::helper('reflektion')->log(
|
102 |
+
"Export path: {$exportPath}",
|
103 |
+
Zend_Log::INFO,
|
104 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
105 |
+
);
|
106 |
+
Mage::helper('reflektion')->log(
|
107 |
+
"Baseline feed: {$bBaselineFile}",
|
108 |
+
Zend_Log::INFO,
|
109 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
110 |
+
);
|
111 |
+
Mage::helper('reflektion')->log(
|
112 |
+
"Min entity_id: {$minEntityId}",
|
113 |
+
Zend_Log::INFO,
|
114 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
115 |
+
);
|
116 |
|
117 |
$bDone = false;
|
118 |
|
119 |
+
$incrementalDate = Mage::getSingleton('core/date')->date("Y-m-d-H-m-s");
|
120 |
|
|
|
|
|
121 |
$websiteName = parse_url(Mage::app()->getWebsite($websiteId)->getDefaultStore()->getBaseUrl(), PHP_URL_HOST);
|
122 |
|
123 |
+
// file generate
|
124 |
+
$filename = $exportPath.DS.$websiteName.'_'.$websiteId.'_product_feed.csv';
|
125 |
|
126 |
+
Mage::helper('reflektion')->log(
|
127 |
+
"Output Filename: {$filename}",
|
128 |
+
Zend_Log::INFO,
|
129 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
130 |
+
);
|
131 |
|
132 |
$collection = $this->getFeedCollection($websiteId);
|
133 |
|
|
|
134 |
if (!$bBaselineFile) {
|
135 |
+
$collection = $this->addIncrementalFilter($collection);
|
136 |
}
|
137 |
+
|
138 |
$headerColumns = array_values($this->getFieldMap());
|
139 |
// Create output file
|
140 |
$file = Mage::helper('reflektion/csvfile');
|
142 |
$bSuccess = $file->open($filename, $headerColumns);
|
143 |
|
144 |
if (!$bSuccess) {
|
145 |
+
Mage::helper('reflektion')->log(
|
146 |
+
'Failed to open data feed file:'.$filename,
|
147 |
+
Zend_Log::ERR,
|
148 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
149 |
+
);
|
150 |
return false;
|
151 |
}
|
152 |
+
|
153 |
+
// get all the website attribute
|
154 |
+
Mage::helper('reflektion')->log(
|
155 |
+
'Initializing attribute values',
|
156 |
+
Zend_Log::INFO,
|
157 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
158 |
+
);
|
159 |
$this->_initAttributeSets();
|
160 |
+
$rootCatId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getRootCategoryId();
|
161 |
$catlistHtml = Mage::helper('reflektion')->getTreeCategories($rootCatId);
|
162 |
foreach ($collection as $curRow) {
|
163 |
$curRowData = $curRow->getData();
|
164 |
+
$rowValues = array();
|
165 |
|
166 |
foreach ($this->getFieldMap() as $mapKey => $mapValue) {
|
167 |
// If the attribute is a select or multiselect then we need to translate the
|
168 |
// option id value into the display value
|
169 |
if (array_key_exists($mapKey, $this->_optionValueMap)) {
|
170 |
+
$items = explode(",", $curRowData[$mapKey]);
|
171 |
$attrList = array();
|
172 |
foreach ($items as $item) {
|
173 |
if (array_key_exists($item, $this->_attrSetIdToName)) {
|
176 |
$attrList[] = "";
|
177 |
}
|
178 |
}
|
179 |
+
|
180 |
$rowValues[$mapValue] = implode(",", $attrList);
|
181 |
} else {
|
182 |
if ($mapKey == "category_ids") {
|
183 |
$arrayTempCat = array();
|
184 |
+
$arrayCats = explode(" | ", $curRowData[$mapKey]);
|
185 |
foreach ($arrayCats as $arrayCat) {
|
186 |
+
if (isset($catlistHtml[$arrayCat])) {
|
187 |
+
$arrayTempCat[] = $catlistHtml[$arrayCat];
|
188 |
+
}
|
189 |
}
|
190 |
+
|
191 |
$curRowData[$mapKey] = implode(" | ", $arrayTempCat);
|
192 |
}
|
193 |
+
|
194 |
if (array_key_exists($mapKey, $curRowData)) {
|
195 |
$rowValues[$mapValue] = $curRowData[$mapKey];
|
196 |
} else {
|
197 |
$rowValues[$mapValue] = "";
|
198 |
}
|
199 |
+
}//end if
|
200 |
+
}//end foreach
|
201 |
|
202 |
$bSuccess = $file->writeRow($rowValues);
|
203 |
if (!$bSuccess) {
|
204 |
+
Mage::helper('reflektion')->log(
|
205 |
+
'Failed to write to data feed file: '.$filename,
|
206 |
+
Zend_Log::ERR,
|
207 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
208 |
+
);
|
209 |
$file->close();
|
210 |
return false;
|
211 |
}
|
212 |
|
213 |
// Collect last entity Id and generate new minEntityId param
|
214 |
+
$minEntityId = ($curRow->getEntityId() + 1);
|
215 |
+
}//end foreach
|
216 |
+
|
217 |
// Check if export is done
|
218 |
if (count($collection) > 0) {
|
219 |
$bDone = true;
|
221 |
|
222 |
$bSuccess = $file->close();
|
223 |
if (!$bSuccess) {
|
224 |
+
Mage::helper('reflektion')->log(
|
225 |
+
'Failed to close data feed file: '.$filename,
|
226 |
+
Zend_Log::ERR,
|
227 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
228 |
+
);
|
229 |
return false;
|
230 |
}
|
|
|
231 |
|
232 |
+
}//end generate()
|
233 |
+
|
234 |
+
|
235 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Feed/Product.php
CHANGED
@@ -8,7 +8,8 @@
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Product attributes operations
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Feed_Product extends Reflektion_Catalogexport_Model_Feed_Base
|
|
|
12 |
|
13 |
// Magento product fields to Reflektion Product Feed
|
14 |
|
@@ -29,12 +30,14 @@ class Reflektion_Catalogexport_Model_Feed_Product extends Reflektion_Catalogexpo
|
|
29 |
'type_id' => 'Product Type',
|
30 |
);
|
31 |
|
32 |
-
public function getFieldMap()
|
|
|
33 |
return $this->fieldMap;
|
34 |
}
|
35 |
|
36 |
// File name key
|
37 |
-
public function getFileNameKey()
|
|
|
38 |
return 'product';
|
39 |
}
|
40 |
|
@@ -43,7 +46,8 @@ class Reflektion_Catalogexport_Model_Feed_Product extends Reflektion_Catalogexpo
|
|
43 |
*
|
44 |
* @param $websiteId Which website to query for collection
|
45 |
*/
|
46 |
-
public function getFeedCollection($websiteId)
|
|
|
47 |
|
48 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
49 |
|
@@ -61,87 +65,96 @@ class Reflektion_Catalogexport_Model_Feed_Product extends Reflektion_Catalogexpo
|
|
61 |
->addPriceData(null, $websiteId); //Have to use this version so you can set the website id
|
62 |
// Add stock level fields
|
63 |
$collection->joinTable(
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
|
66 |
$prodCatTable = $collection->getTable('catalog/category_product');
|
67 |
-
$collection->getSelect()
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
78 |
|
79 |
// Add full product page URL
|
80 |
$baseUrl = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getBaseUrl();
|
81 |
$coreRewriteTable = $collection->getTable('core/url_rewrite');
|
82 |
-
$collection->getSelect()
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
93 |
|
94 |
// Add product image URL
|
95 |
-
$imageBaseURL = Mage::app()->getWebsite($websiteId)
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
);
|
102 |
|
103 |
-
$collection
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
" '')", 'small_image'
|
108 |
);
|
109 |
|
110 |
-
$collection
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
" '')", 'thumbnail'
|
115 |
);
|
116 |
|
117 |
// Check Status, visibility and is_in_stock
|
118 |
-
$collection
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
"at_qty.qty, at_qty.is_in_stock)," .
|
128 |
-
"at_qty.is_in_stock))", 'type_id'
|
129 |
);
|
130 |
|
131 |
// Custom attributes to feed
|
132 |
-
$customAttribs = Mage::app()->getWebsite($websiteId)
|
|
|
133 |
$collection = $this->addCustomAttributes($collection, $customAttribs, $this->fieldMap);
|
134 |
|
135 |
return $collection;
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
-
* Add filter to collection to make it only include records necessary for automatic
|
|
|
140 |
*
|
141 |
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
142 |
*/
|
143 |
-
protected function addIncrementalFilter($collection
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
145 |
// Stock items Filter
|
146 |
$collection->
|
147 |
addAttributeToFilter('is_in_stock', 1);
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Product attributes operations
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_Feed_Product extends Reflektion_Catalogexport_Model_Feed_Base
|
12 |
+
{
|
13 |
|
14 |
// Magento product fields to Reflektion Product Feed
|
15 |
|
30 |
'type_id' => 'Product Type',
|
31 |
);
|
32 |
|
33 |
+
public function getFieldMap()
|
34 |
+
{
|
35 |
return $this->fieldMap;
|
36 |
}
|
37 |
|
38 |
// File name key
|
39 |
+
public function getFileNameKey()
|
40 |
+
{
|
41 |
return 'product';
|
42 |
}
|
43 |
|
46 |
*
|
47 |
* @param $websiteId Which website to query for collection
|
48 |
*/
|
49 |
+
public function getFeedCollection($websiteId)
|
50 |
+
{
|
51 |
|
52 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
53 |
|
65 |
->addPriceData(null, $websiteId); //Have to use this version so you can set the website id
|
66 |
// Add stock level fields
|
67 |
$collection->joinTable(
|
68 |
+
array('at_qty' => 'cataloginventory/stock_item'),
|
69 |
+
'product_id=entity_id',
|
70 |
+
array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'),
|
71 |
+
'{{table}}.stock_id=1', 'left'
|
72 |
+
);
|
73 |
|
74 |
$prodCatTable = $collection->getTable('catalog/category_product');
|
75 |
+
$collection->getSelect()->columns(
|
76 |
+
array(
|
77 |
+
'category_ids' =>
|
78 |
+
' (select ' .
|
79 |
+
" group_concat(distinct "
|
80 |
+
. "pc.category_id"
|
81 |
+
. " separator ' | ') " .
|
82 |
+
' from ' . $prodCatTable . ' pc ' .
|
83 |
+
' where ' .
|
84 |
+
' pc.product_id = e.entity_id) '
|
85 |
+
,)
|
86 |
+
);
|
87 |
|
88 |
// Add full product page URL
|
89 |
$baseUrl = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getBaseUrl();
|
90 |
$coreRewriteTable = $collection->getTable('core/url_rewrite');
|
91 |
+
$collection->getSelect()->columns(
|
92 |
+
array(
|
93 |
+
'product_url' =>
|
94 |
+
" (select " .
|
95 |
+
" concat('{$baseUrl}', url.request_path) " .
|
96 |
+
" from " .
|
97 |
+
" {$coreRewriteTable} url " .
|
98 |
+
" where " .
|
99 |
+
" id_path = concat('product/', e.entity_id) " .
|
100 |
+
" limit 1) "
|
101 |
+
,)
|
102 |
+
);
|
103 |
|
104 |
// Add product image URL
|
105 |
+
$imageBaseURL = Mage::app()->getWebsite($websiteId)
|
106 |
+
->getDefaultStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "catalog/product";
|
107 |
+
$collection->addExpressionAttributeToSelect(
|
108 |
+
'image_url', "if({{image}} <> 'no_selection', " .
|
109 |
+
" concat('{$imageBaseURL}', {{image}}), " .
|
110 |
+
" '')", 'image'
|
111 |
);
|
112 |
|
113 |
+
$collection->addExpressionAttributeToSelect(
|
114 |
+
'small_image', "if({{small_image}} <> 'no_selection', " .
|
115 |
+
" concat('{$imageBaseURL}', {{small_image}}), " .
|
116 |
+
" '')", 'small_image'
|
|
|
117 |
);
|
118 |
|
119 |
+
$collection->addExpressionAttributeToSelect(
|
120 |
+
'thumbnail', "if({{thumbnail}} <> 'no_selection', " .
|
121 |
+
" concat('{$imageBaseURL}', {{thumbnail}}), " .
|
122 |
+
" '')", 'thumbnail'
|
|
|
123 |
);
|
124 |
|
125 |
// Check Status, visibility and is_in_stock
|
126 |
+
$collection->addExpressionAttributeToSelect('cur_status', "{{status}}", 'status');
|
127 |
+
|
128 |
+
$collection->addExpressionAttributeToSelect(
|
129 |
+
'adj_qty', "if({{type_id}} = 'simple', " .
|
130 |
+
"at_qty.qty, " .
|
131 |
+
"if (at_qty.is_in_stock=1, " .
|
132 |
+
"if (at_qty.qty>0, " .
|
133 |
+
"at_qty.qty, at_qty.is_in_stock)," .
|
134 |
+
"at_qty.is_in_stock))", 'type_id'
|
|
|
|
|
135 |
);
|
136 |
|
137 |
// Custom attributes to feed
|
138 |
+
$customAttribs = Mage::app()->getWebsite($websiteId)
|
139 |
+
->getConfig('reflektion_datafeeds/feedsenabled/product_attributes');
|
140 |
$collection = $this->addCustomAttributes($collection, $customAttribs, $this->fieldMap);
|
141 |
|
142 |
return $collection;
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Add filter to collection to make it only include records necessary for automatic
|
147 |
+
* daily feed (instead of one-time baseline feed).
|
148 |
*
|
149 |
* @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
|
150 |
*/
|
151 |
+
protected function addIncrementalFilter($collection)
|
152 |
+
{
|
153 |
+
Mage::helper('reflektion')->log(
|
154 |
+
'Adding incremental filters to product feed',
|
155 |
+
Zend_Log::INFO,
|
156 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
157 |
+
);
|
158 |
// Stock items Filter
|
159 |
$collection->
|
160 |
addAttributeToFilter('is_in_stock', 1);
|
app/code/community/Reflektion/Catalogexport/Model/Generatefeeds.php
CHANGED
@@ -6,28 +6,33 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Generate catalog product feeds output(CSV) in queue
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Generatefeeds
|
|
|
12 |
|
13 |
const REFLEKTION_FEED_PATH = 'reflektion/feeds';
|
14 |
|
15 |
-
protected static $feedTypes = array(
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
protected function _construct() {
|
20 |
-
|
21 |
-
}
|
22 |
|
23 |
/**
|
24 |
* Return a list of possible feed types
|
25 |
*
|
26 |
* @returns array Array of all known feeds types
|
27 |
*/
|
28 |
-
public static function getFeedTypes()
|
|
|
29 |
return self::$feedTypes;
|
30 |
-
|
|
|
|
|
31 |
|
32 |
/**
|
33 |
* Generate data feeds for this specific website
|
@@ -35,22 +40,32 @@ class Reflektion_Catalogexport_Model_Generatefeeds {
|
|
35 |
* @param $websiteId Id of the website for which to generate data feeds
|
36 |
* @param $bBaselineFile Should this file be a baseline file or an automated daily file
|
37 |
* @param $feedType Type of feed to generate, null = generate all feeds
|
38 |
-
* @param $minEntityId Number representing minimum value for entity Id to export -
|
|
|
39 |
*/
|
40 |
-
public function generateForWebsite($websiteId, $bBaselineFile, $feedType, &$minEntityId, &$bDone)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
|
48 |
-
$
|
49 |
-
$
|
|
|
50 |
$oIo->checkAndCreateFolder($feedExportPath);
|
51 |
|
52 |
-
$modelFeed = Mage::getModel('reflektion/feed_'
|
53 |
$modelFeed->generate($websiteId, $feedExportPath, $bBaselineFile, $minEntityId, $bDone);
|
54 |
-
}
|
55 |
|
56 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Generate catalog product feeds output(CSV) in queue
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_Generatefeeds
|
12 |
+
{
|
13 |
|
14 |
const REFLEKTION_FEED_PATH = 'reflektion/feeds';
|
15 |
|
16 |
+
protected static $feedTypes = array('product');
|
17 |
+
|
18 |
+
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
|
22 |
+
}//end _construct()
|
23 |
|
|
|
|
|
|
|
24 |
|
25 |
/**
|
26 |
* Return a list of possible feed types
|
27 |
*
|
28 |
* @returns array Array of all known feeds types
|
29 |
*/
|
30 |
+
public static function getFeedTypes()
|
31 |
+
{
|
32 |
return self::$feedTypes;
|
33 |
+
|
34 |
+
}//end getFeedTypes()
|
35 |
+
|
36 |
|
37 |
/**
|
38 |
* Generate data feeds for this specific website
|
40 |
* @param $websiteId Id of the website for which to generate data feeds
|
41 |
* @param $bBaselineFile Should this file be a baseline file or an automated daily file
|
42 |
* @param $feedType Type of feed to generate, null = generate all feeds
|
43 |
+
* @param $minEntityId Number representing minimum value for entity Id to export -
|
44 |
+
* This acts as a placeholder for where the feed export left off
|
45 |
*/
|
46 |
+
public function generateForWebsite($websiteId, $bBaselineFile, $feedType, &$minEntityId, &$bDone)
|
47 |
+
{
|
48 |
+
Mage::helper('reflektion')->log(
|
49 |
+
'Memory usage: '.memory_get_usage(),
|
50 |
+
Zend_Log::DEBUG,
|
51 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
52 |
+
);
|
53 |
+
$website = Mage::app()->getWebsite($websiteId);
|
54 |
+
if ($website->getConfig('reflektion_datafeeds/general/allfeedsenabled') != 'enabled'
|
55 |
+
|| $website->getConfig('reflektion_datafeeds/feedsenabled/'.$feedType) != 'enabled'
|
56 |
+
) {
|
57 |
+
Mage::throwException('Data feeds or feedtype '.$feedType.' not enabled for website: '.$websiteId);
|
58 |
}
|
59 |
|
60 |
+
$dir = Mage::getConfig()->getVarDir().DS;
|
61 |
+
$feedExportPath = $dir.Reflektion_Catalogexport_Model_Generatefeeds::REFLEKTION_FEED_PATH;
|
62 |
+
$oIo = new Varien_Io_File();
|
63 |
$oIo->checkAndCreateFolder($feedExportPath);
|
64 |
|
65 |
+
$modelFeed = Mage::getModel('reflektion/feed_'.$feedType);
|
66 |
$modelFeed->generate($websiteId, $feedExportPath, $bBaselineFile, $minEntityId, $bDone);
|
|
|
67 |
|
68 |
+
}//end generateForWebsite()
|
69 |
+
|
70 |
+
|
71 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Job.php
CHANGED
@@ -6,71 +6,102 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Generate Jobs in queue - manual or cron jobs
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Job extends Mage_Core_Model_Abstract
|
|
|
12 |
|
13 |
/**
|
14 |
* Job Types
|
15 |
*/
|
16 |
const TYPE_GENERATE_BASELINE = 1;
|
17 |
-
const TYPE_GENERATE_DAILY
|
18 |
-
const TYPE_TRANSFER
|
19 |
-
const TYPE_TRANSFER_MANUAL
|
20 |
|
21 |
/**
|
22 |
* Statuses
|
23 |
*/
|
24 |
const STATUS_SCHEDULED = 1;
|
25 |
-
const STATUS_RUNNING
|
26 |
const STATUS_COMPLETED = 3;
|
27 |
-
const STATUS_ERROR
|
28 |
-
const STATUS_MANUAL
|
29 |
|
30 |
-
|
|
|
|
|
31 |
parent::_construct();
|
32 |
$this->_init('reflektion/job');
|
33 |
-
|
|
|
|
|
34 |
|
35 |
/**
|
36 |
* Pull the next job to run from the queue and set status to running
|
37 |
*/
|
38 |
-
public static function getNextJobFromQueue()
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
$collection = Mage::getResourceModel('reflektion/job_collection');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
$
|
43 |
-
|
44 |
-
$collection->getSelect()
|
45 |
-
->where('status = ' . Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED . ' or status = ' . Reflektion_Catalogexport_Model_Job::STATUS_RUNNING)
|
46 |
-
->where(Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED . " not in (select status from {$table} mbj2 where mbj2.job_id = main_table.dependent_on_job_id) ")
|
47 |
-
->order('job_id')
|
48 |
-
->limit(1);
|
49 |
|
50 |
foreach ($collection as $job) {
|
51 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
52 |
$job->setStatus(Reflektion_Catalogexport_Model_Job::STATUS_RUNNING);
|
53 |
$job->setStartedAt(Mage::getSingleton('core/date')->gmtDate());
|
54 |
$job->save();
|
55 |
return $job;
|
56 |
}
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
58 |
return false;
|
59 |
-
|
|
|
|
|
60 |
|
61 |
/**
|
62 |
* Create a new job object
|
63 |
*/
|
64 |
-
public static function createJob($dependentOnJobId, $websiteId, $type, $feedType, $isBaseTran = 0)
|
|
|
65 |
if (Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_BASELINE == $type) {
|
66 |
$status = Reflektion_Catalogexport_Model_Job::STATUS_MANUAL;
|
67 |
-
}
|
68 |
$status = Reflektion_Catalogexport_Model_Job::STATUS_MANUAL;
|
69 |
-
$type
|
70 |
} else {
|
71 |
$status = Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED;
|
72 |
}
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
$newJob = Mage::getModel('reflektion/job');
|
75 |
$newJob->setDependentOnJobId($dependentOnJobId);
|
76 |
$newJob->setMinEntityId(0);
|
@@ -81,50 +112,72 @@ class Reflektion_Catalogexport_Model_Job extends Mage_Core_Model_Abstract {
|
|
81 |
$newJob->setStatus($status);
|
82 |
$newJob->save();
|
83 |
return $newJob;
|
84 |
-
|
|
|
|
|
85 |
|
86 |
/**
|
87 |
* Schedule all the necessary daily jobs for today
|
88 |
*/
|
89 |
-
public static function scheduleAllDailyJobs()
|
|
|
90 |
$websites = Mage::app()->getWebsites(false, true);
|
91 |
foreach ($websites as $website) {
|
92 |
Reflektion_Catalogexport_Model_Job::scheduleJobs($website->getId(), false);
|
93 |
}
|
94 |
-
|
|
|
|
|
95 |
|
96 |
/**
|
97 |
* Schedule all daily or baseline jobs for all websites to run immediately
|
98 |
*/
|
99 |
-
public static function scheduleJobsAllWebsites($bBaselineFile)
|
|
|
100 |
$websites = Mage::app()->getWebsites(false, true);
|
101 |
foreach ($websites as $website) {
|
102 |
$websiteId = $website->getId();
|
103 |
Reflektion_Catalogexport_Model_Job::scheduleJobs($websiteId, $bBaselineFile);
|
104 |
}
|
105 |
-
|
|
|
|
|
106 |
|
107 |
/**
|
108 |
* Schedule baseline or incremental daily jobs to run immediately
|
109 |
*/
|
110 |
-
public static function scheduleJobs($websiteId, $bBaselineFile)
|
111 |
-
|
112 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
$lastJobId = null;
|
114 |
-
if (Mage::app()->getWebsite($websiteId)->getConfig('reflektion_datafeeds/general/allfeedsenabled') != 'enabled'
|
|
|
115 |
return;
|
116 |
}
|
|
|
117 |
// Generate jobs - enabled feeds
|
118 |
foreach (Reflektion_Catalogexport_Model_Generatefeeds::getFeedTypes() as $curType) {
|
119 |
// Create feed job
|
120 |
-
|
|
|
121 |
// Check manual or daily
|
122 |
$jobType = 0;
|
123 |
if ($bBaselineFile) {
|
124 |
-
$jobType
|
125 |
$isBaseTran = 1;
|
126 |
} else {
|
127 |
-
$jobType
|
128 |
$isBaseTran = 0;
|
129 |
}
|
130 |
|
@@ -135,28 +188,73 @@ class Reflektion_Catalogexport_Model_Job extends Mage_Core_Model_Abstract {
|
|
135 |
}
|
136 |
|
137 |
// Transfer feeds job
|
138 |
-
$job = Reflektion_Catalogexport_Model_Job::createJob(
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
$job->save();
|
140 |
-
|
|
|
|
|
141 |
|
142 |
/**
|
143 |
* Run job
|
144 |
*/
|
145 |
-
public function run()
|
|
|
146 |
try {
|
147 |
-
Mage::helper('reflektion')->log(
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
Mage::helper('reflektion')->log(
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
// Execute the job
|
156 |
$this->executeJob();
|
157 |
|
158 |
-
Mage::helper('reflektion')->log(
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
} catch (Exception $e) {
|
161 |
// Fail this job
|
162 |
$this->setStatus(Reflektion_Catalogexport_Model_Job::STATUS_ERROR);
|
@@ -165,59 +263,79 @@ class Reflektion_Catalogexport_Model_Job extends Mage_Core_Model_Abstract {
|
|
165 |
$this->save();
|
166 |
// Log exception
|
167 |
Mage::logException($e);
|
168 |
-
Mage::helper('reflektion')->log(
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
return $this;
|
174 |
-
|
|
|
|
|
175 |
|
176 |
/**
|
177 |
* Execute this job
|
178 |
*/
|
179 |
-
protected function executeJob()
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
}
|
|
|
183 |
$bDone = false;
|
184 |
|
185 |
// Switch on job type
|
186 |
switch ($this->getType()) {
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
}
|
214 |
|
215 |
// Job as succeeded
|
216 |
if ($bDone) {
|
217 |
$this->setStatus(Reflektion_Catalogexport_Model_Job::STATUS_COMPLETED);
|
218 |
$this->setEndedAt(Mage::getSingleton('core/date')->gmtDate());
|
219 |
}
|
|
|
220 |
$this->save();
|
221 |
-
}
|
222 |
|
223 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Generate Jobs in queue - manual or cron jobs
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_Job extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
|
14 |
/**
|
15 |
* Job Types
|
16 |
*/
|
17 |
const TYPE_GENERATE_BASELINE = 1;
|
18 |
+
const TYPE_GENERATE_DAILY = 2;
|
19 |
+
const TYPE_TRANSFER = 3;
|
20 |
+
const TYPE_TRANSFER_MANUAL = 4;
|
21 |
|
22 |
/**
|
23 |
* Statuses
|
24 |
*/
|
25 |
const STATUS_SCHEDULED = 1;
|
26 |
+
const STATUS_RUNNING = 2;
|
27 |
const STATUS_COMPLETED = 3;
|
28 |
+
const STATUS_ERROR = 4;
|
29 |
+
const STATUS_MANUAL = 5;
|
30 |
|
31 |
+
|
32 |
+
public function _construct()
|
33 |
+
{
|
34 |
parent::_construct();
|
35 |
$this->_init('reflektion/job');
|
36 |
+
|
37 |
+
}//end _construct()
|
38 |
+
|
39 |
|
40 |
/**
|
41 |
* Pull the next job to run from the queue and set status to running
|
42 |
*/
|
43 |
+
public static function getNextJobFromQueue()
|
44 |
+
{
|
45 |
+
Mage::helper('reflektion')->log(
|
46 |
+
'Getting next job from the queue.',
|
47 |
+
Zend_Log::INFO,
|
48 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
49 |
+
);
|
50 |
$collection = Mage::getResourceModel('reflektion/job_collection');
|
51 |
+
$collection->addFieldToFilter(
|
52 |
+
'status',
|
53 |
+
array(
|
54 |
+
'in' => array(
|
55 |
+
Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED,
|
56 |
+
Reflektion_Catalogexport_Model_Job::STATUS_RUNNING,
|
57 |
+
),
|
58 |
+
)
|
59 |
+
);
|
60 |
|
61 |
+
$collection->addOrder('job_id', 'ASC');
|
62 |
+
$collection->setPageSize(1);
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
foreach ($collection as $job) {
|
65 |
+
Mage::helper('reflektion')->log(
|
66 |
+
'Found job id: '.$job->getJobId(),
|
67 |
+
Zend_Log::INFO,
|
68 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
69 |
+
);
|
70 |
$job->setStatus(Reflektion_Catalogexport_Model_Job::STATUS_RUNNING);
|
71 |
$job->setStartedAt(Mage::getSingleton('core/date')->gmtDate());
|
72 |
$job->save();
|
73 |
return $job;
|
74 |
}
|
75 |
+
|
76 |
+
Mage::helper('reflektion')->log(
|
77 |
+
'No jobs found.',
|
78 |
+
Zend_Log::INFO,
|
79 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
80 |
+
);
|
81 |
return false;
|
82 |
+
|
83 |
+
}//end getNextJobFromQueue()
|
84 |
+
|
85 |
|
86 |
/**
|
87 |
* Create a new job object
|
88 |
*/
|
89 |
+
public static function createJob($dependentOnJobId, $websiteId, $type, $feedType, $isBaseTran = 0)
|
90 |
+
{
|
91 |
if (Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_BASELINE == $type) {
|
92 |
$status = Reflektion_Catalogexport_Model_Job::STATUS_MANUAL;
|
93 |
+
} else if ($isBaseTran == 1) {
|
94 |
$status = Reflektion_Catalogexport_Model_Job::STATUS_MANUAL;
|
95 |
+
$type = Reflektion_Catalogexport_Model_Job::TYPE_TRANSFER_MANUAL;
|
96 |
} else {
|
97 |
$status = Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED;
|
98 |
}
|
99 |
+
|
100 |
+
Mage::helper('reflektion')->log(
|
101 |
+
'Scheduling new job.',
|
102 |
+
Zend_Log::INFO,
|
103 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
104 |
+
);
|
105 |
$newJob = Mage::getModel('reflektion/job');
|
106 |
$newJob->setDependentOnJobId($dependentOnJobId);
|
107 |
$newJob->setMinEntityId(0);
|
112 |
$newJob->setStatus($status);
|
113 |
$newJob->save();
|
114 |
return $newJob;
|
115 |
+
|
116 |
+
}//end createJob()
|
117 |
+
|
118 |
|
119 |
/**
|
120 |
* Schedule all the necessary daily jobs for today
|
121 |
*/
|
122 |
+
public static function scheduleAllDailyJobs()
|
123 |
+
{
|
124 |
$websites = Mage::app()->getWebsites(false, true);
|
125 |
foreach ($websites as $website) {
|
126 |
Reflektion_Catalogexport_Model_Job::scheduleJobs($website->getId(), false);
|
127 |
}
|
128 |
+
|
129 |
+
}//end scheduleAllDailyJobs()
|
130 |
+
|
131 |
|
132 |
/**
|
133 |
* Schedule all daily or baseline jobs for all websites to run immediately
|
134 |
*/
|
135 |
+
public static function scheduleJobsAllWebsites($bBaselineFile)
|
136 |
+
{
|
137 |
$websites = Mage::app()->getWebsites(false, true);
|
138 |
foreach ($websites as $website) {
|
139 |
$websiteId = $website->getId();
|
140 |
Reflektion_Catalogexport_Model_Job::scheduleJobs($websiteId, $bBaselineFile);
|
141 |
}
|
142 |
+
|
143 |
+
}//end scheduleJobsAllWebsites()
|
144 |
+
|
145 |
|
146 |
/**
|
147 |
* Schedule baseline or incremental daily jobs to run immediately
|
148 |
*/
|
149 |
+
public static function scheduleJobs($websiteId, $bBaselineFile)
|
150 |
+
{
|
151 |
+
Mage::helper('reflektion')->log(
|
152 |
+
'Scheduling jobs for website: '.$websiteId,
|
153 |
+
Zend_Log::INFO,
|
154 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
155 |
+
);
|
156 |
+
Mage::helper('reflektion')->log(
|
157 |
+
'All feeds for website set to: '.Mage::app()->getWebsite($websiteId)->getConfig(
|
158 |
+
'reflektion_datafeeds/general/allfeedsenabled'
|
159 |
+
),
|
160 |
+
Zend_Log::INFO,
|
161 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
162 |
+
);
|
163 |
$lastJobId = null;
|
164 |
+
if (Mage::app()->getWebsite($websiteId)->getConfig('reflektion_datafeeds/general/allfeedsenabled') != 'enabled'
|
165 |
+
) {
|
166 |
return;
|
167 |
}
|
168 |
+
|
169 |
// Generate jobs - enabled feeds
|
170 |
foreach (Reflektion_Catalogexport_Model_Generatefeeds::getFeedTypes() as $curType) {
|
171 |
// Create feed job
|
172 |
+
$curConfig = 'reflektion_datafeeds/feedsenabled/'.$curType;
|
173 |
+
if (Mage::app()->getWebsite($websiteId)->getConfig($curConfig) == 'enabled') {
|
174 |
// Check manual or daily
|
175 |
$jobType = 0;
|
176 |
if ($bBaselineFile) {
|
177 |
+
$jobType = Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_BASELINE;
|
178 |
$isBaseTran = 1;
|
179 |
} else {
|
180 |
+
$jobType = Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_DAILY;
|
181 |
$isBaseTran = 0;
|
182 |
}
|
183 |
|
188 |
}
|
189 |
|
190 |
// Transfer feeds job
|
191 |
+
$job = Reflektion_Catalogexport_Model_Job::createJob(
|
192 |
+
$lastJobId,
|
193 |
+
$websiteId,
|
194 |
+
Reflektion_Catalogexport_Model_Job::TYPE_TRANSFER,
|
195 |
+
null,
|
196 |
+
$isBaseTran
|
197 |
+
);
|
198 |
$job->save();
|
199 |
+
|
200 |
+
}//end scheduleJobs()
|
201 |
+
|
202 |
|
203 |
/**
|
204 |
* Run job
|
205 |
*/
|
206 |
+
public function run()
|
207 |
+
{
|
208 |
try {
|
209 |
+
Mage::helper('reflektion')->log(
|
210 |
+
'Running job: '.$this->getJobId(),
|
211 |
+
Zend_Log::INFO,
|
212 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
213 |
+
);
|
214 |
+
Mage::helper('reflektion')->log(
|
215 |
+
'Website Id: '.$this->getWebsiteId(),
|
216 |
+
Zend_Log::INFO,
|
217 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
218 |
+
);
|
219 |
+
Mage::helper('reflektion')->log(
|
220 |
+
'Dependent On Job Id: '.$this->getDependentOnJobId(),
|
221 |
+
Zend_Log::INFO,
|
222 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
223 |
+
);
|
224 |
+
Mage::helper('reflektion')->log(
|
225 |
+
'Min Entity Id: '.$this->getMinEntityId(),
|
226 |
+
Zend_Log::INFO,
|
227 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
228 |
+
);
|
229 |
+
Mage::helper('reflektion')->log(
|
230 |
+
'Type: '.$this->getType(),
|
231 |
+
Zend_Log::INFO,
|
232 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
233 |
+
);
|
234 |
+
Mage::helper('reflektion')->log(
|
235 |
+
'Feed Type: '.$this->getFeedType(),
|
236 |
+
Zend_Log::INFO,
|
237 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
238 |
+
);
|
239 |
+
Mage::helper('reflektion')->log(
|
240 |
+
'Memory usage: '.memory_get_usage(),
|
241 |
+
Zend_Log::DEBUG,
|
242 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
243 |
+
);
|
244 |
|
245 |
// Execute the job
|
246 |
$this->executeJob();
|
247 |
|
248 |
+
Mage::helper('reflektion')->log(
|
249 |
+
'Job completed successfully.',
|
250 |
+
Zend_Log::INFO,
|
251 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
252 |
+
);
|
253 |
+
Mage::helper('reflektion')->log(
|
254 |
+
'Memory usage: '.memory_get_usage(),
|
255 |
+
Zend_Log::DEBUG,
|
256 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
257 |
+
);
|
258 |
} catch (Exception $e) {
|
259 |
// Fail this job
|
260 |
$this->setStatus(Reflektion_Catalogexport_Model_Job::STATUS_ERROR);
|
263 |
$this->save();
|
264 |
// Log exception
|
265 |
Mage::logException($e);
|
266 |
+
Mage::helper('reflektion')->log(
|
267 |
+
'Job failed with error:',
|
268 |
+
Zend_Log::ERR,
|
269 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
270 |
+
);
|
271 |
+
Mage::helper('reflektion')->log(
|
272 |
+
$e->getMessage(),
|
273 |
+
Zend_Log::ERR,
|
274 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
275 |
+
);
|
276 |
+
Mage::helper('reflektion')->log(
|
277 |
+
'Memory usage: '.memory_get_usage(),
|
278 |
+
Zend_Log::DEBUG,
|
279 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
280 |
+
);
|
281 |
+
}//end try
|
282 |
|
283 |
return $this;
|
284 |
+
|
285 |
+
}//end run()
|
286 |
+
|
287 |
|
288 |
/**
|
289 |
* Execute this job
|
290 |
*/
|
291 |
+
protected function executeJob()
|
292 |
+
{
|
293 |
+
$feedEn = 'reflektion_datafeeds/general/allfeedsenabled';
|
294 |
+
if (Mage::app()->getWebsite($this->getWebsiteId())->getConfig($feedEn) != 'enabled') {
|
295 |
+
Mage::throwException('Data feeds not enabled for website: '.$this->getWebsiteId());
|
296 |
}
|
297 |
+
|
298 |
$bDone = false;
|
299 |
|
300 |
// Switch on job type
|
301 |
switch ($this->getType()) {
|
302 |
+
case Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_BASELINE:
|
303 |
+
// Call - Reflektion_Catalogexport_Model_Generatefeeds
|
304 |
+
$genModel = Mage::getModel('reflektion/generatefeeds');
|
305 |
+
$minEntityId = $this->getMinEntityId();
|
306 |
+
$genModel->generateForWebsite($this->getWebsiteId(), true, $this->getFeedType(), $minEntityId, $bDone);
|
307 |
+
$this->setMinEntityId($minEntityId);
|
308 |
+
break;
|
309 |
+
case Reflektion_Catalogexport_Model_Job::TYPE_GENERATE_DAILY:
|
310 |
+
// Call - Reflektion_Catalogexport_Model_Generatefeeds
|
311 |
+
$genModel = Mage::getModel('reflektion/generatefeeds');
|
312 |
+
$minEntityId = $this->getMinEntityId();
|
313 |
+
$genModel->generateForWebsite($this->getWebsiteId(), false, $this->getFeedType(), $minEntityId, $bDone);
|
314 |
+
$this->setMinEntityId($minEntityId);
|
315 |
+
break;
|
316 |
+
case Reflektion_Catalogexport_Model_Job::TYPE_TRANSFER:
|
317 |
+
// Call - Reflektion_Catalogexport_Model_Transferfeeds
|
318 |
+
$tranModel = Mage::getModel('reflektion/transferfeeds');
|
319 |
+
$tranModel->transfer($this->getWebsiteId());
|
320 |
+
$bDone = true;
|
321 |
+
break;
|
322 |
+
case Reflektion_Catalogexport_Model_Job::TYPE_TRANSFER_MANUAL:
|
323 |
+
// Call - Reflektion_Catalogexport_Model_Transferfeeds
|
324 |
+
$tranModel = Mage::getModel('reflektion/transferfeeds');
|
325 |
+
$tranModel->transfer($this->getWebsiteId());
|
326 |
+
$bDone = true;
|
327 |
+
break;
|
328 |
+
}//end switch
|
329 |
|
330 |
// Job as succeeded
|
331 |
if ($bDone) {
|
332 |
$this->setStatus(Reflektion_Catalogexport_Model_Job::STATUS_COMPLETED);
|
333 |
$this->setEndedAt(Mage::getSingleton('core/date')->gmtDate());
|
334 |
}
|
335 |
+
|
336 |
$this->save();
|
|
|
337 |
|
338 |
+
}//end executeJob()
|
339 |
+
|
340 |
+
|
341 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Layout.php
CHANGED
@@ -6,20 +6,23 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
*
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Layout extends Mage_Core_Model_Layout
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Add block object to layout based on xml node data
|
15 |
*
|
16 |
-
* @param
|
17 |
-
* @param
|
18 |
* @return Mage_Core_Model_Layout
|
19 |
*/
|
20 |
-
protected function _generateBlock($node, $parent)
|
21 |
-
|
22 |
parent:: _generateBlock($node, $parent);
|
23 |
-
}
|
24 |
|
25 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
|
|
9 |
*/
|
10 |
+
class Reflektion_Catalogexport_Model_Layout extends Mage_Core_Model_Layout
|
11 |
+
{
|
12 |
+
|
13 |
|
14 |
/**
|
15 |
* Add block object to layout based on xml node data
|
16 |
*
|
17 |
+
* @param Varien_Simplexml_Element $node
|
18 |
+
* @param Varien_Simplexml_Element $parent
|
19 |
* @return Mage_Core_Model_Layout
|
20 |
*/
|
21 |
+
protected function _generateBlock($node, $parent)
|
22 |
+
{
|
23 |
parent:: _generateBlock($node, $parent);
|
|
|
24 |
|
25 |
+
}//end _generateBlock()
|
26 |
+
|
27 |
+
|
28 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Mysql4/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Model/Mysql4/Job.php
CHANGED
@@ -6,12 +6,16 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
*
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
$this->_init('reflektion/job', 'job_id');
|
15 |
-
}
|
16 |
|
17 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
|
|
9 |
*/
|
10 |
+
class Reflektion_Catalogexport_Model_Mysql4_Job extends Mage_Core_Model_Mysql4_Abstract
|
11 |
+
{
|
12 |
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
$this->_init('reflektion/job', 'job_id');
|
|
|
17 |
|
18 |
+
}//end _construct()
|
19 |
+
|
20 |
+
|
21 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Mysql4/Job/Collection.php
CHANGED
@@ -6,12 +6,16 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
*
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Mysql4_Job_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
$this->_init('reflektion/job');
|
15 |
-
}
|
16 |
|
17 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
|
|
9 |
*/
|
10 |
+
class Reflektion_Catalogexport_Model_Mysql4_Job_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
11 |
+
{
|
12 |
|
13 |
+
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
$this->_init('reflektion/job');
|
|
|
17 |
|
18 |
+
}//end _construct()
|
19 |
+
|
20 |
+
|
21 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Observer.php
CHANGED
@@ -6,75 +6,158 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
*
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Observer
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Generate and send new datafeed files
|
15 |
*
|
16 |
-
* @param
|
17 |
-
* @return
|
18 |
*/
|
19 |
-
public function processDailyFeeds($schedule)
|
|
|
20 |
|
21 |
try {
|
22 |
-
Mage::helper('reflektion')->log(
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
// schedule daily feed jobs for all websites
|
30 |
$this->scheduleJobs();
|
31 |
|
32 |
// Log mem usage
|
33 |
-
Mage::helper('reflektion')->log(
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
for ($k = 0; $k < $countScheduled; $k++) {
|
39 |
-
$this->runJob();
|
40 |
-
|
|
|
|
|
41 |
}
|
42 |
-
|
43 |
-
Mage::helper('reflektion')->log(
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
} catch (Exception $e) {
|
47 |
Mage::logException($e);
|
48 |
-
Mage::helper('reflektion')->log(
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
return $this;
|
56 |
-
|
|
|
|
|
57 |
|
58 |
/**
|
59 |
* Schedule any daily feed jobs which are necessary when we hit the daily trigger time
|
60 |
-
*
|
61 |
-
*
|
62 |
*/
|
63 |
-
protected function scheduleJobs()
|
|
|
64 |
try {
|
65 |
Reflektion_Catalogexport_Model_Job::scheduleAllDailyJobs();
|
66 |
} catch (Exception $e) {
|
67 |
Mage::logException($e);
|
68 |
-
Mage::helper('reflektion')->log(
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
throw $e;
|
71 |
}
|
72 |
-
|
|
|
|
|
73 |
|
74 |
/**
|
75 |
* Grab the next job and run it, if it exists
|
76 |
*/
|
77 |
-
protected function runJob()
|
|
|
78 |
try {
|
79 |
$job = Reflektion_Catalogexport_Model_Job::getNextJobFromQueue();
|
80 |
if ($job !== false) {
|
@@ -82,10 +165,20 @@ class Reflektion_Catalogexport_Model_Observer {
|
|
82 |
}
|
83 |
} catch (Exception $e) {
|
84 |
Mage::logException($e);
|
85 |
-
Mage::helper('reflektion')->log(
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
throw $e;
|
88 |
}
|
89 |
-
}
|
90 |
|
91 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
|
|
9 |
*/
|
10 |
+
class Reflektion_Catalogexport_Model_Observer
|
11 |
+
{
|
12 |
+
|
13 |
|
14 |
/**
|
15 |
* Generate and send new datafeed files
|
16 |
*
|
17 |
+
* @param Mage_Cron_Model_Schedule $schedule
|
18 |
+
* @return Reflektion_Catalogexport_Model_Observer
|
19 |
*/
|
20 |
+
public function processDailyFeeds($schedule)
|
21 |
+
{
|
22 |
|
23 |
try {
|
24 |
+
Mage::helper('reflektion')->log(
|
25 |
+
'**********************************************************',
|
26 |
+
Zend_Log::INFO,
|
27 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
28 |
+
);
|
29 |
+
Mage::helper('reflektion')->log(
|
30 |
+
'Data feeds cron process started...',
|
31 |
+
Zend_Log::INFO,
|
32 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
33 |
+
);
|
34 |
+
Mage::helper('reflektion')->log(
|
35 |
+
'Is Single Store Mode: '.Mage::app()->isSingleStoreMode(),
|
36 |
+
Zend_Log::INFO,
|
37 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
38 |
+
);
|
39 |
+
Mage::helper('reflektion')->log(
|
40 |
+
'Memory usage: '.memory_get_usage(),
|
41 |
+
Zend_Log::DEBUG,
|
42 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
43 |
+
);
|
44 |
+
Mage::helper('reflektion')->log(
|
45 |
+
'**********************************************************',
|
46 |
+
Zend_Log::INFO,
|
47 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
48 |
+
);
|
49 |
+
Mage::helper('reflektion')->log(
|
50 |
+
'Memory usage: '.memory_get_usage(),
|
51 |
+
Zend_Log::DEBUG,
|
52 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
53 |
+
);
|
54 |
|
55 |
// schedule daily feed jobs for all websites
|
56 |
$this->scheduleJobs();
|
57 |
|
58 |
// Log mem usage
|
59 |
+
Mage::helper('reflektion')->log(
|
60 |
+
'Memory usage: '.memory_get_usage(),
|
61 |
+
Zend_Log::DEBUG,
|
62 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
63 |
+
);
|
64 |
+
$collectionJobs = Mage::getModel('reflektion/job')->getCollection()->addFieldToFilter(
|
65 |
+
'status',
|
66 |
+
array('eq' => Reflektion_Catalogexport_Model_Job::STATUS_SCHEDULED)
|
67 |
+
);
|
68 |
+
$countScheduled = $collectionJobs->getSize();
|
69 |
|
70 |
for ($k = 0; $k < $countScheduled; $k++) {
|
71 |
+
$this->runJob();
|
72 |
+
// products
|
73 |
+
$this->runJob();
|
74 |
+
// file transfer
|
75 |
}
|
76 |
+
|
77 |
+
Mage::helper('reflektion')->log(
|
78 |
+
'**********************************************************',
|
79 |
+
Zend_Log::INFO,
|
80 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
81 |
+
);
|
82 |
+
Mage::helper('reflektion')->log(
|
83 |
+
'Daily feeds cron process completed successfully.',
|
84 |
+
Zend_Log::INFO,
|
85 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
86 |
+
);
|
87 |
+
Mage::helper('reflektion')->log(
|
88 |
+
'Memory usage: '.memory_get_usage(),
|
89 |
+
Zend_Log::DEBUG,
|
90 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
91 |
+
);
|
92 |
+
Mage::helper('reflektion')->log(
|
93 |
+
'**********************************************************',
|
94 |
+
Zend_Log::INFO,
|
95 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
96 |
+
);
|
97 |
} catch (Exception $e) {
|
98 |
Mage::logException($e);
|
99 |
+
Mage::helper('reflektion')->log(
|
100 |
+
'**********************************************************',
|
101 |
+
Zend_Log::ERR,
|
102 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
103 |
+
);
|
104 |
+
Mage::helper('reflektion')->log(
|
105 |
+
'Data feeds cron process failed with error:',
|
106 |
+
Zend_Log::ERR,
|
107 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
108 |
+
);
|
109 |
+
Mage::helper('reflektion')->log(
|
110 |
+
$e->getMessage(),
|
111 |
+
Zend_Log::ERR,
|
112 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
113 |
+
);
|
114 |
+
Mage::helper('reflektion')->log(
|
115 |
+
'Memory usage: '.memory_get_usage(),
|
116 |
+
Zend_Log::DEBUG,
|
117 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
118 |
+
);
|
119 |
+
Mage::helper('reflektion')->log(
|
120 |
+
'**********************************************************',
|
121 |
+
Zend_Log::ERR,
|
122 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
123 |
+
);
|
124 |
+
}//end try
|
125 |
|
126 |
return $this;
|
127 |
+
|
128 |
+
}//end processDailyFeeds()
|
129 |
+
|
130 |
|
131 |
/**
|
132 |
* Schedule any daily feed jobs which are necessary when we hit the daily trigger time
|
|
|
|
|
133 |
*/
|
134 |
+
protected function scheduleJobs()
|
135 |
+
{
|
136 |
try {
|
137 |
Reflektion_Catalogexport_Model_Job::scheduleAllDailyJobs();
|
138 |
} catch (Exception $e) {
|
139 |
Mage::logException($e);
|
140 |
+
Mage::helper('reflektion')->log(
|
141 |
+
'Failed to schedule daily jobs, error:',
|
142 |
+
Zend_Log::ERR,
|
143 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
144 |
+
);
|
145 |
+
Mage::helper('reflektion')->log(
|
146 |
+
$e->getMessage(),
|
147 |
+
Zend_Log::ERR,
|
148 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
149 |
+
);
|
150 |
throw $e;
|
151 |
}
|
152 |
+
|
153 |
+
}//end scheduleJobs()
|
154 |
+
|
155 |
|
156 |
/**
|
157 |
* Grab the next job and run it, if it exists
|
158 |
*/
|
159 |
+
protected function runJob()
|
160 |
+
{
|
161 |
try {
|
162 |
$job = Reflektion_Catalogexport_Model_Job::getNextJobFromQueue();
|
163 |
if ($job !== false) {
|
165 |
}
|
166 |
} catch (Exception $e) {
|
167 |
Mage::logException($e);
|
168 |
+
Mage::helper('reflektion')->log(
|
169 |
+
'Failed to run job, error:',
|
170 |
+
Zend_Log::ERR,
|
171 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
172 |
+
);
|
173 |
+
Mage::helper('reflektion')->log(
|
174 |
+
$e->getMessage(),
|
175 |
+
Zend_Log::ERR,
|
176 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
177 |
+
);
|
178 |
throw $e;
|
179 |
}
|
|
|
180 |
|
181 |
+
}//end runJob()
|
182 |
+
|
183 |
+
|
184 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/System/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/Model/System/Config/Cron.php
CHANGED
@@ -6,31 +6,40 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Validate and save cron job frequency
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_System_Config_Cron extends Mage_Core_Model_Config_Data
|
|
|
12 |
|
13 |
const CRON_STRING_PATH = 'crontab/jobs/reflektion_processdailyfeeds/schedule/cron_expr';
|
14 |
|
15 |
-
|
|
|
|
|
16 |
$time = $this->getData('groups/configurable_cron/fields/frequency/value');
|
17 |
$time = explode(" ", $time);
|
18 |
try {
|
19 |
if (count($time) == 5) {
|
20 |
foreach ($time as $val)
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
} else {
|
25 |
throw new Exception();
|
26 |
}
|
|
|
27 |
$cronExprArray = array(
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
34 |
$cronExprString = join(' ', $cronExprArray);
|
35 |
|
36 |
Mage::getModel('core/config_data')
|
@@ -40,7 +49,9 @@ class Reflektion_Catalogexport_Model_System_Config_Cron extends Mage_Core_Model_
|
|
40 |
->save();
|
41 |
} catch (Exception $e) {
|
42 |
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
|
43 |
-
}
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
}
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Validate and save cron job frequency
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_System_Config_Cron extends Mage_Core_Model_Config_Data
|
12 |
+
{
|
13 |
|
14 |
const CRON_STRING_PATH = 'crontab/jobs/reflektion_processdailyfeeds/schedule/cron_expr';
|
15 |
|
16 |
+
|
17 |
+
protected function _afterSave()
|
18 |
+
{
|
19 |
$time = $this->getData('groups/configurable_cron/fields/frequency/value');
|
20 |
$time = explode(" ", $time);
|
21 |
try {
|
22 |
if (count($time) == 5) {
|
23 |
foreach ($time as $val)
|
24 |
+
if (preg_match('/[^*,\/0-9]/i', $val)) {
|
25 |
+
throw new Exception();
|
26 |
+
}
|
27 |
} else {
|
28 |
throw new Exception();
|
29 |
}
|
30 |
+
|
31 |
$cronExprArray = array(
|
32 |
+
$time[0],
|
33 |
+
// Minute
|
34 |
+
$time[1],
|
35 |
+
// Hour
|
36 |
+
$time[2],
|
37 |
+
// Day of the Month
|
38 |
+
$time[3],
|
39 |
+
// Month of the Year
|
40 |
+
$time[4],
|
41 |
+
// Day of the Week
|
42 |
+
);
|
43 |
$cronExprString = join(' ', $cronExprArray);
|
44 |
|
45 |
Mage::getModel('core/config_data')
|
49 |
->save();
|
50 |
} catch (Exception $e) {
|
51 |
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
|
52 |
+
}//end try
|
53 |
+
|
54 |
+
}//end _afterSave()
|
55 |
+
|
56 |
|
57 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/System/Config/EnableToggle.php
CHANGED
@@ -8,13 +8,24 @@
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description To enable or disable module and feed generation
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_System_Config_EnableToggle
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
return array(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
}
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description To enable or disable module and feed generation
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_System_Config_EnableToggle
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function toOptionArray()
|
16 |
+
{
|
17 |
return array(
|
18 |
+
array(
|
19 |
+
'value' => 'enabled',
|
20 |
+
'label' => Mage::helper('adminhtml')->__('Enabled'),
|
21 |
+
),
|
22 |
+
array(
|
23 |
+
'value' => 'disabled',
|
24 |
+
'label' => Mage::helper('adminhtml')->__('Disabled'),
|
25 |
+
),
|
26 |
+
);
|
27 |
+
|
28 |
+
}//end toOptionArray()
|
29 |
+
|
30 |
|
31 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/System/Config/ProductAttributes.php
CHANGED
@@ -6,27 +6,31 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description To fetch all user defined attributes
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_System_Config_ProductAttributes
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
|
15 |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
|
|
16 |
->addVisibleFilter()
|
17 |
->addStoreLabel(Mage::app()->getStore()->getId())
|
18 |
-
->setOrder('main_table.attribute_id', 'asc')
|
19 |
-
|
20 |
-
$result = array();
|
21 |
foreach ($attributes as $_attribute) {
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
);
|
27 |
-
}
|
28 |
}
|
|
|
29 |
return $result;
|
30 |
-
}
|
31 |
|
32 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description To fetch all user defined attributes
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_System_Config_ProductAttributes
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function toOptionArray()
|
16 |
+
{
|
17 |
|
18 |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
19 |
+
->addFieldToFilter('is_user_defined', 1)
|
20 |
->addVisibleFilter()
|
21 |
->addStoreLabel(Mage::app()->getStore()->getId())
|
22 |
+
->setOrder('main_table.attribute_id', 'asc');
|
23 |
+
$result = array();
|
|
|
24 |
foreach ($attributes as $_attribute) {
|
25 |
+
$result[] = array(
|
26 |
+
'value' => $_attribute["attribute_code"],
|
27 |
+
'label' => $_attribute["frontend_label"],
|
28 |
+
);
|
|
|
|
|
29 |
}
|
30 |
+
|
31 |
return $result;
|
|
|
32 |
|
33 |
+
}//end toOptionArray()
|
34 |
+
|
35 |
+
|
36 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/System/Validate/ProductAttributes.php
CHANGED
@@ -7,26 +7,36 @@
|
|
7 |
* @license https://opensource.org/licenses/OSL-3.0
|
8 |
* @description Validate product attributes to export while saving from admin panel
|
9 |
*/
|
10 |
-
class Reflektion_Catalogexport_Model_System_Validate_ProductAttributes extends Mage_Core_Model_Config_Data
|
|
|
11 |
|
12 |
const ATTRIBUTE_LIMIT = 30;
|
13 |
|
14 |
-
|
|
|
|
|
15 |
$limit = Mage::app()->getWebsite()->getConfig('reflektion_datafeeds/advanced/attribute_limit');
|
16 |
if (!$limit) {
|
17 |
$limit = self::ATTRIBUTE_LIMIT;
|
18 |
}
|
19 |
|
20 |
-
$selections = $this->getValue();
|
21 |
-
|
22 |
-
if (sizeof($selections) > $limit) {
|
|
|
23 |
Mage::getSingleton('core/session')->addWarning(
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
-
$this->setValue(array_slice($selections, 0, $limit, true));
|
|
|
29 |
return parent::save();
|
30 |
-
}
|
31 |
|
32 |
-
}
|
|
|
|
|
|
7 |
* @license https://opensource.org/licenses/OSL-3.0
|
8 |
* @description Validate product attributes to export while saving from admin panel
|
9 |
*/
|
10 |
+
class Reflektion_Catalogexport_Model_System_Validate_ProductAttributes extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
|
13 |
const ATTRIBUTE_LIMIT = 30;
|
14 |
|
15 |
+
|
16 |
+
public function save()
|
17 |
+
{
|
18 |
$limit = Mage::app()->getWebsite()->getConfig('reflektion_datafeeds/advanced/attribute_limit');
|
19 |
if (!$limit) {
|
20 |
$limit = self::ATTRIBUTE_LIMIT;
|
21 |
}
|
22 |
|
23 |
+
$selections = $this->getValue();
|
24 |
+
// Config Value
|
25 |
+
if (sizeof($selections) > $limit) {
|
26 |
+
// more than 30 items selected
|
27 |
Mage::getSingleton('core/session')->addWarning(
|
28 |
+
Mage::helper('reflektion')->__(
|
29 |
+
"WARNING - Only the first %s selected attributes were saved and applied to the feed.",
|
30 |
+
$limit
|
31 |
+
)
|
32 |
+
);
|
33 |
}
|
34 |
|
35 |
+
$this->setValue(array_slice($selections, 0, $limit, true));
|
36 |
+
// only keep the first 30 items the user selected
|
37 |
return parent::save();
|
|
|
38 |
|
39 |
+
}//end save()
|
40 |
+
|
41 |
+
|
42 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/Model/Transferfeeds.php
CHANGED
@@ -6,22 +6,35 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Manage to transfer feed from magento to other server through SFTP
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Model_Transferfeeds
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Transfer data feeds to Reflektion, triggered by cron
|
15 |
*
|
16 |
* @param $websiteId Id of the website for which to generate data feeds
|
17 |
*/
|
18 |
-
public function transfer($websiteId)
|
|
|
19 |
try {
|
20 |
-
Mage::helper('reflektion')->log(
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
$fileList = $this->buildFileList($websiteId);
|
@@ -30,111 +43,182 @@ class Reflektion_Catalogexport_Model_Transferfeeds {
|
|
30 |
Mage::throwException('Transfer file list failed!');
|
31 |
}
|
32 |
|
33 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
34 |
} catch (Exception $e) {
|
35 |
-
Mage::helper('reflektion')->log(
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
throw $e;
|
38 |
-
}
|
39 |
-
|
|
|
|
|
40 |
|
41 |
/**
|
42 |
* Build list of files to transfer, based on enabled website
|
43 |
*
|
44 |
-
* @param
|
45 |
* @return array List of files to transfer for this website (full path & filename specified for each)
|
46 |
*/
|
47 |
-
protected function buildFileList($websiteId)
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
51 |
|
52 |
// Websiteid match string
|
53 |
$websiteIdMatchString = '_product_feed';
|
54 |
|
55 |
$fileList = array();
|
56 |
-
|
|
|
57 |
// Open directory
|
58 |
$dh = opendir($feedPath);
|
59 |
-
if ($dh ===
|
60 |
-
Mage::throwException('Failed to open feed directory: '
|
61 |
}
|
62 |
|
63 |
// Files in directory
|
64 |
-
while (($entry = readdir($dh)) !==
|
65 |
-
$fullpath = $feedPath
|
66 |
// Check if have a file
|
67 |
if (is_file($fullpath)) {
|
68 |
// Check if our file is for the correct websiteId
|
69 |
-
if (strpos($fullpath, $websiteIdMatchString) !==
|
70 |
$fileList[] = $fullpath;
|
71 |
}
|
72 |
}
|
73 |
}
|
|
|
74 |
closedir($dh);
|
75 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
76 |
|
77 |
return $fileList;
|
78 |
-
|
|
|
|
|
79 |
|
80 |
/**
|
81 |
* Transfer this list of files to the SFTP site for Reflektion
|
82 |
*
|
83 |
-
* @param
|
84 |
-
* @param
|
85 |
* @return bool Indicates if files successfully transfered or not
|
86 |
*/
|
87 |
-
protected function transferFileList($websiteId, array $fileList)
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
try {
|
91 |
// Get hostname, port & credentials
|
92 |
-
$
|
93 |
-
$
|
94 |
-
$
|
95 |
-
$
|
|
|
|
|
|
|
96 |
} catch (Exception $e) {
|
97 |
Mage::logException($e);
|
98 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
99 |
return false;
|
100 |
}
|
101 |
|
102 |
// Connect to server
|
103 |
$connection = Mage::helper('reflektion/sftpConnection');
|
104 |
-
$bSuccess
|
105 |
if (!$bSuccess) {
|
106 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
107 |
return false;
|
108 |
}
|
|
|
109 |
$sftpFolder = Mage::app()->getWebsite($websiteId)->getConfig('reflektion_datafeeds/connect/path');
|
110 |
-
$bSuccess
|
111 |
if (!$bSuccess) {
|
112 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
113 |
return false;
|
114 |
}
|
115 |
|
116 |
-
//Iterate file list and put each file
|
117 |
$bTransferSucceeded = true;
|
118 |
foreach ($fileList as $curFile) {
|
119 |
-
Mage::helper('reflektion')->log(
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
$bSuccess = $connection->putAndDeleteFile($curFile);
|
122 |
if (!$bSuccess) {
|
123 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
124 |
$bTransferSucceeded = false;
|
125 |
}
|
126 |
-
}
|
127 |
|
128 |
$connection->close();
|
129 |
|
130 |
// Check results
|
131 |
if (!$bTransferSucceeded) {
|
132 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
133 |
return false;
|
134 |
} else {
|
135 |
-
Mage::helper('reflektion')->log(
|
|
|
|
|
|
|
|
|
136 |
return true;
|
137 |
}
|
138 |
-
}
|
139 |
|
140 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Manage to transfer feed from magento to other server through SFTP
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Model_Transferfeeds
|
12 |
+
{
|
13 |
+
|
14 |
|
15 |
/**
|
16 |
* Transfer data feeds to Reflektion, triggered by cron
|
17 |
*
|
18 |
* @param $websiteId Id of the website for which to generate data feeds
|
19 |
*/
|
20 |
+
public function transfer($websiteId)
|
21 |
+
{
|
22 |
try {
|
23 |
+
Mage::helper('reflektion')->log(
|
24 |
+
'Transferring data feeds for website with Id: '.$websiteId,
|
25 |
+
Zend_Log::INFO,
|
26 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
27 |
+
);
|
28 |
+
Mage::helper('reflektion')->log(
|
29 |
+
'Memory usage: '.memory_get_usage(),
|
30 |
+
Zend_Log::DEBUG,
|
31 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
32 |
+
);
|
33 |
+
|
34 |
+
$feedEn = 'reflektion_datafeeds/general/allfeedsenabled';
|
35 |
+
if (Mage::app()->getWebsite($websiteId)->getConfig($feedEn) != 'enabled'
|
36 |
+
) {
|
37 |
+
Mage::throwException('Data feeds not enabled for website: '.$websiteId);
|
38 |
}
|
39 |
|
40 |
$fileList = $this->buildFileList($websiteId);
|
43 |
Mage::throwException('Transfer file list failed!');
|
44 |
}
|
45 |
|
46 |
+
Mage::helper('reflektion')->log(
|
47 |
+
'Sucessfully transferred data feeds for website.',
|
48 |
+
Zend_Log::INFO,
|
49 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
50 |
+
);
|
51 |
} catch (Exception $e) {
|
52 |
+
Mage::helper('reflektion')->log(
|
53 |
+
'Failed to transfer data feeds for website.',
|
54 |
+
Zend_Log::ERR,
|
55 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
56 |
+
);
|
57 |
+
Mage::helper('reflektion')->log(
|
58 |
+
$e->getMessage(),
|
59 |
+
Zend_Log::ERR,
|
60 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
61 |
+
);
|
62 |
throw $e;
|
63 |
+
}//end try
|
64 |
+
|
65 |
+
}//end transfer()
|
66 |
+
|
67 |
|
68 |
/**
|
69 |
* Build list of files to transfer, based on enabled website
|
70 |
*
|
71 |
+
* @param $websiteId Id of the website for which to generate data feeds
|
72 |
* @return array List of files to transfer for this website (full path & filename specified for each)
|
73 |
*/
|
74 |
+
protected function buildFileList($websiteId)
|
75 |
+
{
|
76 |
+
$dir = Mage::getConfig()->getVarDir().DS;
|
77 |
+
$feedPath = $dir.Reflektion_Catalogexport_Model_Generatefeeds::REFLEKTION_FEED_PATH;
|
78 |
|
79 |
+
Mage::helper('reflektion')->log(
|
80 |
+
'Searching for feed files for website id: '.$websiteId.' here: '.$feedPath,
|
81 |
+
Zend_Log::INFO,
|
82 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
83 |
+
);
|
84 |
|
85 |
// Websiteid match string
|
86 |
$websiteIdMatchString = '_product_feed';
|
87 |
|
88 |
$fileList = array();
|
89 |
+
$oIo = new Varien_Io_File();
|
90 |
+
$oIo->checkAndCreateFolder($feedPath);
|
91 |
// Open directory
|
92 |
$dh = opendir($feedPath);
|
93 |
+
if ($dh === false) {
|
94 |
+
Mage::throwException('Failed to open feed directory: '.$feedPath);
|
95 |
}
|
96 |
|
97 |
// Files in directory
|
98 |
+
while (($entry = readdir($dh)) !== false) {
|
99 |
+
$fullpath = $feedPath.DS.$entry;
|
100 |
// Check if have a file
|
101 |
if (is_file($fullpath)) {
|
102 |
// Check if our file is for the correct websiteId
|
103 |
+
if (strpos($fullpath, $websiteIdMatchString) !== false) {
|
104 |
$fileList[] = $fullpath;
|
105 |
}
|
106 |
}
|
107 |
}
|
108 |
+
|
109 |
closedir($dh);
|
110 |
+
Mage::helper('reflektion')->log(
|
111 |
+
'Found '.count($fileList).' feed files for website id: '.$websiteId,
|
112 |
+
Zend_Log::INFO,
|
113 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
114 |
+
);
|
115 |
|
116 |
return $fileList;
|
117 |
+
|
118 |
+
}//end buildFileList()
|
119 |
+
|
120 |
|
121 |
/**
|
122 |
* Transfer this list of files to the SFTP site for Reflektion
|
123 |
*
|
124 |
+
* @param $websiteId Id of the website for which to generate data feeds
|
125 |
+
* @param $fileList List of file names (full path) to transfer
|
126 |
* @return bool Indicates if files successfully transfered or not
|
127 |
*/
|
128 |
+
protected function transferFileList($websiteId, array $fileList)
|
129 |
+
{
|
130 |
+
Mage::helper('reflektion')->log(
|
131 |
+
'Transferring '.count($fileList).' files for website id: '.$websiteId,
|
132 |
+
Zend_Log::INFO,
|
133 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
134 |
+
);
|
135 |
|
136 |
try {
|
137 |
// Get hostname, port & credentials
|
138 |
+
$curWebsite = Mage::app()->getWebsite($websiteId);
|
139 |
+
$sftpHost = $curWebsite->getConfig('reflektion_datafeeds/connect/hostname');
|
140 |
+
$sftpPort = $curWebsite->getConfig('reflektion_datafeeds/connect/port');
|
141 |
+
$sftpUser = $curWebsite->getConfig('reflektion_datafeeds/connect/username');
|
142 |
+
$sftpPassword = Mage::helper('core')->decrypt(
|
143 |
+
$curWebsite->getConfig('reflektion_datafeeds/connect/password')
|
144 |
+
);
|
145 |
} catch (Exception $e) {
|
146 |
Mage::logException($e);
|
147 |
+
Mage::helper('reflektion')->log(
|
148 |
+
$e->getMessage(),
|
149 |
+
Zend_Log::ERR,
|
150 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
151 |
+
);
|
152 |
return false;
|
153 |
}
|
154 |
|
155 |
// Connect to server
|
156 |
$connection = Mage::helper('reflektion/sftpConnection');
|
157 |
+
$bSuccess = $connection->connect($sftpHost, $sftpPort, $sftpUser, $sftpPassword);
|
158 |
if (!$bSuccess) {
|
159 |
+
Mage::helper('reflektion')->log(
|
160 |
+
'Failed to connect to Reflektion!',
|
161 |
+
Zend_Log::ERR,
|
162 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
163 |
+
);
|
164 |
return false;
|
165 |
}
|
166 |
+
|
167 |
$sftpFolder = Mage::app()->getWebsite($websiteId)->getConfig('reflektion_datafeeds/connect/path');
|
168 |
+
$bSuccess = $connection->changeDir($sftpFolder);
|
169 |
if (!$bSuccess) {
|
170 |
+
Mage::helper('reflektion')->log(
|
171 |
+
'Failed to change folders to: '.$sftpFolder,
|
172 |
+
Zend_Log::ERR,
|
173 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
174 |
+
);
|
175 |
return false;
|
176 |
}
|
177 |
|
178 |
+
// Iterate file list and put each file
|
179 |
$bTransferSucceeded = true;
|
180 |
foreach ($fileList as $curFile) {
|
181 |
+
Mage::helper('reflektion')->log(
|
182 |
+
'Transferring file: '.$curFile,
|
183 |
+
Zend_Log::INFO,
|
184 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
185 |
+
);
|
186 |
+
Mage::helper('reflektion')->log(
|
187 |
+
'Memory usage: '.memory_get_usage(),
|
188 |
+
Zend_Log::DEBUG,
|
189 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
190 |
+
);
|
191 |
$bSuccess = $connection->putAndDeleteFile($curFile);
|
192 |
if (!$bSuccess) {
|
193 |
+
Mage::helper('reflektion')->log(
|
194 |
+
'Failed to transfer and delete file: '.$curFile,
|
195 |
+
Zend_Log::ERR,
|
196 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
197 |
+
);
|
198 |
$bTransferSucceeded = false;
|
199 |
}
|
200 |
+
}//end foreach
|
201 |
|
202 |
$connection->close();
|
203 |
|
204 |
// Check results
|
205 |
if (!$bTransferSucceeded) {
|
206 |
+
Mage::helper('reflektion')->log(
|
207 |
+
'Some file transfers failed!',
|
208 |
+
Zend_Log::ERR,
|
209 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
210 |
+
);
|
211 |
return false;
|
212 |
} else {
|
213 |
+
Mage::helper('reflektion')->log(
|
214 |
+
'Successfully transferred all files.',
|
215 |
+
Zend_Log::INFO,
|
216 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
217 |
+
);
|
218 |
return true;
|
219 |
}
|
|
|
220 |
|
221 |
+
}//end transferFileList()
|
222 |
+
|
223 |
+
|
224 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/controllers/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/controllers/Adminhtml/ExportController.php
CHANGED
@@ -8,17 +8,30 @@
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Actions to generate jobs in queue
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
$this->loadLayout()->_setActiveMenu("reflektion/export");
|
15 |
$this->renderLayout();
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
* Export baseline data feed
|
20 |
*/
|
21 |
-
public function exportoneAction()
|
|
|
22 |
try {
|
23 |
$id = $this->getRequest()->getParam('id');
|
24 |
Mage::helper('reflektion')->validateFeedConfiguration($id);
|
@@ -32,24 +45,45 @@ class Reflektion_Catalogexport_Adminhtml_ExportController extends Mage_Adminhtml
|
|
32 |
|
33 |
try {
|
34 |
$id = $this->getRequest()->getParam('id');
|
35 |
-
Mage::log(
|
|
|
|
|
|
|
|
|
36 |
|
37 |
// Schedule all feeds for site
|
38 |
Reflektion_Catalogexport_Model_Job::scheduleJobs($id, true);
|
39 |
-
Mage::log(
|
|
|
|
|
|
|
|
|
40 |
} catch (Exception $e) {
|
41 |
Mage::logException($e);
|
42 |
-
Mage::log(
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
$this->_redirect('*/*/index');
|
47 |
-
|
|
|
|
|
48 |
|
49 |
/**
|
50 |
* Export all baseline data feeds
|
51 |
*/
|
52 |
-
public function exportallAction()
|
|
|
53 |
try {
|
54 |
Mage::helper('reflektion')->validateFeedConfiguration();
|
55 |
} catch (Exception $e) {
|
@@ -61,7 +95,11 @@ class Reflektion_Catalogexport_Adminhtml_ExportController extends Mage_Adminhtml
|
|
61 |
|
62 |
try {
|
63 |
$id = $this->getRequest()->getParam('id');
|
64 |
-
Mage::log(
|
|
|
|
|
|
|
|
|
65 |
|
66 |
// Schedule all feeds for site
|
67 |
Reflektion_Catalogexport_Model_Job::scheduleJobsAllWebsites(true);
|
@@ -71,8 +109,11 @@ class Reflektion_Catalogexport_Adminhtml_ExportController extends Mage_Adminhtml
|
|
71 |
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
72 |
Mage::log($e->getMessage(), Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
73 |
}
|
|
|
74 |
$this->_getSession()->addSuccess($this->__('Feed generation and transfer has been scheduled all websites.'));
|
75 |
$this->_redirect('*/*/index');
|
76 |
-
}
|
77 |
|
78 |
-
}
|
|
|
|
|
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
* @description Actions to generate jobs in queue
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
$this->loadLayout()->_setActiveMenu("reflektion/export");
|
18 |
$this->renderLayout();
|
19 |
+
|
20 |
+
}//end indexAction()
|
21 |
+
|
22 |
+
|
23 |
+
protected function _isAllowed()
|
24 |
+
{
|
25 |
+
return Mage::getSingleton('admin/session')->isAllowed('reflektion/export');
|
26 |
+
|
27 |
+
}//end _isAllowed()
|
28 |
+
|
29 |
|
30 |
/**
|
31 |
* Export baseline data feed
|
32 |
*/
|
33 |
+
public function exportoneAction()
|
34 |
+
{
|
35 |
try {
|
36 |
$id = $this->getRequest()->getParam('id');
|
37 |
Mage::helper('reflektion')->validateFeedConfiguration($id);
|
45 |
|
46 |
try {
|
47 |
$id = $this->getRequest()->getParam('id');
|
48 |
+
Mage::log(
|
49 |
+
'Scheduling immediate baseline data feeds for website Id: '.$id,
|
50 |
+
Zend_Log::INFO,
|
51 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
52 |
+
);
|
53 |
|
54 |
// Schedule all feeds for site
|
55 |
Reflektion_Catalogexport_Model_Job::scheduleJobs($id, true);
|
56 |
+
Mage::log(
|
57 |
+
'Successfully scheduled feeds.',
|
58 |
+
Zend_Log::INFO,
|
59 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
60 |
+
);
|
61 |
} catch (Exception $e) {
|
62 |
Mage::logException($e);
|
63 |
+
Mage::log(
|
64 |
+
'Failed to schedule feeds.',
|
65 |
+
Zend_Log::ERR,
|
66 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
67 |
+
);
|
68 |
+
Mage::log(
|
69 |
+
$e->getMessage(),
|
70 |
+
Zend_Log::ERR,
|
71 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
72 |
+
);
|
73 |
+
}//end try
|
74 |
+
$this->_getSession()->addSuccess(
|
75 |
+
$this->__('Feed generation and transfer has been scheduled for website ID '.$id.'.')
|
76 |
+
);
|
77 |
$this->_redirect('*/*/index');
|
78 |
+
|
79 |
+
}//end exportoneAction()
|
80 |
+
|
81 |
|
82 |
/**
|
83 |
* Export all baseline data feeds
|
84 |
*/
|
85 |
+
public function exportallAction()
|
86 |
+
{
|
87 |
try {
|
88 |
Mage::helper('reflektion')->validateFeedConfiguration();
|
89 |
} catch (Exception $e) {
|
95 |
|
96 |
try {
|
97 |
$id = $this->getRequest()->getParam('id');
|
98 |
+
Mage::log(
|
99 |
+
'Scheduling immediate baseline data feeds for all websites.',
|
100 |
+
Zend_Log::INFO,
|
101 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
102 |
+
);
|
103 |
|
104 |
// Schedule all feeds for site
|
105 |
Reflektion_Catalogexport_Model_Job::scheduleJobsAllWebsites(true);
|
109 |
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
110 |
Mage::log($e->getMessage(), Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
111 |
}
|
112 |
+
|
113 |
$this->_getSession()->addSuccess($this->__('Feed generation and transfer has been scheduled all websites.'));
|
114 |
$this->_redirect('*/*/index');
|
|
|
115 |
|
116 |
+
}//end exportallAction()
|
117 |
+
|
118 |
+
|
119 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/controllers/Adminhtml/JobController.php
CHANGED
@@ -6,19 +6,32 @@
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
-
* @description Actions to process jobs in queue
|
10 |
*/
|
11 |
-
class Reflektion_Catalogexport_Adminhtml_JobController extends Mage_Adminhtml_Controller_Action
|
|
|
12 |
|
13 |
-
|
|
|
|
|
14 |
$this->loadLayout()->_setActiveMenu("reflektion/job");
|
15 |
$this->renderLayout();
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
* Export all baseline data feeds
|
20 |
*/
|
21 |
-
public function exportallAction()
|
|
|
22 |
try {
|
23 |
Mage::helper('reflektion')->validateFeedConfiguration();
|
24 |
} catch (Exception $e) {
|
@@ -29,7 +42,11 @@ class Reflektion_Catalogexport_Adminhtml_JobController extends Mage_Adminhtml_Co
|
|
29 |
}
|
30 |
|
31 |
try {
|
32 |
-
Mage::log(
|
|
|
|
|
|
|
|
|
33 |
// Schedule all feeds for site
|
34 |
Reflektion_Catalogexport_Model_Job::scheduleJobsAllWebsites(true);
|
35 |
Mage::log('Successfully scheduled feeds.', Zend_Log::INFO, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
@@ -38,68 +55,97 @@ class Reflektion_Catalogexport_Adminhtml_JobController extends Mage_Adminhtml_Co
|
|
38 |
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
39 |
Mage::log($e->getMessage(), Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
40 |
}
|
|
|
41 |
$this->_getSession()->addSuccess($this->__('Feed generation and transfer has been scheduled all websites.'));
|
42 |
$this->_redirect('*/*/index');
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
|
|
|
|
59 |
}
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
)
|
|
|
66 |
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
}
|
72 |
|
73 |
-
|
|
|
|
|
74 |
$jobIds = $this->getRequest()->getParam('job_id');
|
75 |
if (!is_array($jobIds)) {
|
76 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
|
|
|
|
77 |
} else {
|
78 |
try {
|
79 |
-
$jobModel = Mage::getModel('reflektion/job')
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
88 |
}
|
89 |
} catch (Exception $e) {
|
90 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
91 |
}
|
92 |
-
}
|
93 |
|
94 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
95 |
-
|
96 |
-
|
97 |
-
)
|
|
|
98 |
);
|
99 |
|
100 |
-
Mage::log(
|
|
|
|
|
|
|
|
|
101 |
|
102 |
$this->_redirect('*/*/index');
|
103 |
-
}
|
104 |
|
105 |
-
}
|
|
|
|
|
|
6 |
* @website http://www.reflektion.com/ <http://www.reflektion.com/>
|
7 |
* @createdOn 02 Mar 2016
|
8 |
* @license https://opensource.org/licenses/OSL-3.0
|
9 |
+
* @description Actions to process jobs in queue
|
10 |
*/
|
11 |
+
class Reflektion_Catalogexport_Adminhtml_JobController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
$this->loadLayout()->_setActiveMenu("reflektion/job");
|
18 |
$this->renderLayout();
|
19 |
+
|
20 |
+
}//end indexAction()
|
21 |
+
|
22 |
+
|
23 |
+
protected function _isAllowed()
|
24 |
+
{
|
25 |
+
return Mage::getSingleton('admin/session')->isAllowed('reflektion/job');
|
26 |
+
|
27 |
+
}//end _isAllowed()
|
28 |
+
|
29 |
|
30 |
/**
|
31 |
* Export all baseline data feeds
|
32 |
*/
|
33 |
+
public function exportallAction()
|
34 |
+
{
|
35 |
try {
|
36 |
Mage::helper('reflektion')->validateFeedConfiguration();
|
37 |
} catch (Exception $e) {
|
42 |
}
|
43 |
|
44 |
try {
|
45 |
+
Mage::log(
|
46 |
+
'Scheduling immediate baseline data feeds for all websites.',
|
47 |
+
Zend_Log::INFO,
|
48 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
49 |
+
);
|
50 |
// Schedule all feeds for site
|
51 |
Reflektion_Catalogexport_Model_Job::scheduleJobsAllWebsites(true);
|
52 |
Mage::log('Successfully scheduled feeds.', Zend_Log::INFO, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
55 |
Mage::log('Failed to schedule feeds.', Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
56 |
Mage::log($e->getMessage(), Zend_Log::ERR, Reflektion_Catalogexport_Helper_Data::LOG_FILE);
|
57 |
}
|
58 |
+
|
59 |
$this->_getSession()->addSuccess($this->__('Feed generation and transfer has been scheduled all websites.'));
|
60 |
$this->_redirect('*/*/index');
|
61 |
+
|
62 |
+
}//end exportallAction()
|
63 |
+
|
64 |
+
|
65 |
+
public function massDeleteAction()
|
66 |
+
{
|
67 |
+
$jobIds = $this->getRequest()->getParam('job_id');
|
68 |
+
if (!is_array($jobIds)) {
|
69 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
70 |
+
Mage::helper('reflektion')->__('Please select jobs(s) to delete.')
|
71 |
+
);
|
72 |
+
} else {
|
73 |
+
try {
|
74 |
+
$jobModel = Mage::getModel('reflektion/job')
|
75 |
+
->getCollection()
|
76 |
+
->addFieldToFilter('job_id', array('in' => $jobIds));
|
77 |
+
foreach ($jobModel as $jobs) {
|
78 |
+
Mage::log(
|
79 |
+
'Mass delete - Deleting job id '.$jobs->getJobId(),
|
80 |
+
Zend_Log::INFO,
|
81 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
82 |
+
);
|
83 |
+
$jobs->delete();
|
84 |
}
|
85 |
+
} catch (Exception $e) {
|
86 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
87 |
}
|
88 |
+
}//end if
|
89 |
|
90 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
91 |
+
Mage::helper('reflektion')->__(
|
92 |
+
'Total of %d record(s) were deleted.',
|
93 |
+
count($jobIds)
|
94 |
+
)
|
95 |
+
);
|
96 |
|
97 |
+
Mage::log(
|
98 |
+
'Mass delete - '.count($jobIds).' jobs deleted.',
|
99 |
+
Zend_Log::INFO,
|
100 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
101 |
+
);
|
102 |
|
103 |
+
$this->_redirect('*/*/index');
|
104 |
+
|
105 |
+
}//end massDeleteAction()
|
106 |
|
107 |
+
|
108 |
+
public function massRunAction()
|
109 |
+
{
|
110 |
$jobIds = $this->getRequest()->getParam('job_id');
|
111 |
if (!is_array($jobIds)) {
|
112 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
113 |
+
Mage::helper('reflektion')->__('Please select jobs(s) to execute.')
|
114 |
+
);
|
115 |
} else {
|
116 |
try {
|
117 |
+
$jobModel = Mage::getModel('reflektion/job')
|
118 |
+
->getCollection()
|
119 |
+
->addFieldToFilter('job_id', array('in' => $jobIds));
|
120 |
+
foreach ($jobModel as $jobs) {
|
121 |
+
Mage::log(
|
122 |
+
'Mass execute - Execute job id '.$jobs->getJobId(),
|
123 |
+
Zend_Log::INFO,
|
124 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
125 |
+
);
|
126 |
+
$jobs->setStartedAt(Mage::getSingleton('core/date')->gmtDate())->save()->run();
|
127 |
}
|
128 |
} catch (Exception $e) {
|
129 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
130 |
}
|
131 |
+
}//end if
|
132 |
|
133 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
134 |
+
Mage::helper('reflektion')->__(
|
135 |
+
'Total of %d jobs(s) were executed',
|
136 |
+
count($jobIds)
|
137 |
+
)
|
138 |
);
|
139 |
|
140 |
+
Mage::log(
|
141 |
+
'Mass execute - '.count($jobIds).' jobs executed.',
|
142 |
+
Zend_Log::INFO,
|
143 |
+
Reflektion_Catalogexport_Helper_Data::LOG_FILE
|
144 |
+
);
|
145 |
|
146 |
$this->_redirect('*/*/index');
|
|
|
147 |
|
148 |
+
}//end massRunAction()
|
149 |
+
|
150 |
+
|
151 |
+
}//end class
|
app/code/community/Reflektion/Catalogexport/etc/adminhtml.xml
CHANGED
@@ -58,8 +58,11 @@
|
|
58 |
<sort_order>1000</sort_order>
|
59 |
<children>
|
60 |
<export translate="title">
|
61 |
-
<title>
|
62 |
</export>
|
|
|
|
|
|
|
63 |
</children>
|
64 |
</reflektion>
|
65 |
</children>
|
58 |
<sort_order>1000</sort_order>
|
59 |
<children>
|
60 |
<export translate="title">
|
61 |
+
<title>Generate Feeds</title>
|
62 |
</export>
|
63 |
+
<job translate="title">
|
64 |
+
<title>Feeds in Queue</title>
|
65 |
+
</job>
|
66 |
</children>
|
67 |
</reflektion>
|
68 |
</children>
|
app/code/community/Reflektion/Catalogexport/etc/config.xml
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
|
14 |
<modules>
|
15 |
<Reflektion_Catalogexport>
|
16 |
-
<version>1.0.
|
17 |
</Reflektion_Catalogexport>
|
18 |
</modules>
|
19 |
|
13 |
|
14 |
<modules>
|
15 |
<Reflektion_Catalogexport>
|
16 |
+
<version>1.0.5</version>
|
17 |
</Reflektion_Catalogexport>
|
18 |
</modules>
|
19 |
|
app/code/community/Reflektion/Catalogexport/etc/system.xml
CHANGED
@@ -113,8 +113,8 @@
|
|
113 |
</username>
|
114 |
<password translate="label">
|
115 |
<label>Password</label>
|
116 |
-
<frontend_type>
|
117 |
-
|
118 |
<sort_order>5</sort_order>
|
119 |
<show_in_default>0</show_in_default>
|
120 |
<show_in_website>1</show_in_website>
|
113 |
</username>
|
114 |
<password translate="label">
|
115 |
<label>Password</label>
|
116 |
+
<frontend_type>obscure</frontend_type>
|
117 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
118 |
<sort_order>5</sort_order>
|
119 |
<show_in_default>0</show_in_default>
|
120 |
<show_in_website>1</show_in_website>
|
app/code/community/Reflektion/Catalogexport/sql/.DS_Store
DELETED
Binary file
|
app/code/community/Reflektion/Catalogexport/sql/reflektion_setup/mysql4-install-1.0.0.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* @category Reflektion
|
5 |
* @package Reflektion_Catalogexport
|
@@ -10,27 +9,108 @@
|
|
10 |
*/
|
11 |
$installer = $this;
|
12 |
$installer->startSetup();
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
$installer->endSetup();
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* @category Reflektion
|
4 |
* @package Reflektion_Catalogexport
|
9 |
*/
|
10 |
$installer = $this;
|
11 |
$installer->startSetup();
|
12 |
+
$table = $installer->getConnection()->newTable($installer->getTable('reflektion/job'))
|
13 |
+
->addColumn(
|
14 |
+
'job_id',
|
15 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
16 |
+
null,
|
17 |
+
array(
|
18 |
+
'unsigned' => true,
|
19 |
+
'nullable' => false,
|
20 |
+
'primary' => true,
|
21 |
+
'identity' => true,
|
22 |
+
),
|
23 |
+
'Job Id'
|
24 |
+
)
|
25 |
+
->addColumn(
|
26 |
+
'website_id',
|
27 |
+
Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
28 |
+
6,
|
29 |
+
array(
|
30 |
+
'unsigned' => true,
|
31 |
+
'nullable' => false,
|
32 |
+
),
|
33 |
+
'Website Id'
|
34 |
+
)
|
35 |
+
->addColumn(
|
36 |
+
'dependent_on_job_id',
|
37 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
38 |
+
null,
|
39 |
+
array('unsigned' => true),
|
40 |
+
'Dependent On Job Id'
|
41 |
+
)
|
42 |
+
->addColumn(
|
43 |
+
'min_entity_id',
|
44 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
45 |
+
null,
|
46 |
+
array('unsigned' => true),
|
47 |
+
'Min Entity Id'
|
48 |
+
)
|
49 |
+
->addColumn(
|
50 |
+
'type',
|
51 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
52 |
+
40,
|
53 |
+
array('nullable' => false),
|
54 |
+
'Type'
|
55 |
+
)
|
56 |
+
->addColumn(
|
57 |
+
'feed_type',
|
58 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
59 |
+
40,
|
60 |
+
array('nullable' => false),
|
61 |
+
'Feed Type'
|
62 |
+
)
|
63 |
+
->addColumn(
|
64 |
+
'status',
|
65 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
66 |
+
11,
|
67 |
+
array('nullable' => false),
|
68 |
+
'Status'
|
69 |
+
)
|
70 |
+
->addColumn(
|
71 |
+
'scheduled_at',
|
72 |
+
Varien_Db_Ddl_Table::TYPE_DATETIME,
|
73 |
+
null,
|
74 |
+
array('nullable' => true),
|
75 |
+
'Scheduled At'
|
76 |
+
)
|
77 |
+
->addColumn(
|
78 |
+
'started_at',
|
79 |
+
Varien_Db_Ddl_Table::TYPE_DATETIME,
|
80 |
+
null,
|
81 |
+
array('nullable' => true),
|
82 |
+
'Started At'
|
83 |
+
)
|
84 |
+
->addColumn(
|
85 |
+
'ended_at',
|
86 |
+
Varien_Db_Ddl_Table::TYPE_DATETIME,
|
87 |
+
null,
|
88 |
+
array('nullable' => true),
|
89 |
+
'Ended At'
|
90 |
+
)
|
91 |
+
->addColumn(
|
92 |
+
'error_message',
|
93 |
+
Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
94 |
+
64,
|
95 |
+
array('nullable' => false),
|
96 |
+
'Error Message'
|
97 |
+
)
|
98 |
+
->addIndex(
|
99 |
+
$installer->getIdxName(
|
100 |
+
'reflektion/job',
|
101 |
+
array(
|
102 |
+
'type',
|
103 |
+
'feed_type',
|
104 |
+
'status',
|
105 |
+
)
|
106 |
+
),
|
107 |
+
array(
|
108 |
+
'type',
|
109 |
+
'feed_type',
|
110 |
+
'status',
|
111 |
+
)
|
112 |
+
)
|
113 |
+
->setComment('reflektion/job entity table');
|
114 |
+
$installer->getConnection()->createTable($table);
|
115 |
|
116 |
$installer->endSetup();
|
app/etc/modules/Reflektion_Catalogexport.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
<Reflektion_Catalogexport>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
-
<version>1.0.
|
8 |
</Reflektion_Catalogexport>
|
9 |
</modules>
|
10 |
</config>
|
4 |
<Reflektion_Catalogexport>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
+
<version>1.0.5</version>
|
8 |
</Reflektion_Catalogexport>
|
9 |
</modules>
|
10 |
</config>
|
package.xml
CHANGED
@@ -1,27 +1,36 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Reflektion_Individualization_Extension</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Reflektion Individualization Extension</summary>
|
10 |
-
<description>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<authors><author><name>Amar</name><user>Reflektion</user><email>amar.chokhawala@reflektion.com</email></author></authors>
|
22 |
-
<date>2016-03
|
23 |
-
<time>
|
24 |
-
<contents><target name="magecommunity"><dir name="Reflektion"><dir name="Catalogexport"><dir name="Block"><dir name="Adminhtml"><dir name="Export"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="
|
25 |
<compatible/>
|
26 |
<dependencies><required><php><min>5.4.0</min><max>5.6.18</max></php></required></dependencies>
|
27 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Reflektion_Individualization_Extension</name>
|
4 |
+
<version>1.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Reflektion Individualization Extension</summary>
|
10 |
+
<description>MAJOR HIGHLIGHTS AND IMPROVEMENTS 
|
11 |
+

|
12 |
+
- Compatible with Magento Enterprise versions 1.11.x to 1.14.x
|
13 |
+
- Performance increased
|
14 |
+

|
15 |
+

|
16 |
+
FIXES
|
17 |
+

|
18 |
+
- Access Control List issue
|
19 |
+
- Issues fixed to enhance performance</description>
|
20 |
+
<notes>MAJOR HIGHLIGHTS AND IMPROVEMENTS 
|
21 |
+

|
22 |
+
- Compatible with Magento Enterprise versions 1.11.x to 1.14.x
|
23 |
+
- Performance increased
|
24 |
+

|
25 |
+

|
26 |
+
FIXES
|
27 |
+

|
28 |
+
- Access Control List issue
|
29 |
+
- Issues fixed to enhance performance</notes>
|
30 |
<authors><author><name>Amar</name><user>Reflektion</user><email>amar.chokhawala@reflektion.com</email></author></authors>
|
31 |
+
<date>2016-11-03</date>
|
32 |
+
<time>12:36:20</time>
|
33 |
+
<contents><target name="magecommunity"><dir name="Reflektion"><dir name="Catalogexport"><dir name="Block"><dir name="Adminhtml"><dir name="Export"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="8cfdbd74115747329c1bf4a37c305e5f"/></dir></dir><file name="Grid.php" hash="53de8c1d7361b3326707548406628652"/></dir><file name="Export.php" hash="1b9aa1d945f2f524024bf6da091054c4"/><dir name="Job"><file name="Grid.php" hash="07b92f9d81cb75a98a86518ab8f00813"/></dir><file name="Job.php" hash="a0d86c2dc69ce00d64c5e60b6e023854"/><dir name="System"><dir name="Config"><file name="CommentText.php" hash="6a6429d2c09f4908de1248821467d8e4"/></dir></dir></dir></dir><dir name="Helper"><file name="Csvfile.php" hash="2758a9c1c851dd729d33b419b5c4661a"/><file name="Data.php" hash="7ec7ff0f7248f89e98482291ba9890a0"/><file name="SftpConnection.php" hash="7faf438ad5394c39764c2a97df0d5424"/></dir><dir name="Model"><dir name="Feed"><file name="Base.php" hash="908a1e10aed857073f08c8759b6db631"/><file name="Product.php" hash="ac562c54f390ce718ba3283ed0038363"/></dir><file name="Generatefeeds.php" hash="68d0a2ec113c6a41f081759802f3b18d"/><file name="Job.php" hash="8b4bc070b0000f7595a40172284a2efa"/><file name="Layout.php" hash="1517215bf85ae5e4d6ee03378498cb6a"/><dir name="Mysql4"><dir name="Job"><file name="Collection.php" hash="7ad38af7c67655e892786fb9c81b00a2"/></dir><file name="Job.php" hash="3e9e086e2d2588b5b0320f982385fc1e"/></dir><file name="Observer.php" hash="904710061a8357cfdf2598ea5fd2c86a"/><dir name="System"><dir name="Config"><file name="Cron.php" hash="87e8d535a65d69031026c0a314cf573c"/><file name="EnableToggle.php" hash="1290a06669cf0a7bb976263c6f95c76c"/><file name="ProductAttributes.php" hash="a61cecaa2c75d5e16fb6fdf72bc97b08"/></dir><dir name="Validate"><file name="ProductAttributes.php" hash="7cfc50bb32146c2aae3f2486cefed085"/></dir></dir><file name="Transferfeeds.php" hash="8e1ca05aa52a07c6fc284d895aacc5f9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="39c2bf93cc410d64c7f8652a50a74081"/><file name="JobController.php" hash="819c6f77a51b4991292604c382b81ad5"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ae63206cec83b8750e77f92d5c5e9cc3"/><file name="config.xml" hash="1710e46c694983c02eeceb96da539ee0"/><file name="system.xml" hash="974c45609aae85f7d88bba662059c589"/></dir><dir name="sql"><dir name="reflektion_setup"><file name="mysql4-install-1.0.0.php" hash="d94aff06ad136a36df9b5f4d3389b1a4"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Reflektion_Catalogexport.xml" hash="2d238aea1ceafc200455fa3b51c48c49"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="reflektion.xml" hash="8e111b6a81750b38bf7b75cc4f9172ec"/></dir></dir></dir></dir></target></contents>
|
34 |
<compatible/>
|
35 |
<dependencies><required><php><min>5.4.0</min><max>5.6.18</max></php></required></dependencies>
|
36 |
</package>
|