Version Notes
This extension is a stable version.
Download this release
Release Info
Developer | Rik Sen |
Extension | Xt_Promotional |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional.php +12 -0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit.php +47 -0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Form.php +19 -0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Tab/Grid.php +205 -0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Tab/Store.php +10 -0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Tabs.php +29 -0
- app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Grid.php +77 -0
- app/code/local/XT/Promotional/Block/Promotional.php +14 -0
- app/code/local/XT/Promotional/Helper/Data.php +6 -0
- app/code/local/XT/Promotional/Model/Grid.php +9 -0
- app/code/local/XT/Promotional/Model/Mysql4/Grid.php +19 -0
- app/code/local/XT/Promotional/Model/Mysql4/Grid/Collection.php +10 -0
- app/code/local/XT/Promotional/Model/Mysql4/Promotional.php +10 -0
- app/code/local/XT/Promotional/Model/Mysql4/Promotional/Collection.php +10 -0
- app/code/local/XT/Promotional/Model/Promotional.php +19 -0
- app/code/local/XT/Promotional/controllers/Adminhtml/PromotionalController.php +163 -0
- app/code/local/XT/Promotional/etc/config.xml +121 -0
- app/code/local/XT/Promotional/sql/promotional_setup/mysql4-install-0.1.0.php +33 -0
- app/design/adminhtml/default/default/layout/promotional.xml +31 -0
- app/design/adminhtml/default/default/template/promotional/stores.phtml +79 -0
- app/design/frontend/base/default/layout/promotional.xml +8 -0
- app/design/frontend/base/default/template/promotional/promotional.phtml +61 -0
- app/etc/modules/XT_Promotional.xml +9 -0
- package.xml +18 -0
app/code/local/XT/Promotional/Block/Adminhtml/Promotional.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class XT_Promotional_Block_Adminhtml_Promotional extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_promotional';
|
7 |
+
$this->_blockGroup = 'promotional';
|
8 |
+
$this->_headerText = Mage::helper('promotional')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('promotional')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Block_Adminhtml_Promotional_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'promotional';
|
11 |
+
$this->_controller = 'adminhtml_promotional';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('promotional')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('promotional')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('promotional_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'promotional_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'promotional_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
$this->_removeButton('save');
|
36 |
+
$this->_removeButton('delete');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getHeaderText()
|
40 |
+
{
|
41 |
+
if( Mage::registry('promotional_data') && Mage::registry('promotional_data')->getId() ) {
|
42 |
+
return Mage::helper('promotional')->__('Manage Promotional Products');
|
43 |
+
} else {
|
44 |
+
return Mage::helper('promotional')->__('Manage Promotional Products');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Block_Adminhtml_Promotional_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Tab/Grid.php
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class XT_Promotional_Block_Adminhtml_Promotional_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('upsellGrid');
|
8 |
+
$this->setUseAjax(true); // Using ajax grid is important
|
9 |
+
$this->setDefaultSort('entity_id');
|
10 |
+
$this->setDefaultFilter(array('in_products'=>1)); // By default we have added a filter for the rows, that in_products value to be 1
|
11 |
+
$this->setDefaultDir('ASC');
|
12 |
+
$this->setDefaultLimit(200);
|
13 |
+
$this->setSaveParametersInSession(false); //Dont save paramters in session or else it creates problems
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _prepareCollection()
|
17 |
+
{
|
18 |
+
$storeId = Mage::getSingleton('adminhtml/session')->getData('promotional_store_id');
|
19 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
20 |
+
->addAttributeToSelect('name')
|
21 |
+
->addAttributeToSelect('sku')
|
22 |
+
->addAttributeToSelect('price')
|
23 |
+
->addAttributeToSelect('status')
|
24 |
+
->addAttributeToSelect('visibility')
|
25 |
+
//->addStoreFilter($storeId)
|
26 |
+
->joinField('position',
|
27 |
+
'promotional/grid',
|
28 |
+
'position',
|
29 |
+
'product_id=entity_id',
|
30 |
+
'{{table}}.store_id ='.$storeId,
|
31 |
+
'left')
|
32 |
+
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
33 |
+
->addFieldToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
|
34 |
+
->addAttributeToFilter('visibility', array('neq' => 1));
|
35 |
+
$this->setCollection($collection);
|
36 |
+
|
37 |
+
// return parent::_prepareCollection();
|
38 |
+
|
39 |
+
parent::_prepareCollection();
|
40 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
protected function _addColumnFilterToCollection($column)
|
45 |
+
{
|
46 |
+
// Set custom filter for in product flag
|
47 |
+
if ($column->getId() == 'in_products') {
|
48 |
+
$ids = $this->_getSelectedCustomers();
|
49 |
+
if (empty($ids)) {
|
50 |
+
$ids = 0;
|
51 |
+
}
|
52 |
+
if ($column->getFilter()->getValue()) {
|
53 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$ids));
|
54 |
+
} else {
|
55 |
+
if($productIds) {
|
56 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$ids));
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
else if ($this->getCollection()) {
|
61 |
+
if ($column->getId() == 'websites') {
|
62 |
+
$this->getCollection()->joinField('websites',
|
63 |
+
'catalog/product_website',
|
64 |
+
'website_id',
|
65 |
+
'product_id=entity_id',
|
66 |
+
null,
|
67 |
+
'left');
|
68 |
+
}
|
69 |
+
return parent::_addColumnFilterToCollection($column);
|
70 |
+
}
|
71 |
+
else {
|
72 |
+
parent::_addColumnFilterToCollection($column);
|
73 |
+
}
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
protected function _prepareColumns()
|
78 |
+
{
|
79 |
+
|
80 |
+
$this->addColumn('in_products', array(
|
81 |
+
'header_css_class' => 'a-center',
|
82 |
+
'type' => 'checkbox',
|
83 |
+
'name' => 'customer',
|
84 |
+
'values' => $this->_getSelectedCustomers(),
|
85 |
+
'align' => 'center',
|
86 |
+
'index' => 'entity_id'
|
87 |
+
));
|
88 |
+
|
89 |
+
$this->addColumn('id', array(
|
90 |
+
'header' => Mage::helper('promotional')->__('Product Id'),
|
91 |
+
'sortable' => true,
|
92 |
+
'width' => '60px',
|
93 |
+
'index' => 'entity_id'
|
94 |
+
));
|
95 |
+
|
96 |
+
$this->addColumn('name', array(
|
97 |
+
'header' => Mage::helper('promotional')->__('Name'),
|
98 |
+
'index' => 'name'
|
99 |
+
));
|
100 |
+
$this->addColumn('sku', array(
|
101 |
+
'header' => Mage::helper('promotional')->__('SKU'),
|
102 |
+
'width' => '120px',
|
103 |
+
'index' => 'sku'
|
104 |
+
));
|
105 |
+
|
106 |
+
$this->addColumn('type', array(
|
107 |
+
'header' => Mage::helper('promotional')->__('Type'),
|
108 |
+
'width' => 100,
|
109 |
+
'index' => 'type_id',
|
110 |
+
'type' => 'options',
|
111 |
+
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
|
112 |
+
));
|
113 |
+
|
114 |
+
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
115 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
116 |
+
->load()
|
117 |
+
->toOptionHash();
|
118 |
+
|
119 |
+
$this->addColumn('set_name', array(
|
120 |
+
'header' => Mage::helper('promotional')->__('Attrib. Set Name'),
|
121 |
+
'width' => 130,
|
122 |
+
'index' => 'attribute_set_id',
|
123 |
+
'type' => 'options',
|
124 |
+
'options' => $sets,
|
125 |
+
));
|
126 |
+
|
127 |
+
$this->addColumn('status', array(
|
128 |
+
'header' => Mage::helper('promotional')->__('Status'),
|
129 |
+
'width' => 90,
|
130 |
+
'index' => 'status',
|
131 |
+
'type' => 'options',
|
132 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
133 |
+
));
|
134 |
+
|
135 |
+
$this->addColumn('visibility', array(
|
136 |
+
'header' => Mage::helper('promotional')->__('Visibility'),
|
137 |
+
'width' => 90,
|
138 |
+
'index' => 'visibility',
|
139 |
+
'type' => 'options',
|
140 |
+
'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
|
141 |
+
));
|
142 |
+
|
143 |
+
$this->addColumn('price', array(
|
144 |
+
'header' => Mage::helper('promotional')->__('Price'),
|
145 |
+
'type' => 'currency',
|
146 |
+
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
|
147 |
+
'index' => 'price'
|
148 |
+
));
|
149 |
+
|
150 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
151 |
+
$this->addColumn('websites',
|
152 |
+
array(
|
153 |
+
'header'=> Mage::helper('promotional')->__('Websites'),
|
154 |
+
'width' => '100px',
|
155 |
+
'sortable' => false,
|
156 |
+
'index' => 'websites',
|
157 |
+
'type' => 'options',
|
158 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
|
159 |
+
));
|
160 |
+
}
|
161 |
+
|
162 |
+
$this->addColumn('position', array(
|
163 |
+
'header' => Mage::helper('promotional')->__('Position'),
|
164 |
+
'name' => 'position',
|
165 |
+
'width' => 60,
|
166 |
+
'type' => 'number',
|
167 |
+
'validate_class' => 'validate-number',
|
168 |
+
'index' => 'position',
|
169 |
+
'editable' => true,
|
170 |
+
'edit_only' => true
|
171 |
+
));
|
172 |
+
|
173 |
+
return parent::_prepareColumns();
|
174 |
+
}
|
175 |
+
|
176 |
+
protected function _getSelectedCustomers() // Used in grid to return selected customers values.
|
177 |
+
{
|
178 |
+
$customers = array_keys($this->getSelectedCustomers());
|
179 |
+
return $customers;
|
180 |
+
}
|
181 |
+
|
182 |
+
public function getGridUrl()
|
183 |
+
{
|
184 |
+
return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsellgrid', array('_current'=>true));
|
185 |
+
}
|
186 |
+
public function getSelectedCustomers()
|
187 |
+
{
|
188 |
+
// Customer Data
|
189 |
+
$storeId = Mage::getSingleton('adminhtml/session')->getData('promotional_store_id');
|
190 |
+
$tm_id = 1;
|
191 |
+
if(!isset($tm_id)) {
|
192 |
+
$tm_id = 0;
|
193 |
+
}
|
194 |
+
$collection = Mage::getModel('promotional/grid')->getCollection();
|
195 |
+
$collection->addFieldToFilter('store_id',$storeId);
|
196 |
+
$collection->addFieldToFilter('promotional_id',$tm_id);
|
197 |
+
$custIds = array();
|
198 |
+
foreach($collection as $obj){
|
199 |
+
$custIds[$obj->getProductId()] = array('position'=>$obj->getPosition());
|
200 |
+
}
|
201 |
+
return $custIds;
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
}
|
app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Tab/Store.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class XT_Promotional_Block_Adminhtml_Promotional_Edit_Tab_Store extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setTemplate('promotional/stores.phtml');
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Edit/Tabs.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Block_Adminhtml_Promotional_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('promotional_tabs');
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('promotional')->__('Item Information'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml()
|
14 |
+
{
|
15 |
+
$this->addTab('store_section', array(
|
16 |
+
'label' => Mage::helper('promotional')->__('Select Stores'),
|
17 |
+
'title' => Mage::helper('promotional')->__('Select Stores'),
|
18 |
+
'content' => $this->getLayout()->createBlock('promotional/adminhtml_promotional_edit_tab_store')->toHtml(),
|
19 |
+
));
|
20 |
+
$this->addTab('grid_section', array(
|
21 |
+
'label' => Mage::helper('promotional')->__('Promotional Products'),
|
22 |
+
'title' => Mage::helper('promotional')->__('Promotional Products'),
|
23 |
+
'url' => $this->getUrl('*/*/grid', array('_current' => true)),
|
24 |
+
'class' => 'ajax',
|
25 |
+
));
|
26 |
+
|
27 |
+
return parent::_beforeToHtml();
|
28 |
+
}
|
29 |
+
}
|
app/code/local/XT/Promotional/Block/Adminhtml/Promotional/Grid.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Block_Adminhtml_Promotional_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('promotionalGrid');
|
9 |
+
$this->setDefaultSort('promotional_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('promotional/promotional')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('promotional_id', array(
|
24 |
+
'header' => Mage::helper('promotional')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'promotional_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('promotional')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
$this->addColumn('action',
|
37 |
+
array(
|
38 |
+
'header' => Mage::helper('promotional')->__('Action'),
|
39 |
+
'width' => '100',
|
40 |
+
'type' => 'action',
|
41 |
+
'getter' => 'getId',
|
42 |
+
'actions' => array(
|
43 |
+
array(
|
44 |
+
'caption' => Mage::helper('promotional')->__('Edit'),
|
45 |
+
'url' => array('base'=> '*/*/edit'),
|
46 |
+
'field' => 'id'
|
47 |
+
)
|
48 |
+
),
|
49 |
+
'filter' => false,
|
50 |
+
'sortable' => false,
|
51 |
+
'index' => 'stores',
|
52 |
+
'is_system' => true,
|
53 |
+
));
|
54 |
+
|
55 |
+
return parent::_prepareColumns();
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _prepareMassaction()
|
59 |
+
{
|
60 |
+
$this->setMassactionIdField('promotional_id');
|
61 |
+
$this->getMassactionBlock()->setFormFieldName('promotional');
|
62 |
+
|
63 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
64 |
+
'label' => Mage::helper('promotional')->__('Delete'),
|
65 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
66 |
+
'confirm' => Mage::helper('promotional')->__('Are you sure?')
|
67 |
+
));
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getRowUrl($row)
|
73 |
+
{
|
74 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
app/code/local/XT/Promotional/Block/Promotional.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class XT_Promotional_Block_Promotional extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function _prepareLayout()
|
10 |
+
{
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
}
|
app/code/local/XT/Promotional/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/XT/Promotional/Model/Grid.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class XT_Promotional_Model_Grid extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('promotional/grid');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/XT/Promotional/Model/Mysql4/Grid.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Model_Mysql4_Grid extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the promotional_id refers to the key field in your database table.
|
8 |
+
$this->_init('promotional/grid', 'id');
|
9 |
+
}
|
10 |
+
public function addGridPosition($collection,$promotional_id){
|
11 |
+
$table2 = $this->getMainTable();
|
12 |
+
$cond = $this->_getWriteAdapter()->quoteInto('e.entity_id = t2.product_id','');
|
13 |
+
$where = $this->_getWriteAdapter()->quoteInto('t2.promotional_id = ? OR ', $promotional_id).
|
14 |
+
$this->_getWriteAdapter()->quoteInto('isnull(t2.promotional_id)','');
|
15 |
+
$collection->getSelect()->joinLeft(array('t2'=>$table2), $cond)->where($where);
|
16 |
+
|
17 |
+
//echo $collection->getSelect();die;
|
18 |
+
}
|
19 |
+
}
|
app/code/local/XT/Promotional/Model/Mysql4/Grid/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Model_Mysql4_Grid_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('promotional/grid');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/XT/Promotional/Model/Mysql4/Promotional.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Model_Mysql4_Promotional extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the manager_id refers to the key field in your database table.
|
8 |
+
$this->_init('promotional/promotional', 'promotional_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/XT/Promotional/Model/Mysql4/Promotional/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Model_Mysql4_Promotional_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('promotional/promotional');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/XT/Promotional/Model/Promotional.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Model_Promotional extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('promotional/promotional');
|
9 |
+
}
|
10 |
+
public function getproids()
|
11 |
+
{
|
12 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
13 |
+
$result = $connection->query("select * from grid_promotional order by position");
|
14 |
+
while ($row = $result->fetch() ) {
|
15 |
+
$ids[]=$row['product_id'];
|
16 |
+
}
|
17 |
+
return $ids;
|
18 |
+
}
|
19 |
+
}
|
app/code/local/XT/Promotional/controllers/Adminhtml/PromotionalController.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XT_Promotional_Adminhtml_PromotionalController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
public function gridAction(){
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->getLayout()->getBlock('customer.grid');
|
9 |
+
$this->renderLayout();
|
10 |
+
}
|
11 |
+
|
12 |
+
public function upsellgridAction(){
|
13 |
+
$this->loadLayout();
|
14 |
+
$this->getLayout()->getBlock('customer.grid');
|
15 |
+
$this->renderLayout();
|
16 |
+
}
|
17 |
+
|
18 |
+
|
19 |
+
protected function _initAction() {
|
20 |
+
$this->loadLayout()
|
21 |
+
->_setActiveMenu('promotional/items')
|
22 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Promotional'), Mage::helper('adminhtml')->__('Item Manager'));
|
23 |
+
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function indexAction() {
|
28 |
+
$this->_initAction()
|
29 |
+
->renderLayout();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function editAction() {
|
33 |
+
$id = $this->getRequest()->getParam('id');
|
34 |
+
$model = Mage::getModel('promotional/promotional')->load($id);
|
35 |
+
|
36 |
+
if ($model->getId() || $id == 0) {
|
37 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
38 |
+
if (!empty($data)) {
|
39 |
+
$model->setData($data);
|
40 |
+
}
|
41 |
+
|
42 |
+
Mage::register('promotional_data', $model);
|
43 |
+
|
44 |
+
$this->loadLayout();
|
45 |
+
$this->_setActiveMenu('promotional/items');
|
46 |
+
|
47 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
48 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
49 |
+
|
50 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
51 |
+
|
52 |
+
$this->_addContent($this->getLayout()->createBlock('promotional/adminhtml_promotional_edit'))
|
53 |
+
->_addLeft($this->getLayout()->createBlock('promotional/adminhtml_promotional_edit_tabs'));
|
54 |
+
|
55 |
+
$this->renderLayout();
|
56 |
+
} else {
|
57 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotional')->__('Item does not exist'));
|
58 |
+
$this->_redirect('*/*/edit', array('id' => 1));
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
public function newAction() {
|
63 |
+
$this->_forward('edit');
|
64 |
+
}
|
65 |
+
|
66 |
+
public function saveAction() {
|
67 |
+
if ($data = $this->getRequest()->getPost()) {
|
68 |
+
|
69 |
+
/*$model = Mage::getModel('promotional/promotional');
|
70 |
+
$model->setData($data)
|
71 |
+
->setId($this->getRequest()->getParam('id'));*/
|
72 |
+
|
73 |
+
try {
|
74 |
+
|
75 |
+
//$model->save();
|
76 |
+
$promotional_id = 1;
|
77 |
+
if(isset($data['links'])){
|
78 |
+
$customers = Mage::helper('adminhtml/js')->decodeGridSerializedInput($data['links']['customers']); //Save the array to your database
|
79 |
+
|
80 |
+
$collection = Mage::getModel('promotional/grid')->getCollection();
|
81 |
+
$collection->addFieldToFilter('promotional_id',$promotional_id);
|
82 |
+
$collection->addFieldToFilter('store_id',$data['store_id']);
|
83 |
+
foreach($collection as $obj){
|
84 |
+
$obj->delete();
|
85 |
+
}
|
86 |
+
|
87 |
+
foreach($customers as $key => $value){
|
88 |
+
$model2 = Mage::getModel('promotional/grid');
|
89 |
+
$model2->setPromotionalId($promotional_id);
|
90 |
+
$model2->setProductId($key);
|
91 |
+
$model2->setPosition($value['position']);
|
92 |
+
$model2->setStoreId($data['store_id']);
|
93 |
+
$model2->save();
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('promotional')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
//if ($this->getRequest()->getParam('back')) {
|
101 |
+
//$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
//return;
|
103 |
+
//}
|
104 |
+
|
105 |
+
$this->_redirect('*/*/edit', array('id' => 1));
|
106 |
+
return;
|
107 |
+
} catch (Exception $e) {
|
108 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
109 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
110 |
+
$this->_redirect('*/*/edit', array('id' => 1));
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotional')->__('Unable to find item to save'));
|
115 |
+
$this->_redirect('*/*/edit', array('id' => 1));
|
116 |
+
}
|
117 |
+
|
118 |
+
public function deleteAction() {
|
119 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
120 |
+
try {
|
121 |
+
$model = Mage::getModel('promotional/promotional');
|
122 |
+
|
123 |
+
$model->setId($this->getRequest()->getParam('id'))
|
124 |
+
->delete();
|
125 |
+
|
126 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
127 |
+
$this->_redirect('*/*/');
|
128 |
+
} catch (Exception $e) {
|
129 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
130 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
131 |
+
}
|
132 |
+
}
|
133 |
+
$this->_redirect('*/*/');
|
134 |
+
}
|
135 |
+
|
136 |
+
public function massDeleteAction() {
|
137 |
+
$promotionalIds = $this->getRequest()->getParam('promotional');
|
138 |
+
if(!is_array($promotionalIds)) {
|
139 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
140 |
+
} else {
|
141 |
+
try {
|
142 |
+
foreach ($promotionalIds as $promotionalId) {
|
143 |
+
$promotional = Mage::getModel('promotional/promotional')->load($promotionalId);
|
144 |
+
$promotional->delete();
|
145 |
+
}
|
146 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
147 |
+
Mage::helper('adminhtml')->__(
|
148 |
+
'Total of %d record(s) were successfully deleted', count($promotionalIds)
|
149 |
+
)
|
150 |
+
);
|
151 |
+
} catch (Exception $e) {
|
152 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
153 |
+
}
|
154 |
+
}
|
155 |
+
$this->_redirect('*/*/index');
|
156 |
+
}
|
157 |
+
|
158 |
+
public function setregisterAction() {
|
159 |
+
$store_id = $this->getRequest()->getParam('store_id');
|
160 |
+
Mage::getSingleton('adminhtml/session')->setData('promotional_store_id',$store_id);
|
161 |
+
}
|
162 |
+
|
163 |
+
}
|
app/code/local/XT/Promotional/etc/config.xml
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<XT_Promotional>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</XT_Promotional>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<promotional>
|
11 |
+
<use>admin</use>
|
12 |
+
<args>
|
13 |
+
<module>XT_Promotional</module>
|
14 |
+
<frontName>promotional</frontName>
|
15 |
+
</args>
|
16 |
+
</promotional>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
<adminhtml>
|
20 |
+
<menu>
|
21 |
+
<catalog>
|
22 |
+
<children>
|
23 |
+
<promotional module="promotional">
|
24 |
+
<title>Manage Promotional Products</title>
|
25 |
+
<sort_order>3</sort_order>
|
26 |
+
<action>promotional/adminhtml_promotional/new</action>
|
27 |
+
</promotional>
|
28 |
+
</children>
|
29 |
+
</catalog>
|
30 |
+
</menu>
|
31 |
+
<acl>
|
32 |
+
<resources>
|
33 |
+
<all>
|
34 |
+
<title>Allow Everything</title>
|
35 |
+
</all>
|
36 |
+
<admin>
|
37 |
+
<children>
|
38 |
+
<XT_Promotional>
|
39 |
+
<title>Promotional Module</title>
|
40 |
+
<sort_order>10</sort_order>
|
41 |
+
</XT_Promotional>
|
42 |
+
</children>
|
43 |
+
</admin>
|
44 |
+
</resources>
|
45 |
+
</acl>
|
46 |
+
<layout>
|
47 |
+
<updates>
|
48 |
+
<promotional>
|
49 |
+
<file>promotional.xml</file>
|
50 |
+
</promotional>
|
51 |
+
</updates>
|
52 |
+
</layout>
|
53 |
+
</adminhtml>
|
54 |
+
<global>
|
55 |
+
<models>
|
56 |
+
<promotional>
|
57 |
+
<class>XT_Promotional_Model</class>
|
58 |
+
<resourceModel>promotional_mysql4</resourceModel>
|
59 |
+
</promotional>
|
60 |
+
<promotional_mysql4>
|
61 |
+
<class>XT_Promotional_Model_Mysql4</class>
|
62 |
+
<entities>
|
63 |
+
<promotional>
|
64 |
+
<table>customer_promotional</table>
|
65 |
+
</promotional>
|
66 |
+
<grid>
|
67 |
+
<table>grid_promotional</table>
|
68 |
+
</grid>
|
69 |
+
</entities>
|
70 |
+
</promotional_mysql4>
|
71 |
+
</models>
|
72 |
+
<resources>
|
73 |
+
<promotional_setup>
|
74 |
+
<setup>
|
75 |
+
<module>XT_Promotional</module>
|
76 |
+
</setup>
|
77 |
+
<connection>
|
78 |
+
<use>core_setup</use>
|
79 |
+
</connection>
|
80 |
+
</promotional_setup>
|
81 |
+
<promotional_write>
|
82 |
+
<connection>
|
83 |
+
<use>core_write</use>
|
84 |
+
</connection>
|
85 |
+
</promotional_write>
|
86 |
+
<promotional_read>
|
87 |
+
<connection>
|
88 |
+
<use>core_read</use>
|
89 |
+
</connection>
|
90 |
+
</promotional_read>
|
91 |
+
</resources>
|
92 |
+
<blocks>
|
93 |
+
<promotional>
|
94 |
+
<class>XT_Promotional_Block</class>
|
95 |
+
</promotional>
|
96 |
+
</blocks>
|
97 |
+
<helpers>
|
98 |
+
<promotional>
|
99 |
+
<class>XT_Promotional_Helper</class>
|
100 |
+
</promotional>
|
101 |
+
</helpers>
|
102 |
+
</global>
|
103 |
+
<frontend>
|
104 |
+
<routers>
|
105 |
+
<promotional>
|
106 |
+
<use>standard</use>
|
107 |
+
<args>
|
108 |
+
<module>XT_Promotional</module>
|
109 |
+
<frontName>promotional</frontName>
|
110 |
+
</args>
|
111 |
+
</promotional>
|
112 |
+
</routers>
|
113 |
+
<layout>
|
114 |
+
<updates>
|
115 |
+
<promotional>
|
116 |
+
<file>promotional.xml</file>
|
117 |
+
</promotional>
|
118 |
+
</updates>
|
119 |
+
</layout>
|
120 |
+
</frontend>
|
121 |
+
</config>
|
app/code/local/XT/Promotional/sql/promotional_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
DROP TABLE IF EXISTS {$this->getTable('customer_promotional')};
|
10 |
+
CREATE TABLE {$this->getTable('customer_promotional')} (
|
11 |
+
`promotional_id` int(11) NOT NULL default 0,
|
12 |
+
`title` varchar(255) NOT NULL default '',
|
13 |
+
PRIMARY KEY (`promotional_id`)
|
14 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
15 |
+
|
16 |
+
DROP TABLE IF EXISTS {$this->getTable('grid_promotional')};
|
17 |
+
CREATE TABLE {$this->getTable('grid_promotional')} (
|
18 |
+
`id` int(11) unsigned NOT NULL auto_increment,
|
19 |
+
`promotional_id` int(11) NOT NULL ,
|
20 |
+
`product_id` int(11) NOT NULL ,
|
21 |
+
`position` int(11) NOT NULL default 0,
|
22 |
+
`store_id` smallint(6) NOT NULL default '1',
|
23 |
+
PRIMARY KEY (`id`)
|
24 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
25 |
+
|
26 |
+
");
|
27 |
+
|
28 |
+
$installer->run("
|
29 |
+
INSERT INTO `{$installer->getTable('customer_promotional')}`
|
30 |
+
(`promotional_id`, `title`) values (1,'Generic Promotional Products');
|
31 |
+
");
|
32 |
+
|
33 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/promotional.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<promotional_adminhtml_promotional_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="promotional/adminhtml_promotional" name="promotional" />
|
6 |
+
</reference>
|
7 |
+
</promotional_adminhtml_promotional_index>
|
8 |
+
<promotional_adminhtml_promotional_grid>
|
9 |
+
<block type="core/text_list" name="root" output="toHtml">
|
10 |
+
<block type="promotional/adminhtml_promotional_edit_tab_grid" name="customer.grid"/>
|
11 |
+
<block type="adminhtml/widget_grid_serializer" name="grid_serializer">
|
12 |
+
<reference name="grid_serializer">
|
13 |
+
<action method="initSerializerBlock">
|
14 |
+
<grid_block_name>customer.grid</grid_block_name>
|
15 |
+
<data_callback>getSelectedCustomers</data_callback>
|
16 |
+
<hidden_input_name>links[customers]</hidden_input_name>
|
17 |
+
<reload_param_name>customers</reload_param_name>
|
18 |
+
</action>
|
19 |
+
<action method="addColumnInputName">
|
20 |
+
<input_name>position</input_name>
|
21 |
+
</action>
|
22 |
+
</reference>
|
23 |
+
</block>
|
24 |
+
</block>
|
25 |
+
</promotional_adminhtml_promotional_grid>
|
26 |
+
<promotional_adminhtml_promotional_upsellgrid>
|
27 |
+
<block type="core/text_list" name="root" output="toHtml">
|
28 |
+
<block type="promotional/adminhtml_promotional_edit_tab_grid" name="customer.grid"/>
|
29 |
+
</block>
|
30 |
+
</promotional_adminhtml_promotional_upsellgrid>
|
31 |
+
</layout>
|
app/design/adminhtml/default/default/template/promotional/stores.phtml
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="entry-edit">
|
28 |
+
<div class="entry-edit-head">
|
29 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('promotional')->__('Select Stores (Please choose a store view to add items)') ?></h4>
|
30 |
+
</div>
|
31 |
+
<?php $_switcherBlock = new Mage_Adminhtml_Block_Store_Switcher() ;?>
|
32 |
+
<?php if ($websites = $_switcherBlock->getWebsites()): ?>
|
33 |
+
<p class="switcher"><label for="store_switcher"><?php echo $this->__('Choose Store View') ?>:</label>
|
34 |
+
<select name="store_id" id="store_switcher" onchange="setRegister(this.value)">
|
35 |
+
<?php if ($_switcherBlock->hasDefaultOption()): ?>
|
36 |
+
<option value=""><?php echo $_switcherBlock->getDefaultStoreName() ?></option>
|
37 |
+
<?php endif; ?>
|
38 |
+
<?php foreach ($websites as $website): ?>
|
39 |
+
<?php $showWebsite=false; ?>
|
40 |
+
<?php foreach ($website->getGroups() as $group): ?>
|
41 |
+
<?php $showGroup=false; ?>
|
42 |
+
<?php foreach ($_switcherBlock->getStores($group) as $store): ?>
|
43 |
+
<?php if ($showWebsite == false): ?>
|
44 |
+
<?php $showWebsite = true; ?>
|
45 |
+
<optgroup label="<?php echo $website->getName() ?>"></optgroup>
|
46 |
+
<?php endif; ?>
|
47 |
+
<?php if ($showGroup == false): ?>
|
48 |
+
<?php $showGroup = true; ?>
|
49 |
+
<optgroup label=" <?php echo $group->getName() ?>">
|
50 |
+
<?php endif; ?>
|
51 |
+
<option value="<?php echo $store->getId() ?>"<?php if($store->getId() == Mage::getSingleton('adminhtml/session')->getData('promotional_store_id')): ?> selected="selected"<?php endif; ?>> <?php echo $store->getName() ?></option>
|
52 |
+
<?php endforeach; ?>
|
53 |
+
<?php if ($showGroup): ?>
|
54 |
+
</optgroup>
|
55 |
+
<?php endif; ?>
|
56 |
+
<?php endforeach; ?>
|
57 |
+
<?php endforeach; ?>
|
58 |
+
</select>
|
59 |
+
</p>
|
60 |
+
|
61 |
+
<?php endif; ?>
|
62 |
+
|
63 |
+
<script type="text/javascript">
|
64 |
+
|
65 |
+
function setRegister(id){
|
66 |
+
new Ajax.Request('<?php echo $this->getUrl('promotional/adminhtml_promotional/setregister')?>',
|
67 |
+
{
|
68 |
+
method:'get',
|
69 |
+
parameters: {store_id:id},
|
70 |
+
onSuccess: function(transport){
|
71 |
+
var response = transport.responseText || "no response text";
|
72 |
+
window.location.reload();
|
73 |
+
},
|
74 |
+
onFailure: function(){ alert('Something went wrong...') }
|
75 |
+
|
76 |
+
});
|
77 |
+
}
|
78 |
+
</script>
|
79 |
+
|
app/design/frontend/base/default/layout/promotional.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="right">
|
5 |
+
<block type="core/template" name="promotionalproduct" template="promotional/promotional.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
+
</layout>
|
app/design/frontend/base/default/template/promotional/promotional.phtml
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//echo Mage::app()->getStore()->getId();
|
3 |
+
$collection = Mage::getModel('promotional/grid')->getCollection()->addFieldToFilter('store_id',Mage::app()->getStore()->getId())->addFieldToFilter('promotional_id', array('eq' => '1'))->setOrder('position','ASC');
|
4 |
+
//print_r($collection);
|
5 |
+
?>
|
6 |
+
<div class="bstseller-main">
|
7 |
+
<h2>Promotional Products</h2>
|
8 |
+
<div class="bstseller-contain-outer">
|
9 |
+
<div class="bstseller-contain">
|
10 |
+
<?php if(count($collection) > 0){ $count = 1;?>
|
11 |
+
<?php
|
12 |
+
foreach($collection as $col)
|
13 |
+
{
|
14 |
+
if($count<=4)
|
15 |
+
{
|
16 |
+
$productModel = Mage::getModel('catalog/product')->load($col->getProductId());
|
17 |
+
if($productModel->getEntityId()):
|
18 |
+
$price = Mage::helper('core')->currency($productModel->getFinalPrice(),true,false);
|
19 |
+
?>
|
20 |
+
<div class="bstseller-row">
|
21 |
+
<div class="thumb-img"><a href="<?php echo $productModel->getProductUrl();?>"><img src="<?php echo $this->helper('catalog/image')->init($productModel, 'small_image')->resize(80); ?>" width="80" height="80" alt="<?php echo $this->stripTags($this->getImageLabel($productModel, 'small_image'), null, true) ?>" /></a></div>
|
22 |
+
<div class="bstsell-info">
|
23 |
+
<h2><a href="<?php echo $productModel->getProductUrl();?>"><?php echo $productModel->getName();?></a></h2>
|
24 |
+
<p><?php echo $productModel->getListingOverview();?></p>
|
25 |
+
<h3 class="price"><?php echo $price;?></h3>
|
26 |
+
</div>
|
27 |
+
</div>
|
28 |
+
<?php endif; } ?>
|
29 |
+
<?php $count++;} ?>
|
30 |
+
<?php } ?>
|
31 |
+
|
32 |
+
|
33 |
+
<?php /*?><div class="bstseller-row">
|
34 |
+
<div class="thumb-img"><img src="<?php echo $this->getSkinUrl('images/bstsell-pro2.jpg')?>" alt="" /></div>
|
35 |
+
<div class="bstsell-info">
|
36 |
+
<h2><a href="#">ShapeSmart DECarb</a></h2>
|
37 |
+
<p>60 Tablet Box</p>
|
38 |
+
<h3 class="price">£25.03</h3>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
<div class="bstseller-row">
|
42 |
+
<div class="thumb-img"><img src="<?php echo $this->getSkinUrl('images/bstsell-pro3.jpg')?>" alt="" /></div>
|
43 |
+
<div class="bstsell-info">
|
44 |
+
<h2><a href="#">Slimming.com HGH Advanced</a></h2>
|
45 |
+
<p>120 Capsule Box</p>
|
46 |
+
<h3 class="price">£34.67</h3>
|
47 |
+
</div>
|
48 |
+
</div>
|
49 |
+
<div class="bstseller-row">
|
50 |
+
<div class="thumb-img"><img src="<?php echo $this->getSkinUrl('images/bstsell-pro4.jpg')?>" alt="" /></div>
|
51 |
+
<div class="bstsell-info">
|
52 |
+
<h2><a href="#">Goldshield LIPObind</a></h2>
|
53 |
+
<p>60 Tablet Box</p>
|
54 |
+
<h3 class="price">£13.90</h3>
|
55 |
+
</div>
|
56 |
+
</div><?php */?>
|
57 |
+
|
58 |
+
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
</div>
|
app/etc/modules/XT_Promotional.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<XT_Promotional>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</XT_Promotional>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Xt_Promotional</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Ability to assign store specific Promotional Offer.</summary>
|
10 |
+
<description>This module will allow the E-Commerce administrator to choose store specific different promotional product and can show those products on home page or left/right panel or any specific CMS page for individual store.</description>
|
11 |
+
<notes>This extension is a stable version.</notes>
|
12 |
+
<authors><author><name>Rik Sen</name><user>pmgr</user><email>pm@hire-developer.co.uk</email></author></authors>
|
13 |
+
<date>2013-02-01</date>
|
14 |
+
<time>13:46:26</time>
|
15 |
+
<contents><target name="magelocal"><dir name="XT"><dir name="Promotional"><dir name="Block"><dir name="Adminhtml"><dir name="Promotional"><dir name="Edit"><file name="Form.php" hash="3dc0a9d75186ca93e4c4e01557b1fc8b"/><dir name="Tab"><file name="Grid.php" hash="ec3a9c0c22743ff7bc55ca2cc12401af"/><file name="Store.php" hash="c9d5b5d918fde891f128e19cb3e61e6c"/></dir><file name="Tabs.php" hash="4a53066a63481848a498092832ff6a16"/></dir><file name="Edit.php" hash="f7efe7476ca0c5948879f93f8a2fff42"/><file name="Grid.php" hash="4dcb107b72e0446f0c008a5fbbdf745c"/></dir><file name="Promotional.php" hash="dd6224b54ab0d3c08308aa82f7b6c96e"/></dir><file name="Promotional.php" hash="59c291c4be09cba129b21af4e8d3f788"/></dir><dir name="Helper"><file name="Data.php" hash="3565b9e87dde00a5ca8d7d02dd1b4e17"/></dir><dir name="Model"><file name="Grid.php" hash="a54b43fe83045887857f89af29f56f3b"/><dir name="Mysql4"><dir name="Grid"><file name="Collection.php" hash="9c9167fd73abdb6538a0f72d0d9ab8e2"/></dir><file name="Grid.php" hash="c26f0289f6c0a27cf663048b29c5bce0"/><dir name="Promotional"><file name="Collection.php" hash="4d2c44c7022a3c0e59cf1e6a0d125ea8"/></dir><file name="Promotional.php" hash="3cb7bcb15a5fbcaa7991a516680f4b1f"/></dir><file name="Promotional.php" hash="6498fc5416c3b7371a4acacb2ccdbfa9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PromotionalController.php" hash="e74fc550e5a058941c0270aabe50080d"/></dir></dir><dir name="etc"><file name="config.xml" hash="5f425528cd704088dd8309fb9ed0a41a"/></dir><dir name="sql"><dir name="promotional_setup"><file name="mysql4-install-0.1.0.php" hash="280613ee85904b4b52d494bd6094ba15"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="XT_Promotional.xml" hash="53d8881efa35d15a07ba409d43d8c74a"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="promotional.xml" hash="29be8491aab784820ab4653f5c39b086"/></dir><dir name="template"><dir name="promotional"><file name="promotional.phtml" hash="c298d5e44076d663a7ab5349b7cc8a9a"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="promotional.xml" hash="a8bea054f1796766d91fe5481a0e4fdd"/></dir><dir name="template"><dir name="promotional"><file name="stores.phtml" hash="d921ff4c2355268b92764a3615902235"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|