manufacturer_brand_logo - Version 1.1.1

Version Notes

Depends on the manufacturer attribute.

Download this release

Release Info

Developer Biztech
Extension manufacturer_brand_logo
Version 1.1.1
Comparing to
See all releases


Version 1.1.1

Files changed (25) hide show
  1. app/code/local/Bc/Manufacturer/Block/Adminhtml/Grid/Renderer1/Image.php +15 -0
  2. app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer.php +12 -0
  3. app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit.php +45 -0
  4. app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit/Form.php +19 -0
  5. app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit/Tab/Form.php +89 -0
  6. app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit/Tabs.php +24 -0
  7. app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Grid.php +137 -0
  8. app/code/local/Bc/Manufacturer/Block/Manufacturer.php +17 -0
  9. app/code/local/Bc/Manufacturer/Helper/Data.php +6 -0
  10. app/code/local/Bc/Manufacturer/Model/Manufacturer.php +10 -0
  11. app/code/local/Bc/Manufacturer/Model/Mysql4/Manufacturer.php +10 -0
  12. app/code/local/Bc/Manufacturer/Model/Mysql4/Manufacturer/Collection.php +10 -0
  13. app/code/local/Bc/Manufacturer/Model/Status.php +15 -0
  14. app/code/local/Bc/Manufacturer/controllers/Adminhtml/ManufacturerController.php +243 -0
  15. app/code/local/Bc/Manufacturer/controllers/IndexController.php +47 -0
  16. app/code/local/Bc/Manufacturer/etc/adminhtml.xml +63 -0
  17. app/code/local/Bc/Manufacturer/etc/config.xml +120 -0
  18. app/code/local/Bc/Manufacturer/sql/manufacturer_setup/mysql4-install-0.1.0.php +23 -0
  19. app/design/adminhtml/default/default/layout/manufacturer.xml +8 -0
  20. app/design/frontend/base/default/layout/manufacturer.xml +10 -0
  21. app/design/frontend/base/default/template/manufacturer/manufacturer.phtml +88 -0
  22. app/design/frontend/base/default/template/manufacturer/manufacturer_resize.phtml +25 -0
  23. app/design/frontend/base/default/template/manufacturer/product_manufacturer.phtml +18 -0
  24. app/etc/modules/Bc_Manufacturer.xml +9 -0
  25. package.xml +42 -0
app/code/local/Bc/Manufacturer/Block/Adminhtml/Grid/Renderer1/Image.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Block_Adminhtml_Grid_Renderer1_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ public function render(Varien_Object $row)
6
+ {
7
+ if($row->getdata('filename')==""){
8
+ return "";
9
+ }
10
+ else{
11
+ //you can also use some resizer here...
12
+ return "<img src='".Mage::getBaseUrl("media")."/Manufacturer/".$row->getdata('filename')."' width='75' height='75'/>";
13
+ }
14
+ }
15
+ }
app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bc_Manufacturer_Block_Adminhtml_Manufacturer extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_manufacturer';
7
+ $this->_blockGroup = 'manufacturer';
8
+ $this->_headerText = Mage::helper('manufacturer')->__('Manufacturer Manager');
9
+ $this->_addButtonLabel = Mage::helper('manufacturer')->__('Add Manufacturer');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Block_Adminhtml_Manufacturer_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 = 'manufacturer';
11
+ $this->_controller = 'adminhtml_manufacturer';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('manufacturer')->__('Save Manufacturer'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('manufacturer')->__('Delete Manufacturer'));
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('manufacturer_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'manufacturer_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'manufacturer_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('manufacturer_data') && Mage::registry('manufacturer_data')->getId() ) {
40
+ return Mage::helper('manufacturer')->__("Edit Manufacturer"); //'%s'", $this->htmlEscape(Mage::registry('manufacturer_data')->getMenufecturerName()));
41
+ } else {
42
+ return Mage::helper('manufacturer')->__('Add Manufacturer');
43
+ }
44
+ }
45
+ }
app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Block_Adminhtml_Manufacturer_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/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit/Tab/Form.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Block_Adminhtml_Manufacturer_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('manufacturer_form', array('legend'=>Mage::helper('manufacturer')->__('Manufacturer information')));
10
+ //get Manufecturer's Attribut options
11
+ //DebugBreak();
12
+ $attribute_code=Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', "manufacturer");
13
+ $attributeInfo = Mage::getModel('eav/entity_attribute')->load($attribute_code);
14
+ $attribute_table = Mage::getModel('eav/entity_attribute_source_table')->setAttribute($attributeInfo);
15
+ $attributeOptions = $attribute_table->getAllOptions(false);
16
+ $default=array('value'=>'','label'=>'Choose Brand');
17
+ $i=0;
18
+ $manufacturer[$i]=$default;
19
+ foreach($attributeOptions as $key=>$value){
20
+ $i++;
21
+ $manufacturer[$i]=$value;
22
+ }
23
+ //End
24
+ $fieldset->addField('menufecturer_name', 'select', array(
25
+ 'label' => Mage::helper('manufacturer')->__('Select Manufacturer'),
26
+ 'class' => 'required-entry',
27
+ 'required' => true,
28
+ 'name' => 'menufecturer_name',
29
+ 'values' =>$manufacturer,
30
+ ));
31
+
32
+
33
+ //At the time of insert of manufacturer the image uploaded is reqired
34
+ //While time of Edit the control can be blank
35
+ if(Mage::registry('manufacturer_data')->getData('filename')!=""){
36
+ $fieldset->addField('filename', 'file', array(
37
+ 'label' => Mage::helper('manufacturer/data')->__('Brand Logo'),
38
+ 'required' => false,
39
+ 'name' => 'filename',
40
+ 'after_element_html' => Mage::registry('manufacturer_data')->getData('filename') != "" ? '<span class="hint"><img src="'.Mage::getBaseUrl('media')."Manufacturer/".Mage::registry('manufacturer_data')->getData('filename').'" width="25" height="25" name="manufacturer_image" style="vertical-align: middle;" /></span>':'',
41
+ ));
42
+ }else{
43
+ $fieldset->addField('filename', 'file', array(
44
+ 'label' => Mage::helper('manufacturer/data')->__('Brand Logo'),
45
+ 'class' => 'required-entry',
46
+ 'required' => true,
47
+ 'name' => 'filename',
48
+ 'after_element_html' => Mage::registry('manufacturer_data')->getData('filename') != "" ? '<span class="hint"><img src="'.Mage::getBaseUrl('media')."Manufacturer/".Mage::registry('manufacturer_data')->getData('filename').'" width="25" height="25" name="manufacturer_image" style="vertical-align: middle;" /></span>':'',
49
+ ));
50
+ }
51
+ //<br/><input type="checkbox" name="image_chk" id="image_chk"/><label for="image_chk"> Delete Image</label>
52
+
53
+ $fieldset->addField('status', 'select', array(
54
+ 'label' => Mage::helper('manufacturer')->__('Status'),
55
+ 'name' => 'status',
56
+ 'values' => array(
57
+ array(
58
+ 'value' => 1,
59
+ 'label' => Mage::helper('manufacturer')->__('Enabled'),
60
+ ),
61
+
62
+ array(
63
+ 'value' => 2,
64
+ 'label' => Mage::helper('manufacturer')->__('Disabled'),
65
+ ),
66
+ ),
67
+ ));
68
+
69
+
70
+
71
+ /*$fieldset->addField('content', 'editor', array(
72
+ 'name' => 'content',
73
+ 'label' => Mage::helper('manufacturer')->__('Content'),
74
+ 'title' => Mage::helper('manufacturer')->__('Content'),
75
+ 'style' => 'width:700px; height:500px;',
76
+ 'wysiwyg' => false,
77
+ 'required' => true,
78
+ ));*/
79
+
80
+ if ( Mage::getSingleton('adminhtml/session')->getManufacturerData() )
81
+ {
82
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getManufacturerData());
83
+ Mage::getSingleton('adminhtml/session')->setManufacturerData(null);
84
+ } elseif ( Mage::registry('manufacturer_data') ) {
85
+ $form->setValues(Mage::registry('manufacturer_data')->getData());
86
+ }
87
+ return parent::_prepareForm();
88
+ }
89
+ }
app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Block_Adminhtml_Manufacturer_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('manufacturer_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('manufacturer')->__('Manufacturer Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('manufacturer')->__('Manufacturer Information'),
18
+ 'title' => Mage::helper('manufacturer')->__('Manufacturer Information'),
19
+ 'content' => $this->getLayout()->createBlock('manufacturer/adminhtml_manufacturer_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Bc/Manufacturer/Block/Adminhtml/Manufacturer/Grid.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Block_Adminhtml_Manufacturer_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('manufacturerGrid');
9
+ $this->setDefaultSort('manufacturer_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('manufacturer/manufacturer')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('manufacturer_id', array(
24
+ 'header' => Mage::helper('manufacturer')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'manufacturer_id',
28
+ ));
29
+
30
+ //get Manufecturer's Attribut options
31
+ $attribute_code=Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', "manufacturer");
32
+ $attributeInfo = Mage::getModel('eav/entity_attribute')->load($attribute_code);
33
+ $attribute_table = Mage::getModel('eav/entity_attribute_source_table')->setAttribute($attributeInfo);
34
+ $attributeOptions = $attribute_table->getAllOptions(false);
35
+ foreach($attributeOptions as $key=>$value){
36
+ $manufacturer[$value['value']]=$value['label'];
37
+ }
38
+ //End
39
+ $this->addColumn('menufecturer_name', array(
40
+ 'header' => Mage::helper('manufacturer')->__('Manufacturer Name'),
41
+ 'align' =>'left',
42
+ 'index' =>'menufecturer_name',
43
+ 'type' =>'options',
44
+ 'options' =>$manufacturer,
45
+ ));
46
+
47
+ $this->addColumn('filename', array(
48
+ 'header' => Mage::helper('manufacturer')->__('Thumbnail'),
49
+ 'renderer' => 'manufacturer/adminhtml_grid_renderer1_image',
50
+ 'filter'=>false,
51
+ 'align' =>'left',
52
+ 'type' => 'image',
53
+ 'width' => '100px',
54
+ 'index' => 'filename',
55
+ ));
56
+
57
+ /*
58
+ $this->addColumn('content', array(
59
+ 'header' => Mage::helper('manufacturer')->__('Item Content'),
60
+ 'width' => '150px',
61
+ 'index' => 'content',
62
+ ));
63
+ */
64
+
65
+ $this->addColumn('status', array(
66
+ 'header' => Mage::helper('manufacturer')->__('Status'),
67
+ 'align' => 'left',
68
+ 'width' => '80px',
69
+ 'index' => 'status',
70
+ 'type' => 'options',
71
+ 'options' => array(
72
+ 1 => 'Enabled',
73
+ 2 => 'Disabled',
74
+ ),
75
+ ));
76
+
77
+ $this->addColumn('action',
78
+ array(
79
+ 'header' => Mage::helper('manufacturer')->__('Action'),
80
+ 'width' => '100',
81
+ 'type' => 'action',
82
+ 'getter' => 'getId',
83
+ 'actions' => array(
84
+ array(
85
+ 'caption' => Mage::helper('manufacturer')->__('Edit'),
86
+ 'url' => array('base'=> '*/*/edit'),
87
+ 'field' => 'id'
88
+ )
89
+ ),
90
+ 'filter' => false,
91
+ 'sortable' => false,
92
+ 'index' => 'stores',
93
+ 'is_system' => true,
94
+ ));
95
+
96
+ //$this->addExportType('*/*/exportCsv', Mage::helper('manufacturer')->__('CSV'));
97
+ //$this->addExportType('*/*/exportXml', Mage::helper('manufacturer')->__('XML'));
98
+
99
+ return parent::_prepareColumns();
100
+ }
101
+
102
+ protected function _prepareMassaction()
103
+ {
104
+ $this->setMassactionIdField('manufacturer_id');
105
+ $this->getMassactionBlock()->setFormFieldName('manufacturer');
106
+
107
+ $this->getMassactionBlock()->addItem('delete', array(
108
+ 'label' => Mage::helper('manufacturer')->__('Delete'),
109
+ 'url' => $this->getUrl('*/*/massDelete'),
110
+ 'confirm' => Mage::helper('manufacturer')->__('Are you sure?')
111
+ ));
112
+
113
+ $statuses = Mage::getSingleton('manufacturer/status')->getOptionArray();
114
+
115
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
116
+ $this->getMassactionBlock()->addItem('status', array(
117
+ 'label'=> Mage::helper('manufacturer')->__('Change status'),
118
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
119
+ 'additional' => array(
120
+ 'visibility' => array(
121
+ 'name' => 'status',
122
+ 'type' => 'select',
123
+ 'class' => 'required-entry',
124
+ 'label' => Mage::helper('manufacturer')->__('Status'),
125
+ 'values' => $statuses
126
+ )
127
+ )
128
+ ));
129
+ return $this;
130
+ }
131
+
132
+ public function getRowUrl($row)
133
+ {
134
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
135
+ }
136
+
137
+ }
app/code/local/Bc/Manufacturer/Block/Manufacturer.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bc_Manufacturer_Block_Manufacturer extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getManufacturer()
10
+ {
11
+ if (!$this->hasData('manufacturer')) {
12
+ $this->setData('manufacturer', Mage::registry('manufacturer'));
13
+ }
14
+ return $this->getData('manufacturer');
15
+
16
+ }
17
+ }
app/code/local/Bc/Manufacturer/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Bc/Manufacturer/Model/Manufacturer.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Model_Manufacturer extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('manufacturer/manufacturer');
9
+ }
10
+ }
app/code/local/Bc/Manufacturer/Model/Mysql4/Manufacturer.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Model_Mysql4_Manufacturer extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the manufacturer_id refers to the key field in your database table.
8
+ $this->_init('manufacturer/manufacturer', 'manufacturer_id');
9
+ }
10
+ }
app/code/local/Bc/Manufacturer/Model/Mysql4/Manufacturer/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Model_Mysql4_Manufacturer_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('manufacturer/manufacturer');
9
+ }
10
+ }
app/code/local/Bc/Manufacturer/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('manufacturer')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('manufacturer')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Bc/Manufacturer/controllers/Adminhtml/ManufacturerController.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bc_Manufacturer_Adminhtml_ManufacturerController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('manufacturer/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manufacturer Manager'), Mage::helper('adminhtml')->__('Manufacturer Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('manufacturer/manufacturer')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('manufacturer_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('manufacturer/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manufacturer Manager'), Mage::helper('adminhtml')->__('Manufacturer Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manufacturer News'), Mage::helper('adminhtml')->__('Manufacturer News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('manufacturer/adminhtml_manufacturer_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('manufacturer/adminhtml_manufacturer_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('manufacturer')->__('Manufacturer does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+ $data = $this->getRequest()->getPost();
55
+ //DebugBreak();
56
+ //If the manufacturer already exits or not
57
+ $collection=Mage::getModel('manufacturer/manufacturer')->getCollection()->addFieldToFilter('menufecturer_name',$data['menufecturer_name']);
58
+ $manufacturer_data=$collection->getData();
59
+ if(count($collection)>0 && $manufacturer_data[0]['status']==1 && $this->getRequest()->getParam('id')!=$manufacturer_data[0]['manufacturer_id']){
60
+ $this->_forward('edit');
61
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Manufacturer Already Exists'));
62
+
63
+ //Mage::getSingleton('adminhtml/session')->setFormData(false);
64
+ }else{
65
+ if ($data) {
66
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
67
+ try {
68
+ /* Starting upload */
69
+ $uploader = new Varien_File_Uploader('filename');
70
+
71
+ // Any extention would work
72
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
73
+ $uploader->setAllowRenameFiles(false);
74
+
75
+ // Set the file upload mode
76
+ // false -> get the file directly in the specified folder
77
+ // true -> get the file in the product like folders
78
+ // (file.jpg will go in something like /media/f/i/file.jpg)
79
+ $uploader->setFilesDispersion(false);
80
+
81
+ // We set media/Manufacturer as the upload dir
82
+ $path = Mage::getBaseDir('media') . DS ."Manufacturer". DS ;
83
+ $uploader->save($path, $_FILES['filename']['name']);
84
+
85
+ } catch (Exception $e) {
86
+
87
+ }
88
+
89
+ //If the uploaded file is not image it will mnot allow to save manufacturer
90
+ $fileName=$_FILES['filename']['name'];
91
+ $fileName=explode(".", $fileName);
92
+ //this way the name is saved in DB
93
+ try{
94
+ if($uploader->chechAllowedExtension($fileName[1]))
95
+ $data['filename'] = $_FILES['filename']['name'];
96
+ else{
97
+ Mage::getSingleton('adminhtml/session')->addError("Upload Image Files Only");
98
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
99
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
100
+ return;
101
+ }
102
+ }catch (Exception $e) {
103
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
104
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
105
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
106
+ return;
107
+ }
108
+
109
+ }
110
+
111
+
112
+ $model = Mage::getModel('manufacturer/manufacturer');
113
+ $model->setData($data)
114
+ ->setId($this->getRequest()->getParam('id'));
115
+
116
+ try {
117
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
118
+ $model->setCreatedTime(now())
119
+ ->setUpdateTime(now());
120
+ } else {
121
+ $model->setUpdateTime(now());
122
+ }
123
+
124
+ $model->save();
125
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('manufacturer')->__('Manufacturer was successfully saved'));
126
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
127
+
128
+ if ($this->getRequest()->getParam('back')) {
129
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
130
+ return;
131
+ }
132
+ $this->_redirect('*/*/');
133
+ return;
134
+ } catch (Exception $e) {
135
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
136
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
137
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
138
+ return;
139
+ }
140
+ }
141
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('manufacturer')->__('Unable to find manufacturer to save'));
142
+ $this->_redirect('*/*/');
143
+ }
144
+ }
145
+
146
+ public function deleteAction() {
147
+ if( $this->getRequest()->getParam('id') > 0 ) {
148
+ try {
149
+ $model = Mage::getModel('manufacturer/manufacturer');
150
+
151
+ $model->setId($this->getRequest()->getParam('id'))
152
+ ->delete();
153
+
154
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Manufacturer was successfully deleted'));
155
+ $this->_redirect('*/*/');
156
+ } catch (Exception $e) {
157
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
158
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
159
+ }
160
+ }
161
+ $this->_redirect('*/*/');
162
+ }
163
+
164
+ public function massDeleteAction() {
165
+ $manufacturerIds = $this->getRequest()->getParam('manufacturer');
166
+ if(!is_array($manufacturerIds)) {
167
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
168
+ } else {
169
+ try {
170
+ foreach ($manufacturerIds as $manufacturerId) {
171
+ $manufacturer = Mage::getModel('manufacturer/manufacturer')->load($manufacturerId);
172
+ $manufacturer->delete();
173
+ }
174
+ Mage::getSingleton('adminhtml/session')->addSuccess(
175
+ Mage::helper('adminhtml')->__(
176
+ 'Total of %d record(s) were successfully deleted', count($manufacturerIds)
177
+ )
178
+ );
179
+ } catch (Exception $e) {
180
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
181
+ }
182
+ }
183
+ $this->_redirect('*/*/index');
184
+ }
185
+
186
+ public function massStatusAction()
187
+ {
188
+ $manufacturerIds = $this->getRequest()->getParam('manufacturer');
189
+ if(!is_array($manufacturerIds)) {
190
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
191
+ } else {
192
+ try {
193
+ foreach ($manufacturerIds as $manufacturerId) {
194
+ $manufacturer = Mage::getSingleton('manufacturer/manufacturer')
195
+ ->load($manufacturerId)
196
+ ->setStatus($this->getRequest()->getParam('status'))
197
+ ->setIsMassupdate(true)
198
+ ->save();
199
+ }
200
+ $this->_getSession()->addSuccess(
201
+ $this->__('Total of %d record(s) were successfully updated', count($manufacturerIds))
202
+ );
203
+ } catch (Exception $e) {
204
+ $this->_getSession()->addError($e->getMessage());
205
+ }
206
+ }
207
+ $this->_redirect('*/*/index');
208
+ }
209
+
210
+ public function exportCsvAction()
211
+ {
212
+ $fileName = 'manufacturer.csv';
213
+ $content = $this->getLayout()->createBlock('manufacturer/adminhtml_manufacturer_grid')
214
+ ->getCsv();
215
+
216
+ $this->_sendUploadResponse($fileName, $content);
217
+ }
218
+
219
+ public function exportXmlAction()
220
+ {
221
+ $fileName = 'manufacturer.xml';
222
+ $content = $this->getLayout()->createBlock('manufacturer/adminhtml_manufacturer_grid')
223
+ ->getXml();
224
+
225
+ $this->_sendUploadResponse($fileName, $content);
226
+ }
227
+
228
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
229
+ {
230
+ $response = $this->getResponse();
231
+ $response->setHeader('HTTP/1.1 200 OK','');
232
+ $response->setHeader('Pragma', 'public', true);
233
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
234
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
235
+ $response->setHeader('Last-Modified', date('r'));
236
+ $response->setHeader('Accept-Ranges', 'bytes');
237
+ $response->setHeader('Content-Length', strlen($content));
238
+ $response->setHeader('Content-type', $contentType);
239
+ $response->setBody($content);
240
+ $response->sendResponse();
241
+ die;
242
+ }
243
+ }
app/code/local/Bc/Manufacturer/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bc_Manufacturer_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/manufacturer?id=15
11
+ * or
12
+ * http://site.com/manufacturer/id/15
13
+ */
14
+ /*
15
+ $manufacturer_id = $this->getRequest()->getParam('id');
16
+
17
+ if($manufacturer_id != null && $manufacturer_id != '') {
18
+ $manufacturer = Mage::getModel('manufacturer/manufacturer')->load($manufacturer_id)->getData();
19
+ } else {
20
+ $manufacturer = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($manufacturer == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $manufacturerTable = $resource->getTableName('manufacturer');
32
+
33
+ $select = $read->select()
34
+ ->from($manufacturerTable,array('manufacturer_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $manufacturer = $read->fetchRow($select);
39
+ }
40
+ Mage::register('manufacturer', $manufacturer);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Bc/Manufacturer/etc/adminhtml.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Bc
5
+ * @package Bc_Font
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <menu>
12
+ <manufacturer module="manufacturer">
13
+ <title>Manufacturer</title>
14
+ <sort_order>71</sort_order>
15
+ <children>
16
+ <logo module="manufacturer">
17
+ <title>Manage Manufacturer</title>
18
+ <sort_order>0</sort_order>
19
+ <action>manufacturer/adminhtml_manufacturer</action>
20
+ </logo>
21
+ </children>
22
+ </manufacturer>
23
+ </menu>
24
+ <acl>
25
+ <resources>
26
+ <all>
27
+ <title>Allow Everything</title>
28
+ </all>
29
+ <admin>
30
+ <children>
31
+ <manufacturer>
32
+ <title>Manufacturer Module</title>
33
+ <sort_order>10</sort_order>
34
+ </manufacturer>
35
+ <system>
36
+ <children>
37
+ <config>
38
+ <children>
39
+ <logo translate="title" module="manufacturer">
40
+ <title>Logo uplaod</title>
41
+ <sort_order>100</sort_order>
42
+ </logo>
43
+ <logo1 translate="title" module="manufacturer">
44
+ <title>Logo uplaod1</title>
45
+ <sort_order>60</sort_order>
46
+ </logo1>
47
+ </children>
48
+ </config>
49
+ </children>
50
+ </system>
51
+ </children>
52
+ </admin>
53
+ </resources>
54
+ </acl>
55
+ <layout>
56
+ <updates>
57
+ <manufacturer>
58
+ <file>manufacturer.xml</file>
59
+ </manufacturer>
60
+ </updates>
61
+ </layout>
62
+
63
+ </config>
app/code/local/Bc/Manufacturer/etc/config.xml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bc_Manufacturer>
5
+ <version>0.1.0</version>
6
+ </Bc_Manufacturer>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <manufacturer>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Bc_Manufacturer</module>
14
+ <frontName>manufacturer</frontName>
15
+ </args>
16
+ </manufacturer>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <manufacturer>
21
+ <file>manufacturer.xml</file>
22
+ </manufacturer>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <manufacturer>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Bc_Manufacturer</module>
32
+ <frontName>manufacturer</frontName>
33
+ </args>
34
+ </manufacturer>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <manufacturer module="manufacturer">
40
+ <title>Manufacturer</title>
41
+ <sort_order>71</sort_order>
42
+ <children>
43
+ <items module="manufacturer">
44
+ <title>Manage Items</title>
45
+ <sort_order>0</sort_order>
46
+ <action>manufacturer/adminhtml_manufacturer</action>
47
+ </items>
48
+ </children>
49
+ </manufacturer>
50
+ </menu>
51
+ <acl>
52
+ <resources>
53
+ <all>
54
+ <title>Allow Everything</title>
55
+ </all>
56
+ <admin>
57
+ <children>
58
+ <Bc_Manufacturer>
59
+ <title>Manufacturer Module</title>
60
+ <sort_order>10</sort_order>
61
+ </Bc_Manufacturer>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ <layout>
67
+ <updates>
68
+ <manufacturer>
69
+ <file>manufacturer.xml</file>
70
+ </manufacturer>
71
+ </updates>
72
+ </layout>
73
+ </adminhtml>
74
+ <global>
75
+ <models>
76
+ <manufacturer>
77
+ <class>Bc_Manufacturer_Model</class>
78
+ <resourceModel>manufacturer_mysql4</resourceModel>
79
+ </manufacturer>
80
+ <manufacturer_mysql4>
81
+ <class>Bc_Manufacturer_Model_Mysql4</class>
82
+ <entities>
83
+ <manufacturer>
84
+ <table>manufacturer</table>
85
+ </manufacturer>
86
+ </entities>
87
+ </manufacturer_mysql4>
88
+ </models>
89
+ <resources>
90
+ <manufacturer_setup>
91
+ <setup>
92
+ <module>Bc_Manufacturer</module>
93
+ </setup>
94
+ <connection>
95
+ <use>core_setup</use>
96
+ </connection>
97
+ </manufacturer_setup>
98
+ <manufacturer_write>
99
+ <connection>
100
+ <use>core_write</use>
101
+ </connection>
102
+ </manufacturer_write>
103
+ <manufacturer_read>
104
+ <connection>
105
+ <use>core_read</use>
106
+ </connection>
107
+ </manufacturer_read>
108
+ </resources>
109
+ <blocks>
110
+ <manufacturer>
111
+ <class>Bc_Manufacturer_Block</class>
112
+ </manufacturer>
113
+ </blocks>
114
+ <helpers>
115
+ <manufacturer>
116
+ <class>Bc_Manufacturer_Helper</class>
117
+ </manufacturer>
118
+ </helpers>
119
+ </global>
120
+ </config>
app/code/local/Bc/Manufacturer/sql/manufacturer_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('manufacturer')};
10
+ CREATE TABLE {$this->getTable('manufacturer')} (
11
+ `manufacturer_id` int(11) unsigned NOT NULL auto_increment,
12
+ `menufecturer_name` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`manufacturer_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/manufacturer.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <manufacturer_adminhtml_manufacturer_index>
4
+ <reference name="content">
5
+ <block type="manufacturer/adminhtml_manufacturer" name="manufacturer" />
6
+ </reference>
7
+ </manufacturer_adminhtml_manufacturer_index>
8
+ </layout>
app/design/frontend/base/default/layout/manufacturer.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ </default>
5
+ <manufacturer_index_index>
6
+ <reference name="content">
7
+ <block type="manufacturer/manufacturer" name="manufacturer" template="manufacturer/manufacturer.phtml" />
8
+ </reference>
9
+ </manufacturer_index_index>
10
+ </layout>
app/design/frontend/base/default/template/manufacturer/manufacturer.phtml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This shows how to load specific fields from a record in the database.
4
+ 1) Note the load(15), this corresponds to saying "select * from table where table_id = 15"
5
+ 2) You can then just use the get(fieldname) to pull specific data from the table.
6
+ 3) If you have a field named news_id, then it becomes getNewsId, etc.
7
+ */
8
+ /*
9
+ $news = Mage::getModel('manufacturer/manufacturer')->load(15);
10
+ echo $news->getNewsId();
11
+ echo $news->getTitle();
12
+ echo $news->getContent();
13
+ echo $news->getStatus();
14
+ */
15
+
16
+ /*
17
+ This shows an alternate way of loading datas from a record using the database the "Magento Way" (using blocks and controller).
18
+ Uncomment blocks in /app/code/local/Namespace/Module/controllers/IndexController.php if you want to use it.
19
+
20
+ */
21
+ /*
22
+ $object = $this->getManufacturer();
23
+ echo 'id: '.$object['test_id'].'<br/>';
24
+ echo 'title: '.$object['title'].'<br/>';
25
+ echo 'content: '.$object['content'].'<br/>';
26
+ echo 'status: '.$object['status'].'<br/>';
27
+ */
28
+
29
+
30
+ /*
31
+ This shows how to load multiple rows in a collection and save a change to them.
32
+ 1) The setPageSize function will load only 5 records per page and you can set the current Page with the setCurPage function.
33
+ 2) The $collection->walk('save') allows you to save everything in the collection after all changes have been made.
34
+ */
35
+ /*
36
+ $i = 0;
37
+
38
+ $collection = Mage::getModel('manufacturer/manufacturer')->getCollection();
39
+ $collection->setPageSize(5);
40
+ $collection->setCurPage(2);
41
+ $size = $collection->getSize();
42
+ $cnt = count($collection);
43
+ foreach ($collection as $item) {
44
+ $i = $i+1;
45
+ $item->setTitle($i);
46
+ echo $item->getTitle();
47
+ }
48
+
49
+ $collection->walk('save');
50
+ */
51
+
52
+ /*
53
+ This shows how to load a single record and save a change.
54
+ 1) Note the setTitle, this corresponds to the table field name, title, and then you pass it the text to change.
55
+ 2) Call the save() function only on a single record.
56
+ */
57
+ /*
58
+ $object = Mage::getModel('manufacturer/manufacturer')->load(1);
59
+ $object->setTitle('This is a changed title');
60
+ $object->save();
61
+ */
62
+ ?>
63
+
64
+ <?php
65
+ $maufacturers = Mage::getModel('manufacturer/manufacturer')->getCollection()->addFieldToFilter('status',Array('eq'=>1));
66
+ $_columnCount=4;
67
+ $i=0;
68
+ ?>
69
+ <div class="manufacturer-list">
70
+ <?php foreach($maufacturers as $manufacturer): ?>
71
+ <?php if(Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($manufacturer->getMenufecturerName())): ?>
72
+ <?php if ($i++%$_columnCount==0): ?>
73
+ <ul>
74
+ <?php endif; ?>
75
+ <li>
76
+ <a href="<?php echo $this->getBaseUrl()."catalogsearch/advanced/result/?manufacturer[]=".$manufacturer->getMenufecturerName() ?>">
77
+ <?php echo $this->getLayout()->createBlock('core/template')->setmanufacturerimage($manufacturer->getFilename())->setListPageFlag(1)->setTemplate('manufacturer/manufacturer_resize.phtml')->toHtml(); ?>
78
+ </a>
79
+ <div class="manufacturer-name">
80
+ <?php echo Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($manufacturer->getMenufecturerName()) ?>
81
+ </div>
82
+ </li>
83
+ <?php if ($i%$_columnCount==0 && $i!=count($maufacturers)): ?>
84
+ </ul>
85
+ <?php endif; ?>
86
+ <?php endif; ?>
87
+ <?php endforeach; ?>
88
+ </div>
app/design/frontend/base/default/template/manufacturer/manufacturer_resize.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $manufacturer_imge=$this->getmanufacturerimage();
3
+ $list_page_flag=$this->getListPageFlag();
4
+ ?>
5
+ <?php
6
+ $imageUrl = Mage::getBaseUrl('media')."Manufacturer/".$manufacturer_imge;
7
+ // path of the resized image to be saved
8
+ // here, the resized image is saved in media/resized folder
9
+ $imageResized = Mage::getBaseDir('media').DS."Manufacturer".DS."resized".DS.$manufacturer_imge;
10
+ $dirImg=Mage::getBaseDir().str_replace("/",DS,strstr($imageUrl,'/media'));
11
+
12
+ // resize image only if the image file exists and the resized image file doesn't exist
13
+ // the image is resized proportionally with the width/height 135px
14
+ if (!file_exists($imageResized) && file_exists($dirImg)) :
15
+ $imageObj = new Varien_Image($dirImg);
16
+ $imageObj->constrainOnly(false);
17
+ $imageObj->keepAspectRatio(TRUE);
18
+ $imageObj->keepFrame(false);
19
+ $imageObj->backgroundColor(array(255,255,255));
20
+ $imageObj->resize(229,91);
21
+ $imageObj->save($imageResized);
22
+ endif;
23
+ ?>
24
+ <img src="<?php echo Mage::getBaseUrl('media').'Manufacturer/resized/'.$manufacturer_imge ?>" alt="" class="manufacturer_image" />
25
+
app/design/frontend/base/default/template/manufacturer/product_manufacturer.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ $product=$this->getProduct();
4
+ if(Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($product->getData('manufacturer'))):
5
+ $manufacturers=Mage::getModel('manufacturer/manufacturer')->getCollection()->addFieldToFilter('menufecturer_name',$product->getData('manufacturer'));
6
+ foreach($manufacturers as $manufacturer){
7
+ $status=$manufacturer->getStatus();
8
+ if($status==1){
9
+ ?>
10
+ <div class="manufacturer-img-box">
11
+ <a href="<?php echo $this->getBaseUrl()."catalogsearch/advanced/result/?manufacturer[]=".$manufacturer->getMenufecturerName() ?>">
12
+ <?php echo $this->getLayout()->createBlock('core/template')->setmanufacturerimage($manufacturer->getFilename())->setTemplate('manufacturer/manufacturer_resize.phtml')->toHtml(); ?>
13
+ </a>
14
+ </div>
15
+ <?php }
16
+ }
17
+ endif;
18
+ ?>
app/etc/modules/Bc_Manufacturer.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bc_Manufacturer>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Bc_Manufacturer>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>manufacturer_brand_logo</name>
4
+ <version>1.1.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Extension will allow to upload logo for individual brand from admin panel.</summary>
10
+ <description>&lt;h1&gt;Brand Logo Upload&lt;/h1&gt;&#xD;
11
+ &#xD;
12
+ &lt;p&gt;Extension Key : http://connect20.magentocommerce.com/community/manufacturer&lt;/p&gt;&#xD;
13
+ &#xD;
14
+ &lt;p&gt;Extension will allow to upload logo for individual brand from admin panel. Uploaded brand logo will be display on product detail page as well as brand list page. &lt;/p&gt;&#xD;
15
+ &#xD;
16
+ &lt;p&gt;Guideline to upload brand logo &lt;/p&gt;&#xD;
17
+ &#xD;
18
+ &lt;ul&gt;&#xD;
19
+ &lt;li&gt;Go to Manufacturer &gt; Manage manufacture&lt;/li&gt;&#xD;
20
+ &lt;li&gt;Click Add Manufacturer button&lt;/li&gt;&#xD;
21
+ &lt;li&gt;Choose brand and upload logo for that perticular brand&lt;/li&gt;&#xD;
22
+ &lt;li&gt;Click on Save button and You are done. &lt;/li&gt;&#xD;
23
+ &lt;/ul&gt;&#xD;
24
+ &#xD;
25
+ &#xD;
26
+ &lt;p&gt;Use below code to display brand logo on product detail page &lt;/p&gt;&#xD;
27
+ $this-&gt;getLayout()-&gt;createBlock('manufacturer/manufacturer')-&gt;setProduct($_product)-&gt;setTemplate('manufacturer/product_manufacturer.phtml')-&gt;toHtml();&#xD;
28
+ &#xD;
29
+ &lt;p&gt;&#xD;
30
+ Extension will also provide a block which display all the brand logo list in one page. You can put below code at any place wher you want list to be display.&lt;/p&gt;&#xD;
31
+ &#xD;
32
+ &#xD;
33
+ &#xD;
34
+ &lt;p&gt;&lt;b&gt;Note :&lt;/b&gt; Extension will auto create manufacturer attribute if it will not exists. You need to assing this new attribute to current attribute set which is used to create a products in catalog. Once you will add option to that attribute extension will be available for brand image uplaod. &lt;/p&gt;</description>
35
+ <notes>Depends on the manufacturer attribute.</notes>
36
+ <authors><author><name>Biztech</name><user>biztechcon</user><email>sales@biztechconsultancy.com</email></author></authors>
37
+ <date>2012-06-28</date>
38
+ <time>14:15:21</time>
39
+ <contents><target name="mageetc"><dir name="modules"><file name="Bc_Manufacturer.xml" hash="249a2c05a5a03d448b358c7708d286e7"/></dir></target><target name="magelocal"><dir name="Bc"><dir name="Manufacturer"><dir name="Block"><dir name="Adminhtml"><dir name="Grid"><dir name="Renderer1"><file name="Image.php" hash="1495538d3c82b6f24d481fff93fd1420"/></dir></dir><dir name="Manufacturer"><dir name="Edit"><file name="Form.php" hash="1320621adc17dbfb1b8983659a0a876c"/><dir name="Tab"><file name="Form.php" hash="575f2e28024132c4b2aec26ddb4abb5a"/></dir><file name="Tabs.php" hash="517ebac339c5972144ecbdfd5d36c84a"/></dir><file name="Edit.php" hash="5cf324603cbd50996ff6d988c2a5728e"/><file name="Grid.php" hash="6e2e3e6cb4a63d42386f8593b222c3f8"/></dir><file name="Manufacturer.php" hash="0e14f5e8413ba076e7cdce61a0d12c89"/></dir><file name="Manufacturer.php" hash="e3782cc49c8b2bb9f8c4725d829ca379"/></dir><dir name="Helper"><file name="Data.php" hash="793e861143a0495183031410cfa01cbf"/></dir><dir name="Model"><file name="Manufacturer.php" hash="07a159edce18fa9be0969cc2295988df"/><dir name="Mysql4"><dir name="Manufacturer"><file name="Collection.php" hash="b0ff7e1a7abe2cd2c612fdd4067df99f"/></dir><file name="Manufacturer.php" hash="f8e269187b2dedd3ed3affb582aaef9a"/></dir><file name="Status.php" hash="e702ab395b380899a636fc1ffa8e76eb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ManufacturerController.php" hash="e6433fa99dbd211518526bfc72595f08"/></dir><file name="IndexController.php" hash="96cdf068cb8f579766eda5fb662532c2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="fefcf2e2b0f7b6d4aea9353cab4f8708"/><file name="config.xml" hash="7537a5b235b2e76cc89e6168f9237f56"/></dir><dir name="sql"><dir name="manufacturer_setup"><file name="mysql4-install-0.1.0.php" hash="f7d7c267a8f73b7637d29dc224907bb1"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="manufacturer.xml" hash="5e5ae1543ac26dc7427bd7e6be0b3437"/></dir><dir name="template"><dir name="manufacturer"><file name="manufacturer.phtml" hash=""/><file name="manufacturer_resize.phtml" hash=""/><file name="product_manufacturer.phtml" hash=""/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="manufacturer.xml" hash="6dea17bcb6d2ae8f5fe686ef259b7a7b"/></dir></dir></dir></dir></target></contents>
40
+ <compatible/>
41
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
42
+ </package>