straker-translations-easy-translation-platform - Version 1.4.0

Version Notes

1) fix bugs
2) performance improvement
3) compatible with PHP 5.4

Download this release

Release Info

Developer Chris
Extension straker-translations-easy-translation-platform
Version 1.4.0
Comparing to
See all releases


Code changes from version 1.3.9 to 1.4.0

Files changed (53) hide show
  1. app/code/community/StrakerTranslations/EasyTranslationPlatform/.DS_Store +0 -0
  2. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Block/Grid.php +4 -0
  3. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Page/Grid.php +4 -0
  4. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute.php +1 -1
  5. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute/Grid.php +61 -54
  6. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php +1 -1
  7. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category/Grid.php +1 -8
  8. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block.php +1 -1
  9. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block/Grid.php +88 -7
  10. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page.php +1 -1
  11. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page/Grid.php +124 -36
  12. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php +1 -1
  13. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php +1 -1
  14. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Grid.php +5 -6
  15. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Block/Grid.php +2 -2
  16. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Page/Grid.php +1 -1
  17. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Confirm/Grid.php +1 -1
  18. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php +1 -1
  19. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Backend.php +20 -5
  20. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/CmsVersion.php +19 -19
  21. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateOptions.php +1 -1
  22. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Frontend.php +22 -5
  23. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Selected.php +50 -19
  24. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TextArea.php +13 -0
  25. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TranslateOptions.php +1 -1
  26. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Attribute/Translate.php +52 -48
  27. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Category/Translate.php +20 -14
  28. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Block/Translate.php +25 -25
  29. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Page/Translate.php +38 -30
  30. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php +162 -87
  31. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Product/Translate.php +19 -22
  32. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute/Collection.php +11 -0
  33. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Block/Collection.php +12 -0
  34. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Page/Collection.php +12 -0
  35. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/AttributeController.php +7 -7
  36. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/CategoryController.php +5 -5
  37. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/Cms/BlockController.php +10 -7
  38. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/Cms/PageController.php +8 -7
  39. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/JobController.php +21 -15
  40. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/ProductController.php +11 -7
  41. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/CallbackController.php +1 -1
  42. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/.DS_Store +0 -0
  43. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config.xml +13 -10
  44. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config_live.xml +156 -0
  45. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system.xml +108 -108
  46. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system_live.xml +167 -0
  47. app/code/community/StrakerTranslations/EasyTranslationPlatform/sql/.DS_Store +0 -0
  48. app/design/adminhtml/default/straker/layout/straker.xml +2 -6
  49. app/design/adminhtml/default/straker/template/straker/{footer_script.phtml → feedback_script.phtml} +2 -2
  50. app/design/adminhtml/default/straker/template/straker/new/attribute/confirm.phtml +1 -1
  51. package.xml +8 -6
  52. skin/adminhtml/default/straker/.DS_Store +0 -0
  53. skin/adminhtml/default/straker/css/straker.css +4 -1
app/code/community/StrakerTranslations/EasyTranslationPlatform/.DS_Store DELETED
Binary file
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Block/Grid.php CHANGED
@@ -10,6 +10,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Cms_Block_Grid
10
'straker.new_entity_id = main_table.block_id',
11
array('straker_translated' => 'straker.version')
12
);
13
$this->setCollection($collection);
14
15
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
10
'straker.new_entity_id = main_table.block_id',
11
array('straker_translated' => 'straker.version')
12
);
13
+
14
+ $collection->addFilterToMap('title', 'main_table.title');
15
+ $collection->addFilterToMap('identifier', 'main_table.identifier');
16
+
17
$this->setCollection($collection);
18
19
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Cms/Page/Grid.php CHANGED
@@ -10,6 +10,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Cms_Page_Grid
10
'straker.new_entity_id = main_table.page_id',
11
array('straker_translated' => 'straker.version')
12
);
13
$collection->setFirstStoreFlag(true);
14
$this->setCollection($collection);
15
10
'straker.new_entity_id = main_table.page_id',
11
array('straker_translated' => 'straker.version')
12
);
13
+
14
+ $collection->addFilterToMap('title', 'main_table.title');
15
+ $collection->addFilterToMap('identifier', 'main_table.identifier');
16
+
17
$collection->setFirstStoreFlag(true);
18
$this->setCollection($collection);
19
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Attribute/Grid.php CHANGED
@@ -51,87 +51,94 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute_
51
52
protected function _prepareColumns() {
53
$this->addColumn('id', array(
54
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
55
- 'type' => 'number',
56
- 'align' => 'right',
57
- 'width' => '50px',
58
- 'index' => 'id',
59
- 'filter_index' => 'main_table.id'
60
));
61
62
$this->addColumn('attribute_id', array(
63
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute ID'),
64
- 'type' => 'number',
65
- 'align' => 'left',
66
- 'index' => 'attribute_id',
67
- 'filter_index' => 'main_table.attribute_id'
68
));
69
70
$this->addColumn('attribute_code', array(
71
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
72
- 'align' => 'left',
73
- 'index' => 'attribute_code',
74
));
75
76
77
$this->addColumn('label_original', array(
78
- 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Source'),
79
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalLabel',
80
- 'align' => 'center',
81
- 'index' => false,
82
- 'sortable'=> false,
83
- 'filter' => false,
84
));
85
86
- $this->addColumn('option_original', array(
87
- 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Source'),
88
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalOption',
89
- 'align' => 'center',
90
- 'index' => false,
91
- 'sortable'=> false,
92
- 'filter' => false,
93
));
94
95
- $this->addColumn('label_translate', array(
96
- 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Target'),
97
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateLabel',
98
- 'align' => 'center',
99
- 'index' => false,
100
- 'sortable'=> false,
101
- 'filter' => false,
102
));
103
104
$this->addColumn('option_translate', array(
105
- 'header'=>Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Target'),
106
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateOption',
107
- 'align' => 'center',
108
- 'index' => false,
109
- 'sortable'=> false,
110
- 'filter' => false,
111
));
112
113
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
114
$this->addColumn('version', array(
115
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
116
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
117
- 'align' => 'center',
118
- 'index' => 'version',
119
'filter_condition_callback' => [$this, '_filterVersion'],
120
- 'options' => [
121
'0' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
122
'1' => Mage::helper('strakertranslations_easytranslationplatform')->__('Not Published')
123
],
124
- 'width' => '20%'
125
));
126
}
127
128
- // $this->addColumn('view_backend', array(
129
- // 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
130
- // 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
131
- // 'align' => 'center',
132
- // 'index' => false,
133
- // 'filter' => false,
134
- // ));
135
136
return parent::_prepareColumns();
137
}
@@ -162,7 +169,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Attribute_
162
163
$this->getMassactionBlock()->addItem('add', array(
164
'label' => Mage::helper('catalog')->__('Publish Translation'),
165
- 'url' => $this->getUrl('*/*/applyTranslation'),
166
'selected' => 1
167
));
168
51
52
protected function _prepareColumns() {
53
$this->addColumn('id', array(
54
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
55
+ 'type' => 'number',
56
+ 'align' => 'right',
57
+ 'width' => '50px',
58
+ 'index' => 'id',
59
+ 'filter_index' => 'main_table.id',
60
));
61
62
$this->addColumn('attribute_id', array(
63
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute ID'),
64
+ 'type' => 'number',
65
+ 'align' => 'left',
66
+ 'index' => 'attribute_id',
67
+ 'filter_index' => 'main_table.attribute_id',
68
+ 'width' => '50px'
69
));
70
71
$this->addColumn('attribute_code', array(
72
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Attribute Code'),
73
+ 'align' => 'left',
74
+ 'index' => 'attribute_code',
75
+ 'width' => '50px'
76
));
77
78
79
$this->addColumn('label_original', array(
80
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Source'),
81
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalLabel',
82
+ 'align' => 'center',
83
+ 'index' => false,
84
+ 'sortable' => false,
85
+ 'filter' => false,
86
+ 'width' => '15%'
87
));
88
89
+ $this->addColumn('label_translate', array(
90
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Label - Target'),
91
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateLabel',
92
+ 'align' => 'center',
93
+ 'index' => false,
94
+ 'sortable' => false,
95
+ 'filter' => false,
96
+ 'width' => '15%'
97
+
98
));
99
100
+ $this->addColumn('option_original', array(
101
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Source'),
102
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeOriginalOption',
103
+ 'align' => 'center',
104
+ 'index' => false,
105
+ 'sortable' => false,
106
+ 'filter' => false,
107
+ 'width' => '20%'
108
));
109
110
$this->addColumn('option_translate', array(
111
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Option - Target'),
112
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_AttributeTranslateOption',
113
+ 'align' => 'center',
114
+ 'index' => false,
115
+ 'sortable' => false,
116
+ 'filter' => false,
117
+ 'width' => '20%'
118
));
119
120
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
121
$this->addColumn('version', array(
122
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
123
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
124
+ 'align' => 'center',
125
+ 'index' => 'version',
126
'filter_condition_callback' => [$this, '_filterVersion'],
127
+ 'options' => [
128
'0' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
129
'1' => Mage::helper('strakertranslations_easytranslationplatform')->__('Not Published')
130
],
131
+ 'width' => '50px'
132
));
133
}
134
135
+ $this->addColumn('view_backend', array(
136
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
137
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
138
+ 'align' => 'center',
139
+ 'index' => false,
140
+ 'filter' => false,
141
+ ));
142
143
return parent::_prepareColumns();
144
}
169
170
$this->getMassactionBlock()->addItem('add', array(
171
'label' => Mage::helper('catalog')->__('Publish Translation'),
172
+ 'url' => $this->getUrl('*/*/publish'),
173
'selected' => 1
174
));
175
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category e
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category/Grid.php CHANGED
@@ -113,13 +113,6 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
113
));
114
}
115
116
- $this->addColumn('view_frontend', array(
117
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Frontend'),
118
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Frontend',
119
- 'align' => 'center',
120
- 'index' => false,
121
- 'filter' => false,
122
- ));
123
124
$this->addColumn('view_backend', array(
125
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
@@ -160,7 +153,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category_G
160
161
$this->getMassactionBlock()->addItem('add', array(
162
'label' => Mage::helper('catalog')->__('Publish Translation'),
163
- 'url' => $this->getUrl('*/*/applyTranslation'),
164
'selected' => 1
165
));
166
$this->getMassactionBlock()->setTemplate('straker/job/category/massaction.phtml');
113
));
114
}
115
116
117
$this->addColumn('view_backend', array(
118
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
153
154
$this->getMassactionBlock()->addItem('add', array(
155
'label' => Mage::helper('catalog')->__('Publish Translation'),
156
+ 'url' => $this->getUrl('*/*/publish'),
157
'selected' => 1
158
));
159
$this->getMassactionBlock()->setTemplate('straker/job/category/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Block/Grid.php CHANGED
@@ -28,20 +28,49 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
-
32
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->getCollection()
33
->addFieldToFilter('main_table.job_id', $job->getId());
34
35
//echo $collection->getSelect(); die();
36
$this->setCollection($collection);
37
return parent::_prepareCollection();
38
}
39
40
protected function _prepareColumns() {
41
- $this->addColumn('title', array(
42
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Title'),
43
'align' => 'center',
44
- 'index' => 'title'
45
));
46
47
$this->addColumn('identifier', array(
@@ -50,10 +79,54 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
50
'index' => 'identifier'
51
));
52
53
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
54
$this->addColumn('version', array(
55
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
56
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion',
57
'align' => 'center',
58
'type' => 'options',
59
'index' => 'version',
@@ -66,6 +139,14 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
66
));
67
}
68
69
return parent::_prepareColumns();
70
}
71
@@ -96,7 +177,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
96
97
$this->getMassactionBlock()->addItem('add', array(
98
'label' => Mage::helper('catalog')->__('Publish Translation'),
99
- 'url' => $this->getUrl('*/*/applyTranslation'),
100
'selected' => 1
101
));
102
@@ -107,8 +188,8 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Block_
107
108
109
// Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
110
- return $this;
111
}
112
}
113
114
protected function _prepareMassactionColumn()
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
+ $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_block_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
32
+ /** @var StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Block_Collection $collection */
33
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->getCollection()
34
->addFieldToFilter('main_table.job_id', $job->getId());
35
36
//echo $collection->getSelect(); die();
37
+ $collection->getSelect()
38
+ ->joinLeft(
39
+ array('translate' => $collection->getTable('strakertranslations_easytranslationplatform/cms_block_translate')),
40
+ 'main_table.id = translate.id
41
+ AND translate.cms_block_id = main_table.block_id AND translate.job_id = '.$job->getId(),
42
+ array()
43
+ );
44
+
45
+ //loop through this job's attributes and join them to the collection
46
+ foreach ($jobAttributes as $jobAttribute) {
47
+ $attributeCode = $jobAttribute->getColumnName();
48
+ $collection->getSelect()->joinLeft(
49
+ array($attributeCode => $collection->getTable('strakertranslations_easytranslationplatform/cms_block_translate')),
50
+ $attributeCode . '.cms_block_id = main_table.block_id
51
+ AND ' . $attributeCode . '.column_name = \'' . $attributeCode . '\'
52
+ AND ' . $attributeCode . '.job_id = ' . $job->getId(),
53
+ array($attributeCode . '_original' => 'original', $attributeCode . '_translate' => 'translate')
54
+ );
55
+ }
56
+
57
$this->setCollection($collection);
58
return parent::_prepareCollection();
59
}
60
61
protected function _prepareColumns() {
62
+ $this->addColumn('id', array(
63
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
64
+ 'align' => 'center',
65
+ 'width' => '50px',
66
+ 'index' => 'id'
67
+ ));
68
+
69
+ $this->addColumn('block_id', array(
70
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Block ID'),
71
'align' => 'center',
72
+ 'width' => '50px',
73
+ 'index' => 'block_id'
74
));
75
76
$this->addColumn('identifier', array(
79
'index' => 'identifier'
80
));
81
82
+ $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
83
+ $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_block_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
84
+ //loop through this job's attributes and add columns to the grid
85
+ foreach ($jobAttributes as $jobAttribute) {
86
+ $attributeCode = $jobAttribute->getColumnName();
87
+ if($attributeCode === 'content'){
88
+ $this->addColumn($attributeCode . '_original', array(
89
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
90
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
91
+ 'align' => 'left',
92
+ 'index' => $attributeCode . '_original',
93
+ 'filter' => false,
94
+ 'sortable' => false
95
+ ));
96
+
97
+ $this->addColumn($attributeCode . '_translate', array(
98
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
99
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
100
+ 'align' => 'left',
101
+ 'index' => $attributeCode . '_translate',
102
+ 'filter' => false,
103
+ 'sortable' => false
104
+ ));
105
+ }else{
106
+ $this->addColumn($attributeCode . '_original', array(
107
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
108
+ 'align' => 'left',
109
+ 'index' => $attributeCode . '_original',
110
+ // 'filter_index' => $attributeCode.'.translate',
111
+ 'filter' => false,
112
+ 'sortable' => false
113
+ ));
114
+
115
+ $this->addColumn($attributeCode . '_translate', array(
116
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
117
+ 'align' => 'left',
118
+ 'index' => $attributeCode . '_translate',
119
+ // 'filter_index' => $attributeCode.'.translate',
120
+ 'filter' => false,
121
+ 'sortable' => false
122
+ ));
123
+ }
124
+ }
125
+
126
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
127
$this->addColumn('version', array(
128
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
129
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
130
'align' => 'center',
131
'type' => 'options',
132
'index' => 'version',
139
));
140
}
141
142
+ $this->addColumn('view_backend', array(
143
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
144
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
145
+ 'align' => 'center',
146
+ 'index' => false,
147
+ 'filter' => false,
148
+ ));
149
+
150
return parent::_prepareColumns();
151
}
152
177
178
$this->getMassactionBlock()->addItem('add', array(
179
'label' => Mage::helper('catalog')->__('Publish Translation'),
180
+ 'url' => $this->getUrl('*/*/publish'),
181
'selected' => 1
182
));
183
188
189
190
// Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
191
}
192
+ return $this;
193
}
194
195
protected function _prepareMassactionColumn()
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page e
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Cms/Page/Grid.php CHANGED
@@ -28,20 +28,49 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
-
32
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->getCollection()
33
->addFieldToFilter('main_table.job_id', $job->getId());
34
35
$this->setCollection($collection);
36
return parent::_prepareCollection();
37
}
38
39
protected function _prepareColumns() {
40
41
- $this->addColumn('title', array(
42
- 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Title'),
43
'align' => 'center',
44
- 'index' => 'title'
45
));
46
47
$this->addColumn('identifier', array(
@@ -50,10 +79,54 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
50
'index' => 'identifier'
51
));
52
53
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
54
$this->addColumn('version', array(
55
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
56
- 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion',
57
'align' => 'center',
58
'type' => 'options',
59
'index' => 'version',
@@ -66,6 +139,21 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
66
));
67
}
68
69
return parent::_prepareColumns();
70
}
71
@@ -96,7 +184,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
96
97
$this->getMassactionBlock()->addItem('add', array(
98
'label' => Mage::helper('catalog')->__('Publish Translation'),
99
- 'url' => $this->getUrl('*/*/applyTranslation'),
100
'selected' => 1
101
));
102
@@ -111,36 +199,36 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Cms_Page_G
111
return $this;
112
}
113
114
- // protected function _prepareMassactionColumn()
115
- // {
116
- // if ($this->getStatusId() == '4') {
117
- // $columnId = 'massaction';
118
- // $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
119
- // ->setData(array(
120
- // 'index' => $this->getMassactionIdField(),
121
- // 'use_index' => $this->getMassactionIdField(),
122
- // 'filter_index' => $this->getMassactionIdFilter(),
123
- // 'type' => 'massaction',
124
- // 'name' => $this->getMassactionBlock()->getFormFieldName(),
125
- // 'align' => 'center',
126
- // 'is_system' => true
127
- // ));
128
- //
129
- // if ($this->getNoFilterMassactionColumn()) {
130
- // $massactionColumn->setData('filter', false);
131
- // }
132
- //
133
- // $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
134
- // ->setGrid($this)
135
- // ->setId($columnId);
136
- //
137
- // $oldColumns = $this->_columns;
138
- // $this->_columns = array();
139
- // $this->_columns[$columnId] = $massactionColumn;
140
- // $this->_columns = array_merge($this->_columns, $oldColumns);
141
- // return $this;
142
- // }
143
- // }
144
145
public function getMainButtonsHtml()
146
{
28
protected function _prepareCollection() {
29
// $prefix = Mage::getConfig()->getTablePrefix()->__toString();
30
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
31
+ $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_page_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
32
+ /** @var StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Page_Collection $collection */
33
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->getCollection()
34
->addFieldToFilter('main_table.job_id', $job->getId());
35
36
+ //echo $collection->getSelect(); die();
37
+ $collection->getSelect()
38
+ ->joinLeft(
39
+ array('translate' => $collection->getTable('strakertranslations_easytranslationplatform/cms_page_translate')),
40
+ 'main_table.id = translate.id
41
+ AND translate.cms_page_id = main_table.page_id AND translate.job_id = '.$job->getId(),
42
+ array()
43
+ );
44
+
45
+ //loop through this job's attributes and join them to the collection
46
+ foreach ($jobAttributes as $jobAttribute) {
47
+ $attributeCode = $jobAttribute->getColumnName();
48
+ $collection->getSelect()->joinLeft(
49
+ array($attributeCode => $collection->getTable('strakertranslations_easytranslationplatform/cms_page_translate')),
50
+ $attributeCode . '.cms_page_id = main_table.page_id
51
+ AND ' . $attributeCode . '.column_name = \'' . $attributeCode . '\'
52
+ AND ' . $attributeCode . '.job_id = ' . $job->getId(),
53
+ array($attributeCode . '_original' => 'original', $attributeCode . '_translate' => 'translate')
54
+ );
55
+ }
56
+
57
$this->setCollection($collection);
58
return parent::_prepareCollection();
59
}
60
61
protected function _prepareColumns() {
62
+ $this->addColumn('id', array(
63
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
64
+ 'align' => 'center',
65
+ 'width' => '50px',
66
+ 'index' => 'id'
67
+ ));
68
69
+ $this->addColumn('page_id', array(
70
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Page ID'),
71
'align' => 'center',
72
+ 'width' => '50px',
73
+ 'index' => 'page_id'
74
));
75
76
$this->addColumn('identifier', array(
79
'index' => 'identifier'
80
));
81
82
+ $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
83
+ $jobAttributes = Mage::getModel('strakertranslations_easytranslationplatform/cms_page_attributes')->getCollection()->addFieldToFilter('job_id', $job->getId());
84
+ //loop through this job's attributes and add columns to the grid
85
+ foreach ($jobAttributes as $jobAttribute) {
86
+ $attributeCode = $jobAttribute->getColumnName();
87
+ if($attributeCode === 'content'){
88
+ $this->addColumn($attributeCode . '_original', array(
89
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
90
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
91
+ 'align' => 'left',
92
+ 'index' => $attributeCode . '_original',
93
+ 'filter' => false,
94
+ 'sortable' => false
95
+ ));
96
+
97
+ $this->addColumn($attributeCode . '_translate', array(
98
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
99
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea',
100
+ 'align' => 'left',
101
+ 'index' => $attributeCode . '_translate',
102
+ 'filter' => false,
103
+ 'sortable' => false
104
+ ));
105
+ }else{
106
+ $this->addColumn($attributeCode . '_original', array(
107
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Source', ucfirst($attributeCode)),
108
+ 'align' => 'left',
109
+ 'index' => $attributeCode . '_original',
110
+ // 'filter_index' => $attributeCode.'.original',
111
+ 'filter' => false,
112
+ 'sortable' => false
113
+ ));
114
+
115
+ $this->addColumn($attributeCode . '_translate', array(
116
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('%s - Target', ucfirst($attributeCode)),
117
+ 'align' => 'left',
118
+ 'index' => $attributeCode . '_translate',
119
+ // 'filter_index' => $attributeCode.'.translate',
120
+ 'filter' => false,
121
+ 'sortable' => false
122
+ ));
123
+ }
124
+ }
125
+
126
if ($this->getStatusId() == '4' || $this->getStatusId() == '5'){
127
$this->addColumn('version', array(
128
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Published'),
129
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Version',
130
'align' => 'center',
131
'type' => 'options',
132
'index' => 'version',
139
));
140
}
141
142
+ $this->addColumn('view_frontend', array(
143
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Frontend'),
144
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Frontend',
145
+ 'align' => 'center',
146
+ 'index' => false,
147
+ 'filter' => false,
148
+ ));
149
+ $this->addColumn('view_backend', array(
150
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('View Backend'),
151
+ 'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Backend',
152
+ 'align' => 'center',
153
+ 'index' => false,
154
+ 'filter' => false,
155
+ ));
156
+
157
return parent::_prepareColumns();
158
}
159
184
185
$this->getMassactionBlock()->addItem('add', array(
186
'label' => Mage::helper('catalog')->__('Publish Translation'),
187
+ 'url' => $this->getUrl('*/*/publish'),
188
'selected' => 1
189
));
190
199
return $this;
200
}
201
202
+ protected function _prepareMassactionColumn()
203
+ {
204
+ if ($this->getStatusId() == '4') {
205
+ $columnId = 'massaction';
206
+ $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
207
+ ->setData(array(
208
+ 'index' => $this->getMassactionIdField(),
209
+ 'use_index' => $this->getMassactionIdField(),
210
+ 'filter_index' => $this->getMassactionIdFilter(),
211
+ 'type' => 'massaction',
212
+ 'name' => $this->getMassactionBlock()->getFormFieldName(),
213
+ 'align' => 'center',
214
+ 'is_system' => true
215
+ ));
216
+
217
+ if ($this->getNoFilterMassactionColumn()) {
218
+ $massactionColumn->setData('filter', false);
219
+ }
220
+
221
+ $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
222
+ ->setGrid($this)
223
+ ->setId($columnId);
224
+
225
+ $oldColumns = $this->_columns;
226
+ $this->_columns = array();
227
+ $this->_columns[$columnId] = $massactionColumn;
228
+ $this->_columns = array_merge($this->_columns, $oldColumns);
229
+ return $this;
230
+ }
231
+ }
232
233
public function getMainButtonsHtml()
234
{
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php CHANGED
@@ -16,7 +16,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product ex
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
- 'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
16
if ( $jobStatus == '4'){
17
$this->_addButton('publish', array(
18
'label' => Mage::helper('catalog')->__('Publish All Translations'),
19
+ 'onclick' => "setLocation('{$this->getUrl('*/*/publishAll',array('job_id'=>$jobId))}');",
20
'class' => 'task'
21
));
22
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php CHANGED
@@ -174,7 +174,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
174
175
$this->getMassactionBlock()->addItem('add', array(
176
'label' => Mage::helper('catalog')->__('Publish Translation'),
177
- 'url' => $this->getUrl('*/*/applyTranslation'),
178
'selected' => 1
179
));
180
$this->getMassactionBlock()->setTemplate('straker/job/product/massaction.phtml');
174
175
$this->getMassactionBlock()->addItem('add', array(
176
'label' => Mage::helper('catalog')->__('Publish Translation'),
177
+ 'url' => $this->getUrl('*/*/publish'),
178
'selected' => 1
179
));
180
$this->getMassactionBlock()->setTemplate('straker/job/product/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Attribute/Grid.php CHANGED
@@ -167,12 +167,11 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_
167
return $this;
168
}
169
170
- if ($value == 'select' ){
171
- $collection->getSelect()->where('frontend_input=?', 'select');
172
} else {
173
- $collection->getSelect()->where('frontend_input<>?', 'select');
174
}
175
-
176
return $this;
177
}
178
@@ -184,7 +183,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_
184
185
$this->getMassactionBlock()->addItem('add', array(
186
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
187
- 'url' => $this->getUrl('*/*/addtoconfirm'),
188
'selected' => 1
189
));
190
$this->getMassactionBlock()->setTemplate('straker/new/attribute/massaction.phtml');
@@ -213,7 +212,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Attribute_
213
$AttributeIdsWithOption->reset(Zend_Db_Select::LIMIT_OFFSET);
214
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
215
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
216
- $AttributeIdsWithOption->where('frontend_input=?','select');
217
$AttributeIdsWithOption->columns('attribute_id', 'main_table');
218
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($AttributeIdsWithOption);
219
}
167
return $this;
168
}
169
170
+ if ( in_array($value, ['select','multiselect'] ) ){
171
+ $collection->getSelect()->where('frontend_input in (?)', ['select','multiselect']);
172
} else {
173
+ $collection->getSelect()->where('frontend_input not in (?)', ['select','multiselect']);
174
}
175
return $this;
176
}
177
183
184
$this->getMassactionBlock()->addItem('add', array(
185
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
186
+ 'url' => $this->getUrl('*/*/addToConfirm'),
187
'selected' => 1
188
));
189
$this->getMassactionBlock()->setTemplate('straker/new/attribute/massaction.phtml');
212
$AttributeIdsWithOption->reset(Zend_Db_Select::LIMIT_OFFSET);
213
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
214
$AttributeIdsWithOption->reset(Zend_Db_Select::COLUMNS);
215
+ $AttributeIdsWithOption->where('frontend_input in (?)',['select','multiselect']);
216
$AttributeIdsWithOption->columns('attribute_id', 'main_table');
217
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($AttributeIdsWithOption);
218
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Block/Grid.php CHANGED
@@ -14,8 +14,8 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Cms_Block_
14
15
protected function _prepareCollection()
16
{
17
- $collection = Mage::getModel('cms/block')->getCollection();
18
/* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
19
$this->setCollection($collection);
20
return parent::_prepareCollection();
21
}
@@ -94,7 +94,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Cms_Block_
94
95
$this->getMassactionBlock()->addItem('add', array(
96
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
97
- 'url' => $this->getUrl('*/*/addtoconfirm'),
98
'selected' => 1
99
));
100
$this->getMassactionBlock()->setTemplate('straker/new/cms/block/massaction.phtml');
14
15
protected function _prepareCollection()
16
{
17
/* @var $collection Mage_Cms_Model_Mysql4_Block_Collection */
18
+ $collection = Mage::getModel('cms/block')->getCollection();
19
$this->setCollection($collection);
20
return parent::_prepareCollection();
21
}
94
95
$this->getMassactionBlock()->addItem('add', array(
96
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
97
+ 'url' => $this->getUrl('*/*/addToConfirm'),
98
'selected' => 1
99
));
100
$this->getMassactionBlock()->setTemplate('straker/new/cms/block/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Cms/Page/Grid.php CHANGED
@@ -108,7 +108,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Cms_Page_G
108
109
$this->getMassactionBlock()->addItem('add', array(
110
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
111
- 'url' => $this->getUrl('*/*/addtoconfirm'),
112
'selected' => 1
113
));
114
$this->getMassactionBlock()->setTemplate('straker/new/cms/page/massaction.phtml');
108
109
$this->getMassactionBlock()->addItem('add', array(
110
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
111
+ 'url' => $this->getUrl('*/*/addToConfirm'),
112
'selected' => 1
113
));
114
$this->getMassactionBlock()->setTemplate('straker/new/cms/page/massaction.phtml');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Confirm/Grid.php CHANGED
@@ -135,7 +135,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Confirm_Gr
135
136
public function getGridUrl()
137
{
138
- return $this->getUrl('*/*/addtoconfirm', array('_current'=>true));
139
}
140
141
public function getRowUrl($row)
135
136
public function getGridUrl()
137
{
138
+ return $this->getUrl('*/*/addToConfirm', array('_current'=>true));
139
}
140
141
public function getRowUrl($row)
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php CHANGED
@@ -269,7 +269,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
269
270
$this->getMassactionBlock()->addItem('add', array(
271
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
272
- 'url' => $this->getUrl('*/*/addtoconfirm'),
273
'selected' => 1
274
));
275
269
270
$this->getMassactionBlock()->addItem('add', array(
271
'label'=> Mage::helper('catalog')->__('Add to Confirm Page'),
272
+ 'url' => $this->getUrl('*/*/addToConfirm'),
273
'selected' => 1
274
));
275
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Backend.php CHANGED
@@ -7,23 +7,38 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
- $html .= '<p class="inactive">' . $this->__('View Product in Backend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->load($row->getProductId());
14
$url = $this->getUrl('adminhtml/catalog_product/edit', array(
15
'store' => $this->getStoreId($row),
16
- 'id' => $product->getId())
17
);
18
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View Product in Backend') . '</a>';
19
}
20
elseif($row->getCategoryId()) {
21
$category = Mage::getModel('catalog/category')->load($row->getCategoryId());
22
$url = $this->getUrl('adminhtml/catalog_category/edit', array(
23
'store' => $this->getStoreId($row),
24
- 'id' => $category->getId())
25
);
26
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View Category in Backend') . '</a>';
27
}
28
return $html;
29
}
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
+ $html .= '<p class="inactive">' . $this->__('View in Backend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->load($row->getProductId());
14
$url = $this->getUrl('adminhtml/catalog_product/edit', array(
15
'store' => $this->getStoreId($row),
16
+ 'id' => $product->getId()
17
+ )
18
);
19
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
20
+ }elseif($row->getAttributeId()){
21
+ $product = Mage::getModel('catalog/product')->load($row->getAttributeId());
22
+ $url = $this->getUrl('adminhtml/catalog_product_attribute/edit', array(
23
+ 'attribute_id' => $row->getAttributeId()
24
+ )
25
+ );
26
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
27
}
28
elseif($row->getCategoryId()) {
29
$category = Mage::getModel('catalog/category')->load($row->getCategoryId());
30
$url = $this->getUrl('adminhtml/catalog_category/edit', array(
31
'store' => $this->getStoreId($row),
32
+ 'id' => $category->getId()
33
+ )
34
);
35
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
36
+ }elseif($row->getPageId()){
37
+ $url = Mage::helper("adminhtml")->getUrl("adminhtml/cms_page/edit",array("page_id"=>$row->getNewEntityId()));
38
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
39
+ }elseif($row->getBlockId()){
40
+ $url = Mage::helper("adminhtml")->getUrl("adminhtml/cms_block/edit",array("block_id"=>$row->getNewEntityId()));
41
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Backend') . '</a>';
42
}
43
return $html;
44
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/CmsVersion.php CHANGED
@@ -1,20 +1,20 @@
1
<?php
2
- class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion
3
- extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
- {
5
- public function render(Varien_Object $row)
6
- {
7
- if($row->getVersion()){
8
- if($row->getBlockId()){
9
- $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_block/edit",array("block_id"=>$row->getNewEntityId()));
10
- }
11
- else{
12
- $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_page/edit",array("page_id"=>$row->getNewEntityId()));
13
- }
14
- return '<a href="'.$link.'" target="_blank">View Published</a>';
15
- }
16
- else{
17
- return 'Not Published';
18
- }
19
- }
20
- }
1
<?php
2
+ //class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_CmsVersion
3
+ // extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ //{
5
+ // public function render(Varien_Object $row)
6
+ // {
7
+ // if($row->getVersion()){
8
+ // if($row->getBlockId()){
9
+ // $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_block/edit",array("block_id"=>$row->getNewEntityId()));
10
+ // }
11
+ // else{
12
+ // $link = Mage::helper("adminhtml")->getUrl("adminhtml/cms_page/edit",array("page_id"=>$row->getNewEntityId()));
13
+ // }
14
+ // return '<a href="'.$link.'" target="_blank">View Published</a>';
15
+ // }
16
+ // else{
17
+ // return 'Not Published';
18
+ // }
19
+ // }
20
+ //}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/ConfirmTranslateOptions.php CHANGED
@@ -8,7 +8,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
8
9
public function render(Varien_Object $row){
10
$id = $row->getAttributeId();
11
- if ($row->getFrontendInput()=='select') {
12
$html = '<input disabled type="checkbox" name="option" value="' . $id . '" class="checkbox-option"';
13
if (in_array($id, $this->_getOption())) {
14
$html .= ' checked="checked" >';
8
9
public function render(Varien_Object $row){
10
$id = $row->getAttributeId();
11
+ if (in_array($row->getFrontendInput(), ['select', 'multiselect']) ) {
12
$html = '<input disabled type="checkbox" name="option" value="' . $id . '" class="checkbox-option"';
13
if (in_array($id, $this->_getOption())) {
14
$html .= ' checked="checked" >';
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Frontend.php CHANGED
@@ -7,20 +7,32 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
- $html .= '<p class="inactive">' . $this->__('View Product in Frontend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId($row))->load($row->getProductId());
14
if (!$product->isDisabled() && $product->isVisibleInSiteVisibility()) {
15
- $html .= '<a target="_blank" href="' . $product->getProductUrl() . '">' . $this->__('View Product in Frontend') . '</a>';
16
} else {
17
$html .= 'Product is not visible in frontend';
18
}
19
}
20
- elseif($row->getCategoryId()){
21
- $url = $this->getUrl('catalog/category/view', ['id' => $row->getCategoryId(), '_nosid' => true, '_query' => ['___store' => $this->getStoreId($row) ]]);
22
- $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View Category in Frontend') . '</a>';
23
}
24
return $html;
25
}
26
@@ -32,4 +44,9 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
32
}
33
return $this->_storeId;
34
}
35
}
7
public function render(Varien_Object $row){
8
$html = '';
9
if(!$row->getVersion()){
10
+ $html .= '<p class="inactive">' . $this->__('View in Frontend') . '</p>';
11
}
12
elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId($row))->load($row->getProductId());
14
if (!$product->isDisabled() && $product->isVisibleInSiteVisibility()) {
15
+ $html .= '<a target="_blank" href="' . $product->getProductUrl() . '">' . $this->__('View in Frontend') . '</a>';
16
} else {
17
$html .= 'Product is not visible in frontend';
18
}
19
}
20
+ elseif($row->getPageId()){
21
+ $url = '';
22
+ if ($row->getPreviewUrl()) {
23
+ $href = $row->getPreviewUrl();
24
+ } else {
25
+ $urlModel = Mage::getModel('core/url')->setStore($row->getData('_first_store_id'));
26
+ $url = $urlModel->getUrl(
27
+ $row->getIdentifier(), array(
28
+ '_current' => false,
29
+ '_query' => '___store=' . $this->getStoreCode($row),
30
+ )
31
+ );
32
+ }
33
+ $html .= '<a target="_blank" href="' . $url . '">' . $this->__('View in Frontend') . '</a>';
34
}
35
+
36
return $html;
37
}
38
44
}
45
return $this->_storeId;
46
}
47
+
48
+ protected function getStoreCode($row){
49
+ $this->getStoreId($row);
50
+ return Mage::app()->getStore($this->_storeId)->getCode();
51
+ }
52
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Selected.php CHANGED
@@ -8,50 +8,63 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
8
9
switch ($row->getTypeName()) {
10
case 'Product':
11
-
12
- $productAttrubuteCollection =
13
Mage::getModel('strakertranslations_easytranslationplatform/product_attributes')
14
->getCollection()->addFieldToFilter('job_id', $row->getId());
15
16
$output =array();
17
18
- foreach ($productAttrubuteCollection as $productAttrubute) {
19
- $output[] = $this->_getAttributeLabel($productAttrubute->getAttributeId());
20
}
21
$html = implode(', ', $output);
22
-
23
break;
24
-
25
case 'Category':
26
-
27
- $categoryAttrubuteCollection =
28
Mage::getModel('strakertranslations_easytranslationplatform/category_attributes')
29
->getCollection()->addFieldToFilter('job_id', $row->getId());
30
31
- $output =array();
32
-
33
- foreach ($categoryAttrubuteCollection as $categoryAttrubute) {
34
- $output[] = $this->_getAttributeLabel($categoryAttrubute->getAttributeId());
35
- }
36
- $html = implode(', ', $output);
37
38
break;
39
-
40
case 'Attribute':
41
-
42
$AttributeCollection =
43
Mage::getModel('strakertranslations_easytranslationplatform/job_attribute')
44
->getCollection()->addFieldToFilter('job_id', $row->getId());
45
46
- $output = count($AttributeCollection);
47
-
48
$html = $output > 1 ? "$output Attributes" : '1 Attribute';
49
50
break;
51
52
default:
53
$html = '';
54
-
55
}
56
57
return $html;
@@ -62,4 +75,22 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
62
private function _getAttributeLabel($attributeId) {
63
return Mage::getModel('eav/entity_attribute')->load($attributeId)->getFrontendLabel();
64
}
65
}
8
9
switch ($row->getTypeName()) {
10
case 'Product':
11
+ $productAttributeCollection =
12
Mage::getModel('strakertranslations_easytranslationplatform/product_attributes')
13
->getCollection()->addFieldToFilter('job_id', $row->getId());
14
15
$output =array();
16
17
+ foreach ($productAttributeCollection as $productAttribute) {
18
+ $output[] = $this->_getAttributeLabel($productAttribute->getAttributeId());
19
}
20
$html = implode(', ', $output);
21
break;
22
case 'Category':
23
+ $categoryAttributeCollection =
24
Mage::getModel('strakertranslations_easytranslationplatform/category_attributes')
25
->getCollection()->addFieldToFilter('job_id', $row->getId());
26
27
+ $output =array();
28
29
+ foreach ($categoryAttributeCollection as $categoryAttribute) {
30
+ $output[] = $this->_getAttributeLabel($categoryAttribute->getAttributeId());
31
+ }
32
+ $html = implode(', ', $output);
33
break;
34
case 'Attribute':
35
$AttributeCollection =
36
Mage::getModel('strakertranslations_easytranslationplatform/job_attribute')
37
->getCollection()->addFieldToFilter('job_id', $row->getId());
38
39
+ $output = count($AttributeCollection);
40
$html = $output > 1 ? "$output Attributes" : '1 Attribute';
41
+ break;
42
+ case 'CMS Block':
43
+ $cmsBlockAttributeCollection =
44
+ Mage::getModel('strakertranslations_easytranslationplatform/cms_block_attributes')
45
+ ->getCollection()->addFieldToFilter('job_id', $row->getId());
46
47
+ $output =array();
48
+
49
+ foreach ($cmsBlockAttributeCollection as $cmsAttribute) {
50
+ $output[] = $this->_formatColumnName($cmsAttribute->getData('column_name'));
51
+ }
52
+ $html = implode(', ', $output);
53
break;
54
+ case 'CMS Page':
55
+ $cmsPageAttributeCollection =
56
+ Mage::getModel('strakertranslations_easytranslationplatform/cms_page_attributes')
57
+ ->getCollection()->addFieldToFilter('job_id', $row->getId());
58
59
+ $output =array();
60
+
61
+ foreach ($cmsPageAttributeCollection as $cmsAttribute) {
62
+ $output[] = $this->_formatColumnName($cmsAttribute->getData('column_name'));
63
+ }
64
+ $html = implode(', ', $output);
65
+ break;
66
default:
67
$html = '';
68
}
69
70
return $html;
75
private function _getAttributeLabel($attributeId) {
76
return Mage::getModel('eav/entity_attribute')->load($attributeId)->getFrontendLabel();
77
}
78
+
79
+ private function _formatColumnName( $columnName ){
80
+ $return = '';
81
+ switch(strtolower($columnName)){
82
+ case 'meta_keywords':
83
+ $return = 'Meta Keywords';
84
+ break;
85
+ case 'meta_description':
86
+ $return = 'Meta Description';
87
+ break;
88
+ case 'content_heading':
89
+ $return = 'Content Heading';
90
+ break;
91
+ default:
92
+ $return = ucfirst($columnName);
93
+ }
94
+ return $return;
95
+ }
96
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TextArea.php ADDED
@@ -0,0 +1,13 @@
1
+ <?php
2
+ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_TextArea
3
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function render(Varien_Object $row)
6
+ {
7
+ $index = $this->getColumn()->getIndex();
8
+ if($index && $row->getData($index)){
9
+ $value = $row->getData($index);
10
+ return '<textarea cols="100" rows="10">' . htmlspecialchars($value) . '</textarea>';
11
+ }
12
+ }
13
+ }
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/TranslateOptions.php CHANGED
@@ -5,7 +5,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
5
protected $_storeId;
6
7
public function render(Varien_Object $row){
8
- if ($row->getFrontendInput()=='select') {
9
$html = '<input type="checkbox" name="option" value="' . $row->getAttributeId() . '" class="checkbox-option">';
10
}
11
else{
5
protected $_storeId;
6
7
public function render(Varien_Object $row){
8
+ if ( in_array($row->getFrontendInput(), ['select', 'multiselect'] ) ) {
9
$html = '<input type="checkbox" name="option" value="' . $row->getAttributeId() . '" class="checkbox-option">';
10
}
11
else{
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Attribute/Translate.php CHANGED
@@ -71,71 +71,75 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Attribute_Translate exte
71
//
72
// }
73
74
- if ($this->getTranslate()){
75
- $dataInJson = json_encode(simplexml_load_string($this->getTranslate()));
76
- $data = json_decode($dataInJson,true);
77
- $storeId = (int) $this->getStoreId();
78
- /** @var Mage_Eav_Model_Attribute $eavAttributeModel */
79
- $eavAttributeModel = Mage::getModel('eav/entity_attribute');
80
- foreach ($data as $k => $attribute ){
81
- if ($k == 'title' && $attribute){
82
- $attributeId = (int) $this->getAttributeId();
83
- $eavAttributeModel->load($attributeId);
84
- if(!empty($eavAttributeModel->getId())){
85
- $storeLabels = $eavAttributeModel->getStoreLabels();
86
- if(is_array($storeLabels)){
87
- //get all current stores
88
- $stores = array_keys($storeLabels);
89
- if(!in_array($storeId, $stores)){
90
- $storeLabels[$storeId] = trim($attribute);
91
- $eavAttributeModel->setData('store_labels', $storeLabels)->save();
92
}
93
}
94
}
95
- }
96
97
- if ($k == 'option' && $attribute){
98
- $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
99
100
- /* @var $model Mage_Catalog_Model_Entity_Attribute */
101
- $attrModel = Mage::getModel('catalog/resource_eav_attribute');
102
- $attrModel->load($this->getAttributeId());
103
104
- /** @var $valuesCollection Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection */
105
- $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
106
- ->setStoreFilter($storeId, false)
107
- ->setAttributeFilter($attrModel->getId());
108
109
- //0 => ['option_id' => '20', 'attribute_id' => '92', 'sort_order' => '0', 'value' => 'Black' ]
110
- $optionData = $valuesCollection->getData();
111
- $optionIds = array_column($optionData, 'option_id');
112
113
- $optionValueTable = $setup->getTable('eav/attribute_option_value');
114
115
- $newOptionData = [];
116
- foreach ($attribute as $optionId => $optionValue) {
117
- $optionId = str_replace('id_', '',$optionId);
118
- // /** @var Mage_Eav_Model_Entity_Attribute_Option $optionModel */
119
- // $optionModel = Mage::getModel('eav/entity_attribute_option');
120
- // $optionModel->load($optionId);
121
- if( !in_array($optionId, $optionIds)){
122
- array_push(
123
- $newOptionData,
124
- [
125
'option_id' => $optionId,
126
'store_id' => $storeId,
127
'value' => trim($optionValue)
128
- ]
129
- );
130
}
131
- }
132
- if($newOptionData){
133
- $setup->getConnection()->insertMultiple($optionValueTable, $newOptionData);
134
}
135
}
136
}
137
}
138
- $this->setIsImported(1)->save();
139
}
140
141
// private function _getConnection() {
71
//
72
// }
73
74
+ $success = true;
75
+ try{
76
+ if ($this->getTranslate()){
77
+ $dataInJson = json_encode(simplexml_load_string($this->getTranslate()));
78
+ $data = json_decode($dataInJson,true);
79
+ $storeId = (int) $this->getStoreId();
80
+ /** @var Mage_Eav_Model_Attribute $eavAttributeModel */
81
+ $eavAttributeModel = Mage::getModel('eav/entity_attribute');
82
+ foreach ($data as $k => $attribute ){
83
+ if ($k == 'title' && $attribute){
84
+ $attributeId = (int) $this->getAttributeId();
85
+ $eavAttributeModel->load($attributeId);
86
+ $eavAttributeModelId = $eavAttributeModel->getId();
87
+ if(!empty($eavAttributeModelId)){
88
+ $storeLabels = $eavAttributeModel->getStoreLabels();
89
+ if(is_array($storeLabels)){
90
+ //get all current stores
91
+ $stores = array_keys($storeLabels);
92
+ if(!in_array($storeId, $stores)){
93
+ $storeLabels[$storeId] = trim($attribute);
94
+ $eavAttributeModel->setData('store_labels', $storeLabels)->save();
95
+ }
96
}
97
}
98
}
99
100
+ if ($k == 'option' && $attribute){
101
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
102
103
+ /* @var $model Mage_Catalog_Model_Entity_Attribute */
104
+ $attrModel = Mage::getModel('catalog/resource_eav_attribute');
105
+ $attrModel->load($this->getAttributeId());
106
107
+ /** @var $valuesCollection Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection */
108
+ $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
109
+ ->setStoreFilter($storeId, false)
110
+ ->setAttributeFilter($attrModel->getId());
111
112
+ //0 => ['option_id' => '20', 'attribute_id' => '92', 'sort_order' => '0', 'value' => 'Black' ]
113
+ $optionData = $valuesCollection->getData();
114
+ $optionIds = array_column($optionData, 'option_id');
115
116
+ $optionValueTable = $setup->getTable('eav/attribute_option_value');
117
118
+ $newOptionData = [];
119
+ foreach ($attribute as $optionId => $optionValue) {
120
+ $optionId = str_replace('id_', '',$optionId);
121
+ // /** @var Mage_Eav_Model_Entity_Attribute_Option $optionModel */
122
+ // $optionModel = Mage::getModel('eav/entity_attribute_option');
123
+ // $optionModel->load($optionId);
124
+ if( !in_array($optionId, $optionIds)){
125
+ $newOptionData[] = [
126
'option_id' => $optionId,
127
'store_id' => $storeId,
128
'value' => trim($optionValue)
129
+ ];
130
+ }
131
+ }
132
+ if($newOptionData){
133
+ $setup->getConnection()->insertMultiple($optionValueTable, $newOptionData);
134
}
135
}
136
}
137
}
138
+ $this->setIsImported(1)->save();
139
+ }catch(Exception $e){
140
+ $success = false;
141
}
142
+ return $success;
143
}
144
145
// private function _getConnection() {
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Category/Translate.php CHANGED
@@ -14,20 +14,26 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Category_Translate exten
14
}
15
16
public function importTranslation(){
17
-
18
- $category = Mage::getModel('catalog/category')->setStoreId($this->getStoreId())->load($this->getCategoryId());
19
-
20
- $categoryAttributeCode = $this->_getAttributeCode($this->getAttributeId());
21
-
22
- $this->setBackup($category->getData($categoryAttributeCode));
23
-
24
- $category->setData($categoryAttributeCode, $this->getTranslate())
25
- ->getResource()
26
- ->saveAttribute($category, $categoryAttributeCode);
27
- $this->setIsImported(1)->save();
28
-
29
- $category->clearInstance();
30
-
31
}
32
33
protected function _getAttributeCode($attributeId){
14
}
15
16
public function importTranslation(){
17
+ $success = true;
18
+ try{
19
+ $translatedValue = $this->getTranslate();
20
+ //if translated value is null, skip
21
+ if(!is_null($translatedValue)){
22
+ $category = Mage::getModel('catalog/category')
23
+ ->setStoreId($this->getStoreId())
24
+ ->load($this->getCategoryId());
25
+ $categoryAttributeCode = $this->_getAttributeCode($this->getAttributeId());
26
+ $this->setBackup($category->getData($categoryAttributeCode));
27
+ $category->setData($categoryAttributeCode, $translatedValue)
28
+ ->getResource()
29
+ ->saveAttribute($category, $categoryAttributeCode);
30
+ $this->setIsImported(1)->save();
31
+ $category->clearInstance();
32
+ }
33
+ }catch(Exception $e){
34
+ $success = false;
35
+ }
36
+ return $success;
37
}
38
39
protected function _getAttributeCode($attributeId){
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Block/Translate.php CHANGED
@@ -12,37 +12,37 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Cms_Block_Translate exte
12
{
13
$this->_init('strakertranslations_easytranslationplatform/cms_block_translate');
14
}
15
-
16
- public function importTranslation(){
17
-
18
- $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->load($this->getJobCmsId())
19
- ->getNewEntityId();
20
-
21
-
22
- // if ($this->getTranslate()){
23
- //
24
- // $writeConnection = $this->_getConnection();
25
//
26
- // $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/block')
27
- // . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE block_id = '.$newEntityId;
28
//
29
//
30
- // $writeConnection->query($query);
31
//
32
//
33
// }
34
-
35
- if ($this->getTranslate()){
36
- $model = Mage::getModel('cms/block')->load($newEntityId);
37
- if($model->getId()){
38
- $model->setData($this->getColumnName(), $this->getTranslate());
39
- $model->save();
40
- }
41
- }
42
-
43
- $this->setIsImported(1)->save();
44
-
45
- }
46
//
47
// private function _getConnection() {
48
// return Mage::getSingleton('core/resource')->getConnection('core_write');
12
{
13
$this->_init('strakertranslations_easytranslationplatform/cms_block_translate');
14
}
15
//
16
+ // public function importTranslation(){
17
//
18
+ // $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_block')->load($this->getJobCmsId())
19
+ // ->getNewEntityId();
20
//
21
//
22
+ //// if ($this->getTranslate()){
23
+ ////
24
+ //// $writeConnection = $this->_getConnection();
25
+ ////
26
+ //// $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/block')
27
+ //// . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE block_id = '.$newEntityId;
28
+ ////
29
+ ////
30
+ //// $writeConnection->query($query);
31
+ ////
32
+ ////
33
+ //// }
34
//
35
+ // if ($this->getTranslate()){
36
+ // $model = Mage::getModel('cms/block')->load($newEntityId);
37
+ // if($model->getId()){
38
+ // $model->setData($this->getColumnName(), $this->getTranslate());
39
+ // $model->save();
40
+ // }
41
// }
42
+ //
43
+ // $this->setIsImported(1)->save();
44
+ //
45
+ // }
46
//
47
// private function _getConnection() {
48
// return Mage::getSingleton('core/resource')->getConnection('core_write');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Cms/Page/Translate.php CHANGED
@@ -13,40 +13,48 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Cms_Page_Translate exten
13
$this->_init('strakertranslations_easytranslationplatform/cms_page_translate');
14
}
15
16
- public function importTranslation(){
17
-
18
- $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->load($this->getJobCmsId())
19
- ->getNewEntityId();
20
-
21
-
22
- // if ($this->getTranslate()){
23
- //
24
- // $writeConnection = $this->_getConnection();
25
- //
26
- // $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/page')
27
- // . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE page_id = '.$newEntityId;
28
- //
29
- //
30
- // $writeConnection->query($query);
31
- //
32
- //
33
// }
34
- //
35
- // $this->setIsImported(1)->save();
36
- $translation = $this->getTranslate();
37
- if( !empty($translation) ){
38
- $model = Mage::getModel('cms/page')->load($newEntityId);
39
- if($model->getId()){
40
- $model->setData($this->getColumnName(), $translation );
41
- $model->save();
42
- $model->unsetData();
43
- }
44
- }
45
- $this->setIsImported(1)->save();
46
- }
47
//
48
// private function _getConnection() {
49
// return Mage::getSingleton('core/resource')->getConnection('core_write');
50
// }
51
52
}
13
$this->_init('strakertranslations_easytranslationplatform/cms_page_translate');
14
}
15
16
+ // public function importTranslation(){
17
+ // $success = true;
18
+ // $newEntityId =Mage::getModel('strakertranslations_easytranslationplatform/job_cms_page')->load($this->getJobCmsId())
19
+ // ->getNewEntityId();
20
+ //
21
+ //// if ($this->getTranslate()){
22
+ //// $writeConnection = $this->_getConnection();
23
+ //// $query = 'UPDATE `'.Mage::getSingleton('core/resource')->getTableName('cms/page')
24
+ //// . '` SET '.$this->getColumnName() .' = \''.addslashes($this->getTranslate()).' \' WHERE page_id = '.$newEntityId;
25
+ //// $writeConnection->query($query);
26
+ //// }
27
+ //// $this->setIsImported(1)->save();
28
+ //
29
+ // $translation = $this->getTranslate();
30
+ // if( !empty($translation) ){
31
+ // $model = Mage::getModel('cms/page')->load($newEntityId);
32
+ // if($model->getId()){
33
+ // $model->setData($this->getColumnName(), $translation );
34
+ // $model->setData('stores', $this->getStoreId());
35
+ // // try to save it
36
+ // try {
37
+ // // save the data
38
+ // $model->save();
39
+ //
40
+ // // display success message
41
+ // Mage::getSingleton('adminhtml/session')->addSuccess(
42
+ // Mage::helper('cms')->__('The page has been saved.'));
43
+ // $this->setIsImported(1)->save();
44
+ // }catch (Exception $e) {
45
+ // $success = false;
46
+ // Mage::getSingleton('adminhtml/session')->addError($e->getMessage()
47
+ // . ' Page ID: ' . $this->getJobCmsId()
48
+ // . ' Attribute: ' . $this->getColumnName());
49
+ // }
50
+ // }
51
// }
52
+ // return $success;
53
+ // }
54
//
55
// private function _getConnection() {
56
// return Mage::getSingleton('core/resource')->getConnection('core_write');
57
// }
58
59
+
60
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php CHANGED
@@ -62,12 +62,14 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
62
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($productAttributeId)->getAttributeCode();
63
// $model = Mage::getModel('strakertranslations_easytranslationplatform/product_translate');
64
foreach ($productCollection as $product) {
65
- $data[] = [
66
- 'job_id' => $this->getId(),
67
- 'product_id' => $product->getId(),
68
- 'attribute_id' => $productAttributeId,
69
- 'original' => $product->getData($productAttributeCode)
70
- ];
71
// $model->setJobId($this->getId());
72
// $model->setProductId($product->getId());
73
// $model->setAttributeId($productAttributeId);
@@ -75,7 +77,9 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
75
// $model->save();
76
// $model->unsetData();
77
}
78
- $this->conn->insertMultiple($productTranslateTableName, $data);
79
return $this;
80
}
81
@@ -110,12 +114,14 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
110
$model = Mage::getModel('strakertranslations_easytranslationplatform/category_translate');
111
$categoryAttributeCode = Mage::getModel('eav/entity_attribute')->load($categoryAttributeId)->getAttributeCode();
112
foreach ($categoryCollection as $category) {
113
- $model->setJobId($this->getId());
114
- $model->setCategoryId($category->getId());
115
- $model->setAttributeId($categoryAttributeId);
116
- $model->setOriginal($category->getData($categoryAttributeCode));
117
- $model->save();
118
- $model->unsetData();
119
}
120
return $this;
121
}
@@ -151,13 +157,15 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
151
break;
152
}
153
}
154
- $model->setJobId($this->getId());
155
- $model->setData('cms_'.$type.'_id', $cmsData[$type . '_id']);
156
- $model->setcolumnName($Column);
157
- $model->setOriginal($cmsData[$Column]);
158
- $model->setJobCmsId($jobCmsId);
159
- $model->save();
160
- $model->unsetData();
161
}
162
163
return $this;
@@ -756,7 +764,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
756
return $this;
757
}
758
759
- public function submitCmsblock($cmsIds, $columns = array('title', 'content'))
760
{
761
762
$this->setTypeId(6);
@@ -796,6 +804,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
796
if ($this->getJobKey()) {
797
$request = array();
798
$request['job_key'] = $this->getJobKey();
799
$api = $this->_getApi();
800
$response = $api->getTranslation($request);
801
if ($response->job) {
@@ -804,7 +813,11 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
804
$updateFlag = $this->updateJob($job);
805
}
806
}
807
- $this->setLastStatus(1);
808
}
809
else{
810
$this->setLastStatus(0);
@@ -817,6 +830,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
817
}
818
819
public function bulkUpdateTranslation(){
820
$api = $this->_getApi();
821
$response = $api->getTranslation(array());
822
return $response->job ? $response->job : false;
@@ -848,7 +862,8 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
848
foreach ($job->translated_file as $file) {
849
if ($file->download_url && !$this->getDownloadUrl()) {
850
$this->setDownloadUrl($file->download_url)->save();
851
- $this->_importTranslation();
852
}
853
}
854
return $updateFlag;
@@ -867,52 +882,46 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
867
868
protected function _importTranslation()
869
{
870
-
871
- $xml = $this->_getApi()->getTranslatedFile($this->getDownloadUrl());
872
-
873
file_put_contents(Mage::getBaseDir() . $this->_translateFilePath . 'translated_job' . $this->getId() . '.xml', $xml, LOCK_EX);
874
-
875
$data = simplexml_load_string($xml);
876
877
- $_translationValueGroup = array();
878
-
879
- foreach ($data->children() as $_translation) {
880
-
881
- $_entityTranslationId = (string)$_translation->attributes()->content_id;
882
- if ($this->_getType() == 'attribute') {
883
- if ($_translation->attributes()->content_context == "product attribute title") {
884
- $_translationValueGroup[$_entityTranslationId]['title'] = (string)$_translation->value;
885
- }
886
-
887
- if ($_translation->attributes()->content_context == "product attribute option") {
888
- $_translationValueGroup[$_entityTranslationId]['option']['id_' . $_translation->attributes()->option_id] = (string)$_translation->value;
889
}
890
-
891
- } else {
892
- $_translationValueGroup[$_entityTranslationId] = (string)$_translation->value;
893
}
894
895
- }
896
-
897
- foreach ($_translationValueGroup as $content_id => $_translationValue) {
898
-
899
- $value = $_translationValue;
900
901
- if (is_array($_translationValue)) {
902
- $xml = new SimpleXMLElement('<attribute/>');
903
- $this->array_to_xml($_translationValue, $xml);
904
- $value = (string)$xml->asXML();
905
}
906
-
907
-
908
- $_entityTranslation = Mage::getModel('strakertranslations_easytranslationplatform/' . $this->_getType() . '_translate')->load($content_id);
909
- $_entityTranslation->setTranslate($value);
910
- $_entityTranslation->save();
911
- $_entityTranslation->clearInstance();
912
}
913
-
914
- return $this->setDownloadedVersion(1)->save();
915
-
916
}
917
918
protected function _getType()
@@ -939,44 +948,99 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
939
940
public function applyTranslation($entityIds = array())
941
{
942
- $collection = Mage::getModel('strakertranslations_easytranslationplatform/' . $this->_getType() . '_translate')->getCollection()->addFieldToFilter('job_id', $this->getId());
943
944
if ($entityIds) {
945
- $collection->addFieldToFilter($this->_getType() . '_id', array('in' => $entityIds));
946
}
947
948
$updatedIds = array();
949
$writeConnection = $this->getWriteAdapter();
950
951
- if (in_array($this->_getType(), array('cms_block', 'cms_page'))) {
952
- $this->createNewCms($entityIds);
953
- }
954
-
955
- foreach ($collection as $translation) {
956
- $translation->setStoreId($this->getStoreId())->importTranslation();
957
- $entityId = call_user_func(array($translation, 'getData'), strtolower(str_replace(' ', '_', $this->getTypeName() . '_id')));
958
- if (empty($updatedIds[$entityId])) {
959
- $updatedIds[$entityId] = true;
960
- $prefix = Mage::getConfig()->getTablePrefix()->__toString();
961
- if (in_array($this->_getType(), array('cms_block', 'cms_page'))) {
962
- $cmstableName = str_replace('_', '', $this->_getType());
963
- $cmsColumnName = str_replace('cms_', '', $this->_getType());
964
- $entityId = $translation->getData($this->_getType() . '_id');
965
- $writeConnection->update($prefix . 'straker_job_' . $cmstableName, array('version' => 1), $cmsColumnName . "_id = {$entityId} and job_id ={$this->getId()}");
966
- } else {
967
- $writeConnection->update($prefix . 'straker_job_' . $this->_getType(), array('version' => 1), $this->_getType() . "_id = {$entityId} and job_id ={$this->getId()}");
968
}
969
}
970
}
971
- return true;
972
}
973
974
protected function createNewCms($entityIds)
975
{
976
- $cmsType = str_replace('cms_', '', $this->_getType());
977
- $cmsModelName = str_replace('_', '/', $this->_getType());
978
-
979
- $collection = Mage::getModel('strakertranslations_easytranslationplatform/job_' . $this->_getType())->getCollection();
980
$collection->addFieldToFilter('job_id', $this->getId());
981
982
if ($entityIds) {
@@ -992,10 +1056,18 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
992
}
993
//add target store id
994
// $cmsModel->setStores(array())->save();
995
- $cmsModel->setStores([$this->getStoreId()])->save();
996
- $jobCms->setNewEntityId($cmsModel->getId())->save();
997
}
998
}
999
}
1000
1001
public function isPublished()
@@ -1047,6 +1119,9 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
1047
1048
}
1049
1050
protected function getWriteAdapter()
1051
{
1052
return Mage::getSingleton('core/resource')->getConnection('core_write');
@@ -1068,7 +1143,7 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
1068
$collection->distinct(true)->addFieldToSelect($filter);
1069
$languages = [];
1070
foreach ($collection->getData() as $lang) {
1071
- array_push($languages, $lang[$filter]);
1072
}
1073
/** @var $helper StrakerTranslations_EasyTranslationPlatform_Model_Api */
1074
$helper = Mage::getModel('strakertranslations_easytranslationplatform/api');
62
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($productAttributeId)->getAttributeCode();
63
// $model = Mage::getModel('strakertranslations_easytranslationplatform/product_translate');
64
foreach ($productCollection as $product) {
65
+ if($product->getData($productAttributeCode)){
66
+ $data[] = [
67
+ 'job_id' => $this->getId(),
68
+ 'product_id' => $product->getId(),
69
+ 'attribute_id' => $productAttributeId,
70
+ 'original' => $product->getData($productAttributeCode)
71
+ ];
72
+ }
73
// $model->setJobId($this->getId());
74
// $model->setProductId($product->getId());
75
// $model->setAttributeId($productAttributeId);
77
// $model->save();
78
// $model->unsetData();
79
}
80
+ if($data){
81
+ $this->conn->insertMultiple($productTranslateTableName, $data);
82
+ }
83
return $this;
84
}
85
114
$model = Mage::getModel('strakertranslations_easytranslationplatform/category_translate');
115
$categoryAttributeCode = Mage::getModel('eav/entity_attribute')->load($categoryAttributeId)->getAttributeCode();
116
foreach ($categoryCollection as $category) {
117
+ if($category->getData($categoryAttributeCode)){
118
+ $model->setJobId($this->getId());
119
+ $model->setCategoryId($category->getId());
120
+ $model->setAttributeId($categoryAttributeId);
121
+ $model->setOriginal($category->getData($categoryAttributeCode));
122
+ $model->save();
123
+ $model->unsetData();
124
+ }
125
}
126
return $this;
127
}
157
break;
158
}
159
}
160
+ if($cmsData[$Column]){
161
+ $model->setJobId($this->getId());
162
+ $model->setData('cms_'.$type.'_id', $cmsData[$type . '_id']);
163
+ $model->setcolumnName($Column);
164
+ $model->setOriginal($cmsData[$Column]);
165
+ $model->setJobCmsId($jobCmsId);
166
+ $model->save();
167
+ $model->unsetData();
168
+ }
169
}
170
171
return $this;
764
return $this;
765
}
766
767
+ public function submitCmsBlock($cmsIds, $columns = array('title', 'content'))
768
{
769
770
$this->setTypeId(6);
804
if ($this->getJobKey()) {
805
$request = array();
806
$request['job_key'] = $this->getJobKey();
807
+ /** @var StrakerTranslations_EasyTranslationPlatform_Model_Api $api */
808
$api = $this->_getApi();
809
$response = $api->getTranslation($request);
810
if ($response->job) {
813
$updateFlag = $this->updateJob($job);
814
}
815
}
816
+ if($updateFlag){
817
+ $this->setLastStatus(1);
818
+ }else{
819
+ $this->setLastStatus(0);
820
+ }
821
}
822
else{
823
$this->setLastStatus(0);
830
}
831
832
public function bulkUpdateTranslation(){
833
+ /** @var StrakerTranslations_EasyTranslationPlatform_Model_Api $api */
834
$api = $this->_getApi();
835
$response = $api->getTranslation(array());
836
return $response->job ? $response->job : false;
862
foreach ($job->translated_file as $file) {
863
if ($file->download_url && !$this->getDownloadUrl()) {
864
$this->setDownloadUrl($file->download_url)->save();
865
+ $result = $this->_importTranslation();
866
+ $updateFlag = $result === false ? false : true;
867
}
868
}
869
return $updateFlag;
882
883
protected function _importTranslation()
884
{
885
+ /** @var StrakerTranslations_EasyTranslationPlatform_Model_Api $api */
886
+ $api = $this->_getApi();
887
+ $xml = $api->getTranslatedFile($this->getDownloadUrl());
888
file_put_contents(Mage::getBaseDir() . $this->_translateFilePath . 'translated_job' . $this->getId() . '.xml', $xml, LOCK_EX);
889
$data = simplexml_load_string($xml);
890
891
+ if($data === false){
892
+ return false;
893
+ }else{
894
+ $_translationValueGroup = array();
895
+
896
+ foreach ($data->children() as $_translation) {
897
+ $_entityTranslationId = (string)$_translation->attributes()->content_id;
898
+ if ($this->_getType() == 'attribute') {
899
+ if ($_translation->attributes()->content_context == "product attribute title") {
900
+ $_translationValueGroup[$_entityTranslationId]['title'] = (string)$_translation->value;
901
+ }
902
+ if ($_translation->attributes()->content_context == "product attribute option") {
903
+ $_translationValueGroup[$_entityTranslationId]['option']['id_' . $_translation->attributes()->option_id] = (string)$_translation->value;
904
+ }
905
+ } else {
906
+ $_translationValueGroup[$_entityTranslationId] = (string)$_translation->value;
907
}
908
}
909
910
+ foreach ($_translationValueGroup as $content_id => $_translationValue) {
911
+ $value = $_translationValue;
912
+ if (is_array($_translationValue)) {
913
+ $xml = new SimpleXMLElement('<attribute/>');
914
+ $this->array_to_xml($_translationValue, $xml);
915
+ $value = (string)$xml->asXML();
916
+ }
917
918
+ $_entityTranslation = Mage::getModel('strakertranslations_easytranslationplatform/' . $this->_getType() . '_translate')->load($content_id);
919
+ $_entityTranslation->setTranslate($value);
920
+ $_entityTranslation->save();
921
+ $_entityTranslation->clearInstance();
922
}
923
+ return $this->setDownloadedVersion(1)->save();
924
}
925
}
926
927
protected function _getType()
948
949
public function applyTranslation($entityIds = array())
950
{
951
+ $success = true;
952
+ $jobType = $this->_getType(); //product, category, cms_page ...
953
+ // collection for straker_<TYPE>_translate tables
954
+ $collection = Mage::getModel('strakertranslations_easytranslationplatform/' . $jobType . '_translate')->getCollection()->addFieldToFilter('job_id', $this->getId());
955
956
if ($entityIds) {
957
+ $collection->addFieldToFilter($jobType . '_id', array('in' => $entityIds));
958
}
959
960
$updatedIds = array();
961
$writeConnection = $this->getWriteAdapter();
962
+ $prefix = Mage::getConfig()->getTablePrefix()->__toString();
963
+
964
+ try{
965
+ if (in_array($jobType, array('cms_block', 'cms_page'))) {
966
+ $result = $this->createNewCms($entityIds);
967
+ $cmsTableName = str_replace('_', '', $jobType); //cmsxxx
968
+ $cmsColumnName = str_replace('cms_', '', $jobType); //xxx
969
+ $cmsModelName = 'cms/'.$cmsColumnName;
970
+
971
+ if($result['success']){
972
+ //translated content array
973
+ $newCmsData = [];
974
+ foreach($collection as $translation){
975
+ if(!$translation->getIsImported()){
976
+ if(empty($newCmsData[$translation->getData($jobType . '_id')])){
977
+ $newCmsData[$translation->getData($jobType . '_id')] = [
978
+ $translation->getColumnName() => $translation->getTranslate(),
979
+ ];
980
+ }else{
981
+ $newCmsData[$translation->getData($jobType . '_id')][$translation->getColumnName()] = $translation->getTranslate();
982
+ }
983
+ }
984
+ }
985
986
+ //cms old id and new id pairs
987
+ $newCmsIds = $result['new_entity_ids'];
988
+ foreach($newCmsIds as $oldId => $newId){
989
+ $model = Mage::getModel($cmsModelName)->load($newId);
990
+ foreach($newCmsData[$oldId] as $k => $v){
991
+ $model->setData($k, $v);
992
+ }
993
+ $model->setStores($this->getStoreId());
994
+ $model->save();
995
+ $model->unsetData();
996
+ }
997
+ foreach($collection as $translation){
998
+ $entityId = $translation->getData($jobType . '_id');
999
+ if(!$translation->getIsImported()){
1000
+ $translation->setIsImported(1)->save();
1001
+ }
1002
+ if( empty($updatedIds[$entityId]) ){
1003
+ $updatedIds[$entityId] = true;
1004
+ $writeConnection->update($prefix . 'straker_job_' . $cmsTableName, array('version' => 1), $cmsColumnName . "_id = {$entityId} and job_id ={$this->getId()}");
1005
+ }
1006
+ }
1007
+ }else{
1008
+ $success = false;
1009
+ }
1010
+ }else{
1011
+ foreach ($collection as $translation) {
1012
+ if(!$translation->getVersion()){
1013
+ $return = $translation->setStoreId($this->getStoreId())->importTranslation();
1014
+ if($return){
1015
+ $entityId = call_user_func(array($translation, 'getData'), strtolower(str_replace(' ', '_', $this->getTypeName() . '_id')));
1016
+ if (empty($updatedIds[$entityId])) {
1017
+ $updatedIds[$entityId] = true;
1018
+ $writeConnection->update($prefix . 'straker_job_' . $jobType, array('version' => 1), $jobType . "_id = {$entityId} and job_id ={$this->getId()}");
1019
+ }
1020
+ }else{
1021
+ $success = false;
1022
+ }
1023
+ }
1024
}
1025
}
1026
+ }catch(Exception $e){
1027
+ $success = false;
1028
}
1029
+
1030
+ return $success;
1031
}
1032
1033
protected function createNewCms($entityIds)
1034
{
1035
+ $return = [
1036
+ 'success' => true,
1037
+ 'new_entity_ids' => []
1038
+ ];
1039
+ $jobType = $this->_getType();
1040
+ $cmsType = str_replace('cms_', '', $jobType);
1041
+ $cmsModelName = str_replace('_', '/', $jobType);
1042
+
1043
+ $collection = Mage::getModel('strakertranslations_easytranslationplatform/job_' . $jobType)->getCollection();
1044
$collection->addFieldToFilter('job_id', $this->getId());
1045
1046
if ($entityIds) {
1056
}
1057
//add target store id
1058
// $cmsModel->setStores(array())->save();
1059
+ $cmsModel->setStores([$this->getStoreId()]);
1060
+ try{
1061
+ $cmsModel->save();
1062
+ $jobCms->setNewEntityId($cmsModel->getId())->save();
1063
+ $return['new_entity_ids'][$jobCms->getData($cmsType . '_id')] = $cmsModel->getId();
1064
+ }catch(Exception $e){
1065
+ $return['success'] = false;
1066
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage() . 'URL Key: ' . $jobCms->getIdentifier());
1067
+ }
1068
}
1069
}
1070
+ return $return;
1071
}
1072
1073
public function isPublished()
1119
1120
}
1121
1122
+ /**
1123
+ * @return Varien_Db_Adapter_Interface
1124
+ */
1125
protected function getWriteAdapter()
1126
{
1127
return Mage::getSingleton('core/resource')->getConnection('core_write');
1143
$collection->distinct(true)->addFieldToSelect($filter);
1144
$languages = [];
1145
foreach ($collection->getData() as $lang) {
1146
+ $languages[] = $lang[$filter];
1147
}
1148
/** @var $helper StrakerTranslations_EasyTranslationPlatform_Model_Api */
1149
$helper = Mage::getModel('strakertranslations_easytranslationplatform/api');
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Product/Translate.php CHANGED
@@ -14,30 +14,29 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Product_Translate extend
14
}
15
16
public function importTranslation(){
17
-
18
- //if translated value is null, skip
19
- $translatedValue = $this->getTranslate();
20
- if (is_null($translatedValue)){
21
- return;
22
}
23
-
24
- $product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId())->load($this->getProductId());
25
-
26
- $productAttributeCode = $this->_getAttributeCode($this->getAttributeId());
27
-
28
- $this->setBackup($product->getData($productAttributeCode));
29
-
30
- $product->setData($productAttributeCode, $translatedValue)
31
- ->getResource()
32
- ->saveAttribute($product, $productAttributeCode);
33
- $this->setIsImported(1)->save();
34
-
35
- $product->clearInstance();
36
-
37
}
38
39
protected function _getAttributeCode($attributeId){
40
-
41
if (!Mage::registry('attributeCodeCache_'.$attributeId)){
42
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($attributeId)->getAttributeCode();
43
Mage::register('attributeCodeCache_'.$attributeId,$productAttributeCode);
@@ -45,7 +44,5 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Product_Translate extend
45
$productAttributeCode = Mage::registry('attributeCodeCache_'.$attributeId);
46
}
47
return $productAttributeCode;
48
-
49
}
50
-
51
}
14
}
15
16
public function importTranslation(){
17
+ $success = true;
18
+ try{
19
+ //if translated value is null, skip
20
+ $translatedValue = $this->getTranslate();
21
+ if (!is_null($translatedValue)){
22
+ $product = Mage::getModel('catalog/product')
23
+ ->setStoreId($this->getStoreId())
24
+ ->load($this->getProductId());
25
+ $productAttributeCode = $this->_getAttributeCode($this->getAttributeId());
26
+ $this->setBackup($product->getData($productAttributeCode));
27
+ $product->setData($productAttributeCode, $translatedValue)
28
+ ->getResource()
29
+ ->saveAttribute($product, $productAttributeCode);
30
+ $this->setIsImported(1)->save();
31
+ $product->clearInstance();
32
+ }
33
+ }catch(Exception $e){
34
+ $success = false;
35
}
36
+ return $success;
37
}
38
39
protected function _getAttributeCode($attributeId){
40
if (!Mage::registry('attributeCodeCache_'.$attributeId)){
41
$productAttributeCode = Mage::getModel('eav/entity_attribute')->load($attributeId)->getAttributeCode();
42
Mage::register('attributeCodeCache_'.$attributeId,$productAttributeCode);
44
$productAttributeCode = Mage::registry('attributeCodeCache_'.$attributeId);
45
}
46
return $productAttributeCode;
47
}
48
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Attribute/Collection.php CHANGED
@@ -13,4 +13,15 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Attribute_C
13
$this->_init('strakertranslations_easytranslationplatform/job_attribute');
14
}
15
16
}
13
$this->_init('strakertranslations_easytranslationplatform/job_attribute');
14
}
15
16
+ public function getAllIds()
17
+ {
18
+ $idsSelect = clone $this->getSelect();
19
+ $idsSelect->reset(Zend_Db_Select::ORDER);
20
+ $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
+ $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
+ $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
+
24
+ $idsSelect->columns('attribute_id', 'main_table');
25
+ return $this->getConnection()->fetchCol($idsSelect);
26
+ }
27
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Block/Collection.php CHANGED
@@ -13,4 +13,16 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Block_C
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_block');
14
}
15
16
}
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_block');
14
}
15
16
+ public function getAllIds()
17
+ {
18
+ $idsSelect = clone $this->getSelect();
19
+ $idsSelect->reset(Zend_Db_Select::ORDER);
20
+ $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
+ $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
+ $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
+
24
+ $idsSelect->columns('block_id', 'main_table');
25
+ return $this->getConnection()->fetchCol($idsSelect);
26
+ }
27
+
28
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Cms/Page/Collection.php CHANGED
@@ -13,4 +13,16 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Cms_Page_Co
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_page');
14
}
15
16
}
13
$this->_init('strakertranslations_easytranslationplatform/job_cms_page');
14
}
15
16
+ public function getAllIds()
17
+ {
18
+ $idsSelect = clone $this->getSelect();
19
+ $idsSelect->reset(Zend_Db_Select::ORDER);
20
+ $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
+ $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
+ $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
+
24
+ $idsSelect->columns('page_id', 'main_table');
25
+ return $this->getConnection()->fetchCol($idsSelect);
26
+ }
27
+
28
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/AttributeController.php CHANGED
@@ -61,7 +61,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
61
}
62
}
63
64
- public function addtoconfirmAction(){
65
$data = $this->getRequest()->getParams();
66
if(empty($data['attribute']) && empty($data['option'])){
67
$data['attribute'] = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
@@ -87,7 +87,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
87
}
88
}
89
90
- public function submitjobAction(){
91
$data = $this->getRequest()->getParams();
92
if( $data['store'] && isset($data['attribute']) && isset($data['option']) ){
93
$attribute = !empty($data['attribute'])?explode(',', $data['attribute']):array();
@@ -147,7 +147,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
147
}
148
}
149
150
- public function copyAllAction(){
151
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
152
153
if (!$job->getId()){
@@ -168,7 +168,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
168
169
}
170
171
- public function applyTranslationAction(){
172
$jobId = $this->getRequest()->getParam('job_id');
173
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
174
@@ -204,8 +204,8 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
204
}
205
206
public function removeFromCartAction(){
207
- $attributeId = 0;
208
- if(!empty($this->getRequest()->getParam('attribute_id'))){
209
$attributeId = $this->getRequest()->getParam('attribute_id');
210
}
211
$attributeIds = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
@@ -227,7 +227,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_AttributeCon
227
// var_dump($optionIds);
228
// exit;
229
Mage::getSingleton('adminhtml/session')->setData('straker_new_option', implode(',', $optionIds));
230
- $this->_redirect('*/*/addtoconfirm');
231
}
232
233
public function gridAction()
61
}
62
}
63
64
+ public function addToConfirmAction(){
65
$data = $this->getRequest()->getParams();
66
if(empty($data['attribute']) && empty($data['option'])){
67
$data['attribute'] = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
87
}
88
}
89
90
+ public function submitJobAction(){
91
$data = $this->getRequest()->getParams();
92
if( $data['store'] && isset($data['attribute']) && isset($data['option']) ){
93
$attribute = !empty($data['attribute'])?explode(',', $data['attribute']):array();
147
}
148
}
149
150
+ public function publishAllAction(){
151
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
152
153
if (!$job->getId()){
168
169
}
170
171
+ public function publishAction(){
172
$jobId = $this->getRequest()->getParam('job_id');
173
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
174
204
}
205
206
public function removeFromCartAction(){
207
+ $attributeId = $this->getRequest()->getParam('attribute_id');
208
+ if(!empty($attributeId)){
209
$attributeId = $this->getRequest()->getParam('attribute_id');
210
}
211
$attributeIds = Mage::getSingleton('adminhtml/session')->getData('straker_new_attribute');
227
// var_dump($optionIds);
228
// exit;
229
Mage::getSingleton('adminhtml/session')->setData('straker_new_option', implode(',', $optionIds));
230
+ $this->_redirect('*/*/addToConfirm');
231
}
232
233
public function gridAction()
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/CategoryController.php CHANGED
@@ -78,7 +78,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_CategoryCont
78
}
79
}
80
81
- public function submitjobAction()
82
{
83
$data = $this->getRequest()->getParams();
84
if($data['attr'] && $data['store'] && $data['category']){
@@ -159,7 +159,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_CategoryCont
159
// }
160
}
161
162
- public function copyAllAction(){
163
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
164
165
if (!$job->getId()){
@@ -180,7 +180,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_CategoryCont
180
181
}
182
183
- public function applyTranslationAction(){
184
$jobId = $this->getRequest()->getParam('job_id');
185
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
186
@@ -262,8 +262,8 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_CategoryCont
262
}
263
264
public function removeFromCartAction(){
265
- $entityId = 0;
266
- if(!empty($this->getRequest()->getParam('entity_id'))){
267
$entityId = $this->getRequest()->getParam('entity_id');
268
}
269
$categoryIds = Mage::getSingleton('adminhtml/session')->getData('straker_new_category');
78
}
79
}
80
81
+ public function submitJobAction()
82
{
83
$data = $this->getRequest()->getParams();
84
if($data['attr'] && $data['store'] && $data['category']){
159
// }
160
}
161
162
+ public function publishAllAction(){
163
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
164
165
if (!$job->getId()){
180
181
}
182
183
+ public function publishAction(){
184
$jobId = $this->getRequest()->getParam('job_id');
185
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
186
262
}
263
264
public function removeFromCartAction(){
265
+ $entityId = $this->getRequest()->getParam('entity_id');
266
+ if(!empty($entityId)){
267
$entityId = $this->getRequest()->getParam('entity_id');
268
}
269
$categoryIds = Mage::getSingleton('adminhtml/session')->getData('straker_new_category');
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/Cms/BlockController.php CHANGED
@@ -74,7 +74,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_Cms_BlockCon
74
}
75
}
76
77
- public function addtoconfirmAction(){
78
$data = $this->_getParamArray();
79
if(!empty($data['attr']) && !empty($data['store']) && !empty($data['cms_block'])){
80
Mage::getSingleton('adminhtml/session')
@@ -94,9 +94,10 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_Cms_BlockCon
94
}
95
}
96
97
- public function submitjobAction(){
98
$data = $this->getRequest()->getParams();
99
if($data['attr'] && $data['store'] && $data['cms_block']){
100
$jobModel = Mage::getModel('strakertranslations_easytranslationplatform/job');
101
try {
102
$jobModel->checkAndCreateFolder();
@@ -133,7 +134,8 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_Cms_BlockCon
133
}
134
}
135
136
- public function copyAllAction(){
137
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
138
139
if (!$job->getId()){
@@ -154,8 +156,9 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_Cms_BlockCon
154
155
}
156
157
- public function applyTranslationAction(){
158
$jobId = $this->getRequest()->getParam('job_id');
159
$job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId);
160
161
if (!$job->getId()){
@@ -239,8 +242,8 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_Cms_BlockCon
239
}
240
241
public function removeFromCartAction(){
242
- $entityId = 0;
243
- if(!empty($this->getRequest()->getParam('block_id'))){
244
$entityId = $this->getRequest()->getParam('block_id');
245
}
246
$blockIds = Mage::getSingleton('adminhtml/session')->getData('straker_new_cms_block');
@@ -251,7 +254,7 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_Cms_BlockCon
251
unset($blockIds[$key]);
252
}
253
Mage::getSingleton('adminhtml/session')->setData('straker_new_cms_block', $blockIds);
254
- $this->_redirect('*/*/addtoconfirm');
255
}
256
257
private function _getParamArray(){
74
}
75
}
76
77
+ public function addToConfirmAction(){
78
$data = $this->_getParamArray();
79
if(!empty($data['attr']) && !empty($data['store']) && !empty($data['cms_block'])){
80
Mage::getSingleton('adminhtml/session')
94
}
95