Ktree_Labels - Version 0.1.0

Version Notes

Product Labels which will Show discount and latest product info using Customized Images

Download this release

Release Info

Developer KTree
Extension Ktree_Labels
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Ktree/Label/Block/Adminhtml/Label.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Block_Adminhtml_Label extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ public function __construct()
9
+ {
10
+ $this->_controller = 'adminhtml_label';
11
+ $this->_blockGroup = 'label';
12
+ $this->_headerText = Mage::helper('label')->__('Manage Labels');
13
+ $this->_addButtonLabel = Mage::helper('label')->__('Add New Label');
14
+ parent::__construct();
15
+ }
16
+
17
+ }
app/code/local/Ktree/Label/Block/Adminhtml/Label/Edit.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Block_Adminhtml_Label_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+
12
+ $this->_objectId = 'id';
13
+ $this->_blockGroup = 'label';
14
+ $this->_controller = 'adminhtml_label';
15
+
16
+ $this->_updateButton('save', 'label', Mage::helper('label')->__('Save Label'));
17
+ $this->_updateButton('delete', 'label', Mage::helper('label')->__('Delete Label'));
18
+
19
+ if( $this->getRequest()->getParam($this->_objectId) ) {
20
+ $model = Mage::getModel('label/label')->load($this->getRequest()->getParam($this->_objectId));
21
+ Mage::register('label', $model);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Get header text
27
+ *
28
+ * @return string
29
+ */
30
+ public function getHeaderText()
31
+ {
32
+ if( Mage::registry('label') && Mage::registry('label')->getId() ) {
33
+ return Mage::helper('label')->__('Edit Label');
34
+ } else {
35
+ return Mage::helper('label')->__('Add Label');
36
+ }
37
+ }
38
+ }
app/code/local/Ktree/Label/Block/Adminhtml/Label/Edit/Form.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Block_Adminhtml_Label_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+
5
+ /**
6
+ * Preparing global layout
7
+ *
8
+ * You can redefine this method in child classes for changin layout
9
+ *
10
+ * @return Mage_Core_Block_Abstract
11
+ */
12
+ protected function _prepareLayout()
13
+ {
14
+ parent::_prepareLayout();
15
+
16
+ }
17
+
18
+ /**
19
+ * Prepare form before rendering HTML
20
+ *
21
+ * @return Mage_Adminhtml_Block_Widget_Form
22
+ */
23
+ protected function _prepareForm()
24
+ {
25
+ $model = Mage::getModel('label/label');
26
+ $form = new Varien_Data_Form(array(
27
+ 'id' => 'edit_form',
28
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
29
+ 'method' => 'post',
30
+ 'enctype' => 'multipart/form-data'
31
+ ));
32
+
33
+ $fieldset = $form->addFieldset('label_form', array(
34
+ 'legend' => Mage::helper('label')->__('Label'),
35
+ 'class' => 'fieldset-wide',
36
+ )
37
+ );
38
+
39
+ $fieldset->addField('label_text', 'text', array(
40
+ 'name' => 'label_text',
41
+ 'label' => Mage::helper('label')->__('Text'),
42
+ 'class' => 'required-entry',
43
+ 'required' => true,
44
+ ));
45
+
46
+ $fieldset->addField('label_img', 'image', array(
47
+ 'name' => 'label_img',
48
+ 'label' => Mage::helper('label')->__('Image'),
49
+ ));
50
+
51
+
52
+ $fieldset->addField('label_productskus', 'text', array(
53
+ 'name' => 'label_productskus',
54
+ 'label' => Mage::helper('label')->__('Product SKUs'),
55
+ 'class' => 'required-entry',
56
+
57
+ ));
58
+ $fieldset->addField('label_position', 'select', array(
59
+ 'label' => Mage::helper('label')->__('Position'),
60
+ 'name' => 'label_position',
61
+ 'class' => 'required-entry',
62
+ 'values' => $model->getPositions(),
63
+ ));
64
+
65
+ $fieldset->addField('store_id', 'multiselect', array(
66
+ 'name' => 'stores[]',
67
+ 'label' => Mage::helper('cms')->__('Store View'),
68
+ 'title' => Mage::helper('cms')->__('Store View'),
69
+ 'required' => true,
70
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
71
+ ));
72
+ if (Mage::registry('label')) {
73
+ $form->setValues(Mage::registry('label')->getData());
74
+ }
75
+
76
+ $form->setUseContainer(true);
77
+ $this->setForm($form);
78
+ return parent::_prepareForm();
79
+ }
80
+
81
+ }
app/code/local/Ktree/Label/Block/Adminhtml/Label/Grid.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Block_Adminhtml_Label_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+
5
+ /**
6
+ * Constructor
7
+ */
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('labelGrid');
12
+ $this->setDefaultSort('label_id');
13
+ $this->setDefaultDir('ASC');
14
+ $this->setSaveParametersInSession(true);
15
+ }
16
+
17
+ /**
18
+ * Prepare grid collection object
19
+ *
20
+ * @return Ktree_Label_Block_Adminhtml_Label_Grid
21
+ */
22
+ protected function _prepareCollection()
23
+ {
24
+ $this->setCollection(Mage::getModel('label/label')->getCollection());
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ /**
29
+ * Preparing colums for grid
30
+ *
31
+ * @return Ktree_Label_Block_Adminhtml_Label_Grid
32
+ */
33
+ protected function _prepareColumns()
34
+ {
35
+ $this->addColumn('label_id', array(
36
+ 'header' => Mage::helper('label')->__('Id'),
37
+ 'align' => 'right',
38
+ 'width' => '50px',
39
+ 'index' => 'label_id',
40
+ 'type' => 'number',
41
+ ));
42
+
43
+ $this->addColumn('label_text', array(
44
+ 'header' => Mage::helper('label')->__('Text'),
45
+ 'align' => 'left',
46
+ 'index' => 'label_text',
47
+ ));
48
+
49
+ $this->addColumn('label_productskus', array(
50
+ 'header' => Mage::helper('label')->__('Product SKUs'),
51
+ 'align' => 'left',
52
+ 'index' => 'label_productskus',
53
+ ));
54
+ $this->addColumn('label_position', array(
55
+ 'header' => Mage::helper('label')->__('Position'),
56
+ 'align' => 'left',
57
+ 'index' => 'label_position',
58
+ ));
59
+
60
+ return parent::_prepareColumns();
61
+ }
62
+
63
+ public function getRowUrl($row)
64
+ {
65
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
66
+ }
67
+
68
+ }
app/code/local/Ktree/Label/Block/Label.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Block_Label extends Mage_Core_Block_Template
3
+ {
4
+
5
+ /**
6
+ * Before rendering html, but after trying to load cache
7
+ *
8
+ * @return Ktree_Label_Block_Label
9
+ */
10
+ protected function _beforeToHtml()
11
+ {
12
+ $this->_prepareCollection();
13
+ return parent::_beforeToHtml();
14
+ }
15
+
16
+ /**
17
+ * Prepare testimonial collection object
18
+ *
19
+ * @return Ktree_Label_Block_Label
20
+ */
21
+ protected function _prepareCollection()
22
+ {
23
+ /* @var $collection Ktree_Label_Model_Mysql4_Label_Collection */
24
+ $collection = Mage::getModel("label/label")->getCollection();
25
+
26
+ $collection->setOrder('label_id', 'ASC')
27
+ ->load();
28
+ $this->setLabels($collection);
29
+ return $this;
30
+ }
31
+
32
+ }
app/code/local/Ktree/Label/Helper/Data.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getProductLabels($productsku,$type)
5
+ {
6
+ $html = '';
7
+ $labelcollection=Mage::getModel('label/label')->getCollection()->getData();
8
+ $count=0;
9
+ foreach($labelcollection as $label ) {
10
+ $productskus=$label['label_productskus'];
11
+ //$html.=$productsku;
12
+ $stores=$label['store_id'];
13
+ $productskuarray=array();
14
+ $productskuarray=explode(',',$productskus);
15
+ $storeidarray=array();
16
+ $storeidarray=explode(',',$stores);
17
+ $currentStoreId = Mage::app()->getStore()->getId();
18
+ if(in_array($currentStoreId,$storeidarray) || in_array('0',$storeidarray)) {
19
+ if(in_array($productsku,$productskuarray)) {
20
+ //$html.="raj";
21
+ $image=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."".$label['label_img'];
22
+ //$html.=$image;
23
+ if($label['label_position']) {
24
+ $position=strtolower($label['label_position']);
25
+ $position=str_replace(" ","-",$position);
26
+ if($type=='product') {
27
+ $html.='<table class="ktlabel product-'.$position.'" style="height:80px; width:80px;">';
28
+ } else {
29
+ $html.='<table class="ktlabel '.$position.'" style="height:80px; width:80px;">';
30
+ }
31
+ $html.='<tbody><tr>';
32
+ $html.='<td style="background:url('.$image.') no-repeat 0 0">';
33
+ $html.='<span class="ktlabel-txt">'.$label['label_text'].'</span>';
34
+ $html.='</td></tr></tbody></table>';
35
+ }
36
+ //$html.='<img src="'.$image.'" alt="'.$label['lagel_text'].'">';
37
+ //$html.='';
38
+ }
39
+ }
40
+ }
41
+
42
+ return $html;
43
+ }
44
+
45
+ }
app/code/local/Ktree/Label/Model/Label.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Model_Label extends Mage_Core_Model_Abstract
3
+ {
4
+
5
+ /**
6
+ * Internal constructor not depended on params. Can be used for object initialization
7
+ */
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('label/label');
12
+ }
13
+ public function getPositions($labeltext = true)
14
+ {
15
+ $positionsarray = array();
16
+ foreach (array('top', 'middle', 'bottom') as $first){
17
+ foreach (array('left', 'center', 'right') as $second){
18
+ $positions = $labeltext ?
19
+ Mage::helper('label')->__(ucwords($first . ' ' . $second))
20
+ :
21
+ $first . '-' . $second;
22
+ $positionsarray[$positions]=$positions;
23
+ }
24
+ }
25
+ return $positionsarray;
26
+ }
27
+
28
+ }
app/code/local/Ktree/Label/Model/Mysql4/Label.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Model_Mysql4_Label extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+
5
+ /**
6
+ * Resource initialization
7
+ */
8
+ public function _construct()
9
+ {
10
+ $this->_init('label/label', 'label_id');
11
+ }
12
+
13
+ }
app/code/local/Ktree/Label/Model/Mysql4/Label/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Model_Mysql4_Label_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('label/label');
9
+ }
10
+
11
+ }
app/code/local/Ktree/Label/controllers/Adminhtml/LabelController.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_Adminhtml_LabelController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+ /**
6
+ * Init here
7
+ */
8
+ protected function _initAction()
9
+ {
10
+ $this->loadLayout();
11
+ $this->_setActiveMenu('label');
12
+ $this->_addBreadcrumb(Mage::helper('label')->__('Label'), Mage::helper('label')->__('Product Labels'));
13
+ }
14
+
15
+ /**
16
+ * View grid action
17
+ */
18
+ public function indexAction()
19
+ {
20
+ $this->_initAction();
21
+ $this->renderLayout();
22
+ }
23
+
24
+ /**
25
+ * View edit form action
26
+ */
27
+ public function editAction()
28
+ {
29
+ $this->_initAction();
30
+ $this->_addContent($this->getLayout()->createBlock('label/adminhtml_label_edit'));
31
+ $this->renderLayout();
32
+ }
33
+
34
+ /**
35
+ * View new form action
36
+ */
37
+ public function newAction()
38
+ {
39
+ $this->editAction();
40
+ }
41
+
42
+ /**
43
+ * Save form action
44
+ */
45
+ public function saveAction()
46
+ {
47
+ if ($this->getRequest()->getPost()) {
48
+ try {
49
+ $data = $this->getRequest()->getPost();
50
+ if(isset($data['stores'])) {
51
+ $stores = $data['stores'];
52
+ $storesCount = count($stores);
53
+ $storesIndex = 1;
54
+ $storesData = '';
55
+ foreach($stores as $store) {
56
+ $storesData .= $store;
57
+ if($storesIndex < $storesCount) {
58
+ $storesData .= ',';
59
+ }
60
+ $storesIndex++;
61
+ }
62
+ $data['store_id'] = $storesData;
63
+ }
64
+ //implode the reseller services name which is a multiselect fiel
65
+ //$data['reseller_services']=implode(',',$data['reseller_services']);
66
+
67
+ if (isset($_FILES['label_img']['name']) and (file_exists($_FILES['label_img']['tmp_name']))) {
68
+ $uploader = new Varien_File_Uploader('label_img');
69
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
70
+ $uploader->setAllowRenameFiles(false);
71
+ $uploader->setFilesDispersion(false);
72
+ $path = Mage::getBaseDir('media') . DS ;
73
+ $uploader->save($path, $_FILES['label_img']['name']);
74
+ $data['label_img'] = $_FILES['label_img']['name'];
75
+ } else {
76
+ if(isset($data['label_img']['delete']) && $data['label_img']['delete'] == 1) {
77
+ $data['label_img'] = '';
78
+ } else {
79
+ unset($data['label_img']);
80
+ }
81
+ }
82
+
83
+ $model = Mage::getModel('label/label');
84
+ $model->setData($data)->setLabelId($this->getRequest()->getParam('id'))->save();
85
+
86
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('label')->__('Products Label was successfully saved'));
87
+
88
+ } catch (Exception $e) {
89
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
90
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
91
+ return;
92
+ }
93
+ }
94
+
95
+ $this->_redirect('*/*/');
96
+ }
97
+
98
+ /**
99
+ * Delete action
100
+ */
101
+ public function deleteAction()
102
+ {
103
+ if ($this->getRequest()->getParam('id') > 0) {
104
+ try {
105
+ $model = Mage::getModel('label/label');
106
+ $model->setLabelId($this->getRequest()->getParam('id'))
107
+ ->delete();
108
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('label')->__('Products was successfully deleted'));
109
+ $this->_redirect('*/*/');
110
+ } catch (Exception $e) {
111
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
112
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
113
+ }
114
+ }
115
+
116
+ $this->_redirect('*/*/');
117
+ }
118
+
119
+
120
+
121
+ }
app/code/local/Ktree/Label/controllers/IndexController.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ktree_Label_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+
10
+ }
app/code/local/Ktree/Label/etc/adminhtml.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <menu>
5
+ <label translate="title" module="label">
6
+ <title>Product Labels</title>
7
+ <sort_order>50</sort_order>
8
+ <children>
9
+ <label module="label">
10
+ <title> Manage Labels </title>
11
+ <sort_order>0</sort_order>
12
+ <action>adminhtml/label</action>
13
+ </label>
14
+ </children>
15
+ </label>
16
+
17
+ </menu>
18
+ <acl>
19
+ <resources>
20
+ <all>
21
+ <title>Allow Everything</title>
22
+ </all>
23
+ <admin>
24
+ <children>
25
+ <label>
26
+ <title>label</title>
27
+ <sort_order>50</sort_order>
28
+ </label>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <ktree translate="title" module="label">
34
+ <title>ktree Label Section</title>
35
+ </ktree>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ </children>
41
+
42
+ </admin>
43
+ </resources>
44
+ </acl>
45
+ </config>
app/code/local/Ktree/Label/etc/config.xml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ktree_Label>
5
+ <version>0.1.0</version>
6
+ </Ktree_Label>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <label>
12
+ <class>Ktree_Label_Model</class>
13
+ <resourceModel>label_mysql4</resourceModel>
14
+ </label>
15
+ <label_mysql4>
16
+ <class>Ktree_Label_Model_Mysql4</class>
17
+ <entities>
18
+ <label>
19
+ <table>label</table>
20
+ </label>
21
+ </entities>
22
+ </label_mysql4>
23
+ </models>
24
+
25
+ <blocks>
26
+ <label>
27
+ <class>Ktree_Label_Block</class>
28
+ </label>
29
+ </blocks>
30
+
31
+ <helpers>
32
+ <label>
33
+ <class>Ktree_Label_Helper</class>
34
+ </label>
35
+ </helpers>
36
+
37
+ <resources>
38
+ <label_setup>
39
+ <setup>
40
+ <module>Ktree_Label</module>
41
+ </setup>
42
+ <connection>
43
+ <use>core_setup</use>
44
+ </connection>
45
+ </label_setup>
46
+ <label_write>
47
+ <connection>
48
+ <use>core_write</use>
49
+ </connection>
50
+ </label_write>
51
+ <label_read>
52
+ <connection>
53
+ <use>core_read</use>
54
+ </connection>
55
+ </label_read>
56
+ </resources>
57
+ </global>
58
+
59
+ <admin>
60
+ <routers>
61
+ <adminhtml>
62
+ <args>
63
+ <modules>
64
+ <label after="Mage_Adminhtml">Ktree_Label_Adminhtml</label>
65
+ </modules>
66
+ </args>
67
+ </adminhtml>
68
+ </routers>
69
+ </admin>
70
+
71
+ <adminhtml>
72
+ <layout>
73
+ <updates>
74
+ <label>
75
+ <file>label.xml</file>
76
+ </label>
77
+ </updates>
78
+ </layout>
79
+ <translate>
80
+ <modules>
81
+ <Ktree_Label>
82
+ <files>
83
+ <default>Ktree_Label.csv</default>
84
+ </files>
85
+ </Ktree_Label>
86
+ </modules>
87
+ </translate>
88
+ </adminhtml>
89
+
90
+ <frontend>
91
+ <routers>
92
+ <label>
93
+ <use>standard</use>
94
+ <args>
95
+ <module>Ktree_Label</module>
96
+ <frontName>labels</frontName>
97
+ </args>
98
+ </label>
99
+ </routers>
100
+ <layout>
101
+ <updates>
102
+ <label>
103
+ <file>label.xml</file>
104
+ </label>
105
+ </updates>
106
+ </layout>
107
+ <translate>
108
+ <modules>
109
+ <Ktree_Label>
110
+ <files>
111
+ <default>Ktree_Label.csv</default>
112
+ </files>
113
+ </Ktree_Label>
114
+ </modules>
115
+ </translate>
116
+ </frontend>
117
+ </config>
app/code/local/Ktree/Label/sql/label_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $table = $installer->getTable('label');
8
+
9
+ $installer->run("
10
+ create table IF NOT EXISTS {$table} (
11
+ label_id int(11) unsigned not null auto_increment,
12
+ label_text varchar(50) not null default '',
13
+ label_productskus varchar(50) not null default '',
14
+ label_img varchar(128) default NULL,
15
+ label_position varchar(128) NOT NULL default '',
16
+ store_id varchar(10) NOT NULL default '',
17
+ PRIMARY KEY(label_id)
18
+ ) engine=InnoDB default charset=utf8;
19
+ ");
20
+
21
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/label.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="1.0.0">
3
+
4
+ <adminhtml_label_index>
5
+ <reference name="content">
6
+ <block type="label/adminhtml_label" name="label" />
7
+ </reference>
8
+ </adminhtml_label_index>
9
+
10
+ </layout>
app/design/frontend/base/default/template/label/list.phtml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 base_default
23
+ * @copyright Copyright (c) 2012 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
+ <?php
28
+ /**
29
+ * Product list template
30
+ *
31
+ * @see Mage_Catalog_Block_Product_List
32
+ */
33
+ ?>
34
+ <?php
35
+ $_productCollection=$this->getLoadedProductCollection();
36
+ $_helper = $this->helper('catalog/output');
37
+ ?>
38
+ <?php if(!$_productCollection->count()): ?>
39
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
40
+ <?php else: ?>
41
+ <div class="category-products">
42
+ <?php echo $this->getToolbarHtml() ?>
43
+ <?php // List mode
44
+
45
+ ?>
46
+ <?php if($this->getMode()!='grid'): ?>
47
+ <?php $_iterator = 0; ?>
48
+ <ol class="products-list" id="products-list">
49
+ <?php foreach ($_productCollection as $_product): ?>
50
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
51
+
52
+ <div class="ktree-label-div" style="position: relative;">
53
+ <?php // Product Image
54
+ $_productsku=$_product->getSku(); ?>
55
+ <?php echo Mage::helper('label')->getProductLabels($_productsku) ?>
56
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
57
+ </div>
58
+
59
+
60
+ <?php // Product description ?>
61
+ <div class="product-shop">
62
+ <div class="f-fix">
63
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
64
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
65
+ <?php if($_product->getRatingSummary()): ?>
66
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
67
+ <?php endif; ?>
68
+ <?php echo $this->getPriceHtml($_product, true) ?>
69
+ <?php if($_product->isSaleable()): ?>
70
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
71
+ <?php else: ?>
72
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
73
+ <?php endif; ?>
74
+ <div class="desc std">
75
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
76
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
77
+ </div>
78
+ <ul class="add-to-links">
79
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
80
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
81
+ <?php endif; ?>
82
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
83
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
84
+ <?php endif; ?>
85
+ </ul>
86
+ </div>
87
+ </div>
88
+ </li>
89
+ <?php endforeach; ?>
90
+ </ol>
91
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
92
+
93
+ <?php else: ?>
94
+
95
+ <?php // Grid Mode ?>
96
+ <?php $_collectionSize = $_productCollection->count() ?>
97
+ <?php $_columnCount = $this->getColumnCount(); ?>
98
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
99
+
100
+ <?php if ($i++%$_columnCount==0): ?>
101
+ <ul class="products-grid">
102
+ <?php endif ?>
103
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
104
+ <div class="ktree-label-div" style="position: relative;">
105
+ <?php $_productsku=$_product->getSku(); ?>
106
+ <?php echo Mage::helper('label')->getProductLabels($_productsku);?>
107
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
108
+ </div>
109
+
110
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
111
+ <?php if($_product->getRatingSummary()): ?>
112
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
113
+ <?php endif; ?>
114
+ <?php echo $this->getPriceHtml($_product, true) ?>
115
+ <div class="actions">
116
+ <?php if($_product->isSaleable()): ?>
117
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
118
+ <?php else: ?>
119
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
120
+ <?php endif; ?>
121
+ <ul class="add-to-links">
122
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
123
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
124
+ <?php endif; ?>
125
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
126
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
127
+ <?php endif; ?>
128
+ </ul>
129
+ </div>
130
+ </li>
131
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
132
+ </ul>
133
+ <?php endif ?>
134
+ <?php endforeach ?>
135
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
136
+ <?php endif; ?>
137
+
138
+ <div class="toolbar-bottom">
139
+ <?php echo $this->getToolbarHtml() ?>
140
+ </div>
141
+ </div>
142
+ <?php endif; ?>
app/design/frontend/base/default/template/label/media.phtml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 base_default
23
+ * @copyright Copyright (c) 2012 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
+ /**
28
+ * Product media data template
29
+ *
30
+ * @see Mage_Catalog_Block_Product_View_Media
31
+ */
32
+ ?>
33
+ <?php
34
+ $_product = $this->getProduct();
35
+ $_helper = $this->helper('catalog/output');
36
+ ?>
37
+ <?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
38
+ <div class="product-image product-image-zoom" style="position: relative;">
39
+
40
+ <?php $_productsku=$_product->getSku(); ?>
41
+ <?php echo Mage::helper('label')->getProductLabels($_productsku,'product');
42
+
43
+ ?>
44
+ <?php
45
+ $_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
46
+ echo $_helper->productAttribute($_product, $_img, 'image');
47
+ ?>
48
+ </div>
49
+ <p class="zoom-notice" id="track_hint"><?php echo $this->__('Double click on above image to view full picture') ?></p>
50
+ <div class="zoom">
51
+ <img id="zoom_out" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_out.gif') ?>" alt="<?php echo $this->__('Zoom Out') ?>" title="<?php echo $this->__('Zoom Out') ?>" class="btn-zoom-out" />
52
+ <div id="track">
53
+ <div id="handle"></div>
54
+ </div>
55
+ <img id="zoom_in" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_in.gif') ?>" alt="<?php echo $this->__('Zoom In') ?>" title="<?php echo $this->__('Zoom In') ?>" class="btn-zoom-in" />
56
+ </div>
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+ Event.observe(window, 'load', function() {
60
+ product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
61
+ });
62
+ //]]>
63
+ </script>
64
+ <?php else: ?>
65
+ <p class="product-image">
66
+ <?php
67
+ $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
68
+ echo $_helper->productAttribute($_product, $_img, 'image');
69
+ ?>
70
+ </p>
71
+ <?php endif; ?>
72
+ <?php if (count($this->getGalleryImages()) > 0): ?>
73
+ <div class="more-views">
74
+ <h2><?php echo $this->__('More Views') ?></h2>
75
+ <ul>
76
+ <?php foreach ($this->getGalleryImages() as $_image): ?>
77
+ <li>
78
+ <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
79
+ </li>
80
+ <?php endforeach; ?>
81
+ </ul>
82
+ </div>
83
+ <?php endif; ?>
app/etc/modules/Ktree_Label.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Ktree_Label>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Ktree_Label>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ktree_Labels</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSLv3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Product Labels which will Show discount and latest product info using Customized Images</summary>
10
+ <description>Product Labels which will Show discount and latest product info using Customized Images</description>
11
+ <notes>Product Labels which will Show discount and latest product info using Customized Images</notes>
12
+ <authors><author><name>KTree</name><user>KTree</user><email>magento@ktree.com</email></author></authors>
13
+ <date>2015-01-22</date>
14
+ <time>05:10:31</time>
15
+ <contents><target name="magelocal"><dir name="Ktree"><dir name="Label"><dir name="Block"><dir name="Adminhtml"><dir name="Label"><dir name="Edit"><file name="Form.php" hash="6aa0fc9e39d5eafbefdbb008f8c9a8f1"/></dir><file name="Edit.php" hash="2779964c1a360a47b9f6ac6666ad8773"/><file name="Grid.php" hash="d0b9740fe927c488568d683e0a06eb9b"/></dir><file name="Label.php" hash="9b3c0fbd6feb53db16591b2890114edf"/></dir><file name="Label.php" hash="faddec1409b956f11a358b71734b464f"/></dir><dir name="Helper"><file name="Data.php" hash="6f4e695244b3693838a45668a87fb1c6"/></dir><dir name="Model"><file name="Label.php" hash="67558da2be6ca0c5e0de3f4a493162d7"/><dir name="Mysql4"><dir name="Label"><file name="Collection.php" hash="d8036cf9dcf6eca04c44f7d830c84b94"/></dir><file name="Label.php" hash="1be1051178f98f92ed4243f9f1463af9"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LabelController.php" hash="b33b95ecb0c6348c9fff6eb8c364ca11"/></dir><file name="IndexController.php" hash="e7b7ea0f3a52be7314ca943aee922ad1"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a7a9e09759b86ef3f517a8e05a10316e"/><file name="config.xml" hash="6b864c175a4eb2b1839c96461fc73bb5"/></dir><dir name="sql"><dir name="label_setup"><file name="mysql4-install-0.1.0.php" hash="a84c60442ff0133c6785033f6aed31e2"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="label.xml" hash=""/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="label.xml" hash="aaaa29aa743309e83c80bb5f830850a4"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="label"><file name="list.phtml" hash="380f8108dfda48fddb290565fc9da362"/><file name="media.phtml" hash="b1d1c7279924d05418bb4cb90c815038"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ktree_Label.xml" hash="d40c9c5700c75b27e22c192698127ee7"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="ktree-label.css" hash="c82beded5e6f2e77640a4e9516601b90"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/ktree-label.css ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .top-left {
2
+ position: absolute;
3
+ top:-20px;
4
+ }
5
+
6
+ .top-center {
7
+ position: absolute;
8
+ top:-20px;
9
+ left:25px
10
+ }
11
+ .top-right {
12
+ position: absolute;
13
+ top:-20px;
14
+ right:0px;
15
+ }
16
+ .middle-left {
17
+ left: 0;
18
+ position: absolute;
19
+ top: 30px;
20
+ }
21
+ .middle-center {
22
+ left: 25px;
23
+ position: absolute;
24
+ top: 30px;
25
+ }
26
+ .middle-right {
27
+ right: 0px;
28
+ position: absolute;
29
+ top: 30px;
30
+ }
31
+ .bottom-left {
32
+ bottom: -25px;
33
+ left: -2px;
34
+ position: absolute;
35
+ }
36
+ .bottom-center {
37
+ bottom: -25px;
38
+ left: 25px;
39
+ position: absolute;
40
+ }
41
+ .bottom-right {
42
+ bottom: -20px;
43
+ position: absolute;
44
+ right: 0;
45
+ }
46
+ .product-bottom-left {
47
+ position: relative;
48
+ bottom: -200px;
49
+ z-index: 999;
50
+ }
51
+ .product-bottom-center {
52
+ bottom: -200px;
53
+ right: -100px;
54
+ position: relative;
55
+ z-index: 999;
56
+ }
57
+ .product-bottom-right {
58
+ bottom: -300px;
59
+ position: relative;
60
+ z-index: 999;
61
+ right: -220px;
62
+ }
63
+ .product-top-left {
64
+ bottom: 0;
65
+ position: relative;
66
+ right: 0;
67
+ z-index: 999;
68
+ }
69
+ .product-top-center {
70
+ bottom: 0;
71
+ right: -100px;
72
+ z-index: 999;
73
+ position: relative;
74
+ }
75
+ .product-top-right {
76
+ bottom: 0;
77
+ position: relative;
78
+ right: -160px;
79
+ z-index: 999;
80
+ }
81
+ .product-middle-left {
82
+ bottom: -100px;
83
+ position: relative;
84
+ right: 0;
85
+ z-index: 999;
86
+ }
87
+ .product-middle-center {
88
+ bottom: -100px;
89
+ right: -100px;
90
+ z-index: 999;
91
+ position: relative;
92
+ }
93
+ .product-middle-right {
94
+ bottom: -100px;
95
+ position: relative;
96
+ right: -160px;
97
+ z-index: 999;
98
+ }