EnhancedProductFeatures - Version 0.0.1

Version Notes

extra_product_options

Download this release

Release Info

Developer adam
Extension EnhancedProductFeatures
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

app/code/local/Bricks/Catalog/Block/Adminhtml/Tab.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Block_Adminhtml_Tab extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+
8
+ $this->setTemplate('bricks/catalog/tab.phtml');
9
+ }
10
+
11
+ protected function _prepareLayout() {
12
+ $this->setChild( 'add_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData( array(
13
+ 'label' => Mage::helper( 'bricks_catalog' )->__( 'Add New Field' ),
14
+ 'class' => 'add',
15
+ 'id' => 'add_new_product_feature'
16
+ ) ) );
17
+
18
+ $this->setChild( 'delete_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData( array(
19
+ 'label' => Mage::helper( 'bricks_catalog' )->__( 'Delete' ),
20
+ 'class' => 'delete delete-bricks-product-feature'
21
+ ) ) );
22
+
23
+ parent::_prepareLayout();
24
+
25
+ if ( Mage::getSingleton( 'cms/wysiwyg_config' )->isEnabled() ) {
26
+ $this->getLayout()->getBlock( 'head' )->setCanLoadTinyMce( true );
27
+ }
28
+
29
+ return $this;
30
+ }
31
+
32
+ public function getTabLabel() {
33
+ return $this->__( 'Product Features' );
34
+ }
35
+
36
+ public function getTabTitle() {
37
+ return $this->__( 'Product Features' );
38
+ }
39
+
40
+ public function canShowTab() {
41
+ return true;
42
+ }
43
+
44
+ public function isHidden() {
45
+ return false;
46
+ }
47
+
48
+ public function getFeatures() {
49
+ $product = Mage::registry('product');
50
+ $results = array();
51
+
52
+ /* @var $features Bricks_Catalog_Model_Resource_Features_Collection */
53
+ $features = Mage::getSingleton('bricks_catalog/features')
54
+ ->getCollection()
55
+ ->addFieldToFilter( 'product_id', $product->getId() )
56
+ ->setOrder( 'sort_order', Mage_Core_Model_Resource_Db_Collection_Abstract::SORT_ORDER_ASC );
57
+ $count = $features->count();
58
+ foreach ( $features as $feature ) {
59
+ /* @var $feature Bricks_Catalog_Model_Features */
60
+ $ret = $feature->getData();
61
+ if ( isset ( $ret['image'] ) && $ret['image'] ) {
62
+ $ret['image'] = '<img src="' . $ret['image'] . '" width="100" height="100" />';
63
+ }
64
+ $ret['item_count'] = $feature->getId();
65
+ $ret['id'] = $feature->getId();
66
+ $ret['title'] = htmlspecialchars( $feature->getTitle(), ENT_QUOTES );
67
+
68
+ array_push($results, $ret);
69
+ }
70
+
71
+ return array_reverse($results);
72
+ }
73
+
74
+ }
app/code/local/Bricks/Catalog/Block/Features.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Block_Features extends Mage_Core_Block_Template {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ }
8
+
9
+ public function getProduct() {
10
+ return Mage::registry('product');
11
+ }
12
+
13
+ public function getFeatures() {
14
+ $results = array();
15
+
16
+ /* @var $features Bricks_Catalog_Model_Resource_Features_Collection */
17
+ $features = Mage::getSingleton('bricks_catalog/features')
18
+ ->getCollection()
19
+ ->addFieldToFilter( 'product_id', $this->getProduct()->getId() )
20
+ ->setOrder( 'sort_order', Mage_Core_Model_Resource_Db_Collection_Abstract::SORT_ORDER_ASC );
21
+ $count = $features->count();
22
+ foreach ( $features as $feature ) {
23
+ /* @var $feature Bricks_Catalog_Model_Features */
24
+ $ret = $feature->getData();
25
+ if ( isset ( $ret['image'] ) && $ret['image'] ) {
26
+ $ret['image'] = '<img src="' . $ret['image'] . '" />';
27
+ }
28
+ $ret['item_count'] = $count;
29
+ $ret['id'] = $feature->getId();
30
+
31
+ array_push($results, $ret);
32
+ }
33
+
34
+ return $results;
35
+ }
36
+
37
+ }
app/code/local/Bricks/Catalog/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Helper_Data extends Mage_Core_Helper_Abstract {
4
+ }
app/code/local/Bricks/Catalog/Model/Features.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Model_Features extends Mage_Core_Model_Abstract {
4
+
5
+ protected function _construct() {
6
+ $this->_init( 'bricks_catalog/features' );
7
+ }
8
+
9
+ }
app/code/local/Bricks/Catalog/Model/Observer.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Model_Observer {
4
+
5
+ public function saveProductFeatures( $observer ) {
6
+ try {
7
+ /* @var $product Mage_Catalog_Model_Product */
8
+ $product = $observer->getEvent()->getProduct();
9
+ $features = $this->_getRequest()->getParam('bricks_pf');
10
+ if ( ! empty( $features ) && is_array( $features ) ) {
11
+ /* @var $model Bricks_Catalog_Model_Features */
12
+ $model = Mage::getModel('bricks_catalog/features');
13
+ foreach ( $features as $key => $feature ) {
14
+ $model->setData( $feature );
15
+
16
+ if ( $model->getData( 'feature_id' ) ) {
17
+ $model->setId( $feature['feature_id'] );
18
+ } else {
19
+ $model->unsetData('feature_id');
20
+ }
21
+
22
+ $isEdit = ( bool ) $model->getId();
23
+
24
+ if ( $model->getData('is_delete') == '1' && $isEdit ) {
25
+ $model->delete();
26
+ } else if ( $model->getData( 'is_delete' ) != '1' ) {
27
+ $fileKey = 'bricks_pf_' . $key;
28
+ if ( isset ( $_FILES[ $fileKey ] ) ) {
29
+ try {
30
+ $uploader = new Varien_File_Uploader( $fileKey );
31
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
32
+ $uploader->setAllowRenameFiles(true);
33
+ $uploader->setFilesDispersion(false);
34
+ $uploader->setAllowCreateFolders(true);
35
+ $path = implode( DS, array( Mage::getBaseDir('media'), 'catalog', 'product', 'features' ) ) . DS;
36
+ $url = implode( DS, array( Mage::getBaseUrl('media'), 'catalog', 'product', 'features' ) ) . DS;
37
+ $uploader->save( $path, $_FILES[$fileKey]['name'] );
38
+ $model->setData( 'image', $url . basename( $uploader->getUploadedFileName() ) );
39
+ } catch ( Exception $ex ) {
40
+ Mage::logException($ex);
41
+ }
42
+ }
43
+
44
+ $model->setData( 'product_id', $product->getId() );
45
+ $model->save();
46
+ }
47
+ }
48
+ }
49
+ } catch ( Exception $e ) {
50
+ Mage::logException($e);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Shortcut to getRequest
56
+ *
57
+ * @return Mage_Core_Controller_Request_Http
58
+ */
59
+ protected function _getRequest() {
60
+ return Mage::app()->getRequest();
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @param Varien_Event_Observer $observer
66
+ */
67
+ public function beforeRenderProductView( $observer ) {
68
+ $layout = $observer->getEvent()->getData( 'layout' );
69
+ /* @var $layout Mage_Core_Model_Layout */
70
+ $xml = $layout->getXmlString();
71
+ $search = '<block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml">';
72
+
73
+ // echo "<pre>";
74
+ // print_r($observer->getEvent()->getLayout()->getUpdate()->asString());
75
+ // echo $xml;
76
+ // exit;
77
+
78
+ $pos = strpos( $xml, $search );
79
+ if ( $pos !== false ) {
80
+ $action = <<<LAYOUT
81
+ <action method="addTab" translate="title" module="bricks_catalog">
82
+ <alias>product_features</alias>
83
+ <title>Product Features</title>
84
+ <block>bricks_catalog/features</block>
85
+ <template>bricks/catalog/features.phtml</template>
86
+ </action>
87
+ LAYOUT;
88
+ $xml = substr_replace( $xml, $search . $action , $pos, strlen( $search ) );
89
+ $layout->setXml( simplexml_load_string( $xml, $layout->getUpdate()->getElementClass() ) );
90
+ }
91
+ }
92
+
93
+ }
app/code/local/Bricks/Catalog/Model/Resource/Features.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Model_Resource_Features extends Mage_Core_Model_Resource_Db_Abstract {
4
+
5
+ protected function _construct() {
6
+ $this->_init( 'bricks_catalog/features', 'feature_id' );
7
+ }
8
+
9
+ }
app/code/local/Bricks/Catalog/Model/Resource/Features/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Model_Resource_Features_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
4
+
5
+ protected function _construct() {
6
+ $this->_init( 'bricks_catalog/features' );
7
+ }
8
+
9
+ }
app/code/local/Bricks/Catalog/Model/Resource/Setup.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ class Bricks_Catalog_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {}
app/code/local/Bricks/Catalog/etc/config.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Bricks_Catalog>
5
+ <version>0.0.1</version>
6
+ </Bricks_Catalog>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <bricks_catalog>
12
+ <class>Bricks_Catalog_Block</class>
13
+ </bricks_catalog>
14
+ </blocks>
15
+
16
+ <helpers>
17
+ <bricks_catalog>
18
+ <class>Bricks_Catalog_Helper</class>
19
+ </bricks_catalog>
20
+ </helpers>
21
+
22
+ <models>
23
+ <bricks_catalog>
24
+ <class>Bricks_Catalog_Model</class>
25
+ <resourceModel>bricks_catalog_resource</resourceModel>
26
+ </bricks_catalog>
27
+
28
+ <bricks_catalog_resource>
29
+ <class>Bricks_Catalog_Model_Resource</class>
30
+ <entities>
31
+ <features>
32
+ <table>bricks_product_features</table>
33
+ </features>
34
+ </entities>
35
+ </bricks_catalog_resource>
36
+ </models>
37
+
38
+ <resources>
39
+ <bricks_catalog_setup>
40
+ <setup>
41
+ <module>Bricks_Catalog</module>
42
+ <class>Bricks_Catalog_Model_Resource_Setup</class>
43
+ </setup>
44
+ </bricks_catalog_setup>
45
+ </resources>
46
+
47
+ <events>
48
+ <catalog_product_save_after>
49
+ <observers>
50
+ <bricks_catalog>
51
+ <type>singleton</type>
52
+ <class>Bricks_Catalog_Model_Observer</class>
53
+ <method>saveProductFeatures</method>
54
+ </bricks_catalog>
55
+ </observers>
56
+ </catalog_product_save_after>
57
+
58
+ <controller_action_layout_generate_blocks_before>
59
+ <observers>
60
+ <bricks_catalog>
61
+ <type>singleton</type>
62
+ <class>Bricks_Catalog_Model_Observer</class>
63
+ <method>beforeRenderProductView</method>
64
+ </bricks_catalog>
65
+ </observers>
66
+ </controller_action_layout_generate_blocks_before>
67
+ </events>
68
+ </global>
69
+
70
+ <adminhtml>
71
+ <layout>
72
+ <updates>
73
+ <bricks_catalog>
74
+ <file>bricks/catalog.xml</file>
75
+ </bricks_catalog>
76
+ </updates>
77
+ </layout>
78
+ </adminhtml>
79
+
80
+ <frontend>
81
+ <layout>
82
+ <updates>
83
+ <bricks_catalog>
84
+ <file>bricks/catalog.xml</file>
85
+ </bricks_catalog>
86
+ </updates>
87
+ </layout>
88
+ </frontend>
89
+ </config>
app/code/local/Bricks/Catalog/sql/bricks_catalog_setup/install-0.0.1.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup();
6
+
7
+ /* @var $adapter Varien_Db_Adapter_Pdo_Mysql */
8
+ $adapter = $installer->getConnection();
9
+
10
+ $descriptions = $adapter->newTable( $installer->getTable( 'bricks_catalog/features' ) );
11
+ $descriptions->addColumn( 'feature_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
12
+ 'identity' => true,
13
+ 'unsigned' => true,
14
+ 'nullable' => false,
15
+ 'primary' => true
16
+ ) )->addColumn( 'product_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
17
+ 'unsigned' => true,
18
+ 'nullable' => false
19
+ ) )->addColumn( 'title', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
20
+ 'nullable' => false
21
+ ) )->addColumn( 'content', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
22
+ 'nullable' => false
23
+ ) )->addColumn( 'image', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
24
+ 'nullable' => false
25
+ ) )->addColumn( 'image_position', Varien_Db_Ddl_Table::TYPE_VARCHAR, 20, array(
26
+ 'nullable' => false
27
+ ) )->addColumn( 'sort_order', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
28
+ 'unsigned' => true,
29
+ 'nullable' => true
30
+ ) )->addIndex( $installer->getIdxName( 'bricks_catalog/features', array( 'product_id' ) ), array( 'product_id' ) );
31
+
32
+ $adapter->createTable( $descriptions );
33
+
34
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/bricks/catalog.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout>
3
+ <adminhtml_catalog_product_edit>
4
+ <reference name="product_tabs">
5
+ <action method="addTab">
6
+ <name>bricks_catalog_tab</name>
7
+ <block>bricks_catalog/adminhtml_tab</block>
8
+ </action>
9
+ </reference>
10
+ </adminhtml_catalog_product_edit>
11
+ </layout>
app/design/adminhtml/default/default/template/bricks/catalog/tab.phtml ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $block bricks_Catalog_Block_Adminhtml_Tab */
3
+ $block = $this;
4
+
5
+ /* @var $helper bricks_Catalog_Helper_Data */
6
+ $helper = Mage::helper('bricks_catalog');
7
+
8
+ ob_start();
9
+ ?>
10
+
11
+ <div class="option-box" id="div_pf_{{id}}">
12
+ <input type="hidden" name="bricks_pf[{{id}}][id]" id="pf_{{id}}_id" value="{{id}}" />
13
+ <input type="hidden" name="bricks_pf[{{id}}][feature_id]" id="pf_{{id}}_feature_id" value="{{feature_id}}" />
14
+ <input type="hidden" name="bricks_pf[{{id}}][is_delete]" id="pf_{{id}}_is_delete" value="0" />
15
+
16
+ <table class="form-list">
17
+ <tr>
18
+ <td class="label"><label for="pf_{{id}}_title">Title <span class="required">*</span></label></td>
19
+ <td class="value"><input type="text" class="required-entry input-text field-title" name="bricks_pf[{{id}}][title]" value="{{title}}" id="pf_{{id}}_title" /></td>
20
+ </tr>
21
+
22
+ <tr>
23
+ <td class="label"><label for="pf_{{id}}_file">Image</label></td>
24
+ <td class="value">
25
+ {{image}}
26
+ <input type="file" class="input-file field-field" name="bricks_pf_{{id}}" id="pf_{{id}}_file" />
27
+ </td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <td class="label"><label for="pf_{{id}}_image_position">Image Position</label></td>
32
+ <td class="value">
33
+ <select name="bricks_pf[{{id}}][image_position]" id="pf_{{id}}_image_position">
34
+ <option value="auto">Auto</option>
35
+ <option value="left">Left</option>
36
+ <option value="right">Right</option>
37
+ </select>
38
+ </td>
39
+ </tr>
40
+
41
+ <tr>
42
+ <td class="label"><label for="pf_{{id}}_content">Content <span class="required">*</span></label></td>
43
+ <td class="value">
44
+ <textarea name="bricks_pf[{{id}}][content]" id="pf_{{id}}_content" cols="80" rows="7">{{content}}</textarea>
45
+ </td>
46
+ </tr>
47
+
48
+ <tr>
49
+ <td class="label"><label for="pf_{{id}}_sort_order">Sort Order</label></td>
50
+ <td class="value"><input type="text" class="input-text validate-number" name="bricks_pf[{{id}}][sort_order]" value="{{sort_order}}" id="pf_{{id}}_sort_order" /></td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <td class="label"></td>
55
+ <td class="value"><?php echo $block->jsQuoteEscape( $block->getChildHtml('delete_button') ) ?></td>
56
+ </tr>
57
+ </table>
58
+ </div>
59
+
60
+ <?php $tmpl = ob_get_clean(); ?>
61
+
62
+ <div class="entry-edit custom-options product-features">
63
+ <div class="entry-edit-head">
64
+ <h4><?php echo Mage::helper('bricks_catalog')->__( 'Product Descriptions' ); ?></h4>
65
+ <div class="right">
66
+ <?php echo $this->getChildHtml('add_button'); ?>
67
+ </div>
68
+ </div>
69
+
70
+ <div id="product_features_container" class="box">
71
+ <div id="product_features_top"></div>
72
+ </div>
73
+
74
+ </div>
75
+
76
+ <script type="text/javascript">
77
+ //<![CDATA[
78
+ openEditorPopup = function(url, name, specs, parent) {
79
+ if ((typeof popups == "undefined") || popups[name] == undefined || popups[name].closed) {
80
+ if (typeof popups == "undefined") {
81
+ popups = new Array();
82
+ }
83
+ var opener = (parent != undefined ? parent : window);
84
+ popups[name] = opener.open(url, name, specs);
85
+ } else {
86
+ popups[name].focus();
87
+ }
88
+ return popups[name];
89
+ };
90
+
91
+ closeEditorPopup = function(name) {
92
+ if ((typeof popups != "undefined") && popups[name] != undefined && !popups[name].closed) {
93
+ popups[name].close();
94
+ }
95
+ };
96
+
97
+ (function(){
98
+ var pfTemplate = <?php echo Mage::helper('core')->jsonEncode( $tmpl ); ?>,
99
+ bricksField;
100
+
101
+ bricksField = {
102
+ div: $('product_features_top'),
103
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
104
+ templateText : pfTemplate,
105
+ itemCount : 1,
106
+
107
+ add: function( data ) {
108
+ this.template = new Template(this.templateText, this.templateSyntax);
109
+
110
+ if ( ! data.feature_id ) {
111
+ data = {
112
+ id: this.itemCount,
113
+ feature_id: ''
114
+ };
115
+ } else if ( this.itemCount < data.item_count ) {
116
+ this.itemCount = data.item_count;
117
+ }
118
+
119
+ Element.insert(this.div, { 'after': this.template.evaluate( data ) });
120
+ var mce = new tinyMceWysiwygSetup( 'pf_' + data.id + '_content', {
121
+ add_widgets: false,
122
+ add_variables: false,
123
+ add_images: false
124
+ } );
125
+ mce.turnOn();
126
+
127
+ if ( data.image_position && data.id ) {
128
+ $A( $( 'pf_' + data.id + '_image_position' ).options ).each(function(option){
129
+ if ( option.value == data.image_position ) {
130
+ option.selected = true;
131
+ }
132
+ });
133
+ }
134
+
135
+ this.itemCount++;
136
+ this.bindRemoveButtons();
137
+ },
138
+
139
+ remove: function( event ) {
140
+ var element = $( Event.findElement( event, 'div' ) );
141
+ if ( element ) {
142
+ $( element.readAttribute( 'id' ).sub('div_', '') + '_' + 'is_delete' ).value = '1';
143
+ element.addClassName( 'no-display' );
144
+ element.addClassName( 'ignore-validate' );
145
+ element.hide();
146
+ }
147
+ },
148
+
149
+ bindRemoveButtons: function() {
150
+ var buttons = $$( 'div.product-features .delete-bricks-product-feature' );
151
+
152
+ for ( var i = 0; i < buttons.length; i++ ) {
153
+ if ( ! $(buttons[i]).binded ) {
154
+ $( buttons[i] ).binded = true;
155
+ Event.observe( buttons[i], 'click', this.remove.bind( this ) );
156
+ }
157
+ }
158
+ }
159
+ };
160
+
161
+ if($('add_new_product_feature')){
162
+ Event.observe('add_new_product_feature', 'click', bricksField.add.bind(bricksField));
163
+ }
164
+
165
+ Event.observe(window, 'load', function() {
166
+ <?php foreach ( $block->getFeatures() as $feature ): ?>
167
+ bricksField.add(<?php echo Mage::helper('core')->jsonEncode( $feature ); ?>);
168
+ <?php endforeach; ?>
169
+ } );
170
+
171
+ })();
172
+ //]]>
173
+ </script>
app/design/frontend/base/default/layout/bricks/catalog.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="product.info.tabs">
5
+ <action method="addTab" translate="title" module="bricks_catalog">
6
+ <alias>product_features</alias>
7
+ <title>Product Features</title>
8
+ <block>bricks_catalog/features</block>
9
+ <template>bricks/catalog/features.phtml</template>
10
+ </action>
11
+ </reference>
12
+ </catalog_product_view>
13
+ </layout>
app/design/frontend/base/default/template/bricks/catalog/features.phtml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $block Encore_Catalog_Block_Features */
3
+ $block = $this;
4
+ $features = $block->getFeatures();
5
+
6
+ if ( empty( $features ) )
7
+ return;
8
+
9
+ echo '<div class="bricks-product-features">';
10
+
11
+ $last_pos = 'left';
12
+ foreach ( $features as $feature ) :
13
+ if ( $feature['image_position'] == 'auto' ) {
14
+ if ( $last_pos == 'right' ) {
15
+ $img_pos = 'left';
16
+ } else {
17
+ $img_pos = 'right';
18
+ }
19
+ } else {
20
+ $img_pos = $feature['image_position'];
21
+ }
22
+ ?>
23
+
24
+ <div class="feature">
25
+ <?php if ( 'left' === $img_pos ): ?>
26
+ <div class="feature-image left"><div class="pad"><?php echo $feature['image']; ?></div></div>
27
+ <div class="feature-content right">
28
+ <div class="pad">
29
+ <h1 class="feature-title"><?php echo strip_tags( $feature['title'] ); ?></h1>
30
+ <?php echo $feature['content']; ?>
31
+ </div>
32
+ </div>
33
+ <?php else: ?>
34
+ <div class="feature-content left">
35
+ <div class="pad">
36
+ <h1 class="feature-title"><?php echo strip_tags( $feature['title'] ); ?></h1>
37
+ <?php echo $feature['content']; ?>
38
+ </div>
39
+ </div>
40
+ <div class="feature-image right"><div class="pad"><?php echo $feature['image']; ?></div></div>
41
+ <?php endif; ?>
42
+ </div>
43
+
44
+ <?php
45
+
46
+ $last_pos = $img_pos;
47
+ endforeach;
48
+
49
+ echo '</div>';
50
+ ?>
51
+
52
+ <style type="text/css">
53
+ .bricks-product-features .feature {
54
+ padding: 10px 0;
55
+ }
56
+
57
+ .bricks-product-features .feature:before,
58
+ .bricks-product-features .feature:after {
59
+ content: '';
60
+ display: table;
61
+ }
62
+ .bricks-product-features .feature:after {
63
+ clear: both;
64
+ }
65
+
66
+ .bricks-product-features .left {
67
+ float: left;
68
+ }
69
+ .bricks-product-features .right {
70
+ float: right;
71
+ }
72
+
73
+ .bricks-product-features .left .pad {
74
+ padding-right: 10px;
75
+ }
76
+ .bricks-product-features .right .pad {
77
+ padding-left: 10px;
78
+ }
79
+
80
+ .bricks-product-features .feature-content { width: 70%; }
81
+ .bricks-product-features .feature-image { width: 30%; }
82
+
83
+ .bricks-product-features img {
84
+ max-width: 100%;
85
+ height: auto;
86
+ }
87
+ </style>
app/etc/modules/Bricks_Catalog.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Bricks_Catalog>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Bricks_Catalog>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>EnhancedProductFeatures</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSL-3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>extra_product_options</summary>
10
+ <description>extra_product_options</description>
11
+ <notes>extra_product_options</notes>
12
+ <authors><author><name>adam</name><user>adam</user><email>adam@bricksandmortarweb.com</email></author></authors>
13
+ <date>2016-02-09</date>
14
+ <time>15:37:16</time>
15
+ <contents><target name="magelocal"><dir name="Bricks"><dir name="Catalog"><dir name="Block"><dir name="Adminhtml"><file name="Tab.php" hash="5e7c7c252488396c603086d6b93f688f"/></dir><file name="Features.php" hash="abf2b0b475d654e1781336d128198ce0"/></dir><dir name="Helper"><file name="Data.php" hash="5b528dd94277c1ffb098770770588d19"/></dir><dir name="Model"><file name="Features.php" hash="a717400abc7727acd1f58113212a5930"/><file name="Observer.php" hash="0244461c4b1325bec499231b17a5c76a"/><dir name="Resource"><dir name="Features"><file name="Collection.php" hash="62a75b1f1742126e6c000f0a32c200c7"/></dir><file name="Features.php" hash="bdac41742bf9236eed97f90479b33103"/><file name="Setup.php" hash="270212cb39a17ccd1868453f90815710"/></dir></dir><dir name="etc"><file name="config.xml" hash="2f14ddbd7587b584e30940438f26a342"/></dir><dir name="sql"><dir name="bricks_catalog_setup"><file name="install-0.0.1.php" hash="56c2d641577684e6d9b996c118d22904"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bricks_Catalog.xml" hash="be46c315620cb5191d038a14e9ff8261"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="bricks"><file name="catalog.xml" hash="1a37fd801d0521d6dabfca4c513c88b3"/></dir></dir><dir name="template"><dir name="bricks"><dir name="catalog"><file name="tab.phtml" hash="8ddd1fcf888d86b55e20258b106134cb"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="bricks"><dir name="catalog"><file name="features.phtml" hash="3e4b0035de88f609e63d9ce3ed6f8b7a"/></dir></dir></dir><dir name="layout"><dir name="bricks"><file name="catalog.xml" hash="a71549cc9fffe40d53e6f7c9890e55bd"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>2.0.0.0</min><max>6.0.0.0</max></php></required></dependencies>
18
+ </package>