Morningtime_TextfieldLayeredNav - Version 1.3.2.1

Version Notes

Stable Release

Download this release

Release Info

Developer Magento Core Team
Extension Morningtime_TextfieldLayeredNav
Version 1.3.2.1
Comparing to
See all releases


Version 1.3.2.1

Files changed (21) hide show
  1. app/code/community/Morningtime/TextfieldLayeredNav/Block/Adminhtml/Catalog/Product/Attribute/Edit/Tab/Main.php +386 -0
  2. app/code/community/Morningtime/TextfieldLayeredNav/Block/Adminhtml/Catalog/Product/Attribute/Edit/Tab/Options.php +79 -0
  3. app/code/community/Morningtime/TextfieldLayeredNav/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php +60 -0
  4. app/code/community/Morningtime/TextfieldLayeredNav/Block/Catalog/Product/Compare/List.php +34 -0
  5. app/code/community/Morningtime/TextfieldLayeredNav/Block/CatalogSearch/Advanced/Form.php +45 -0
  6. app/code/community/Morningtime/TextfieldLayeredNav/Model/Catalog/Entity/Attribute.php +92 -0
  7. app/code/community/Morningtime/TextfieldLayeredNav/Model/Catalog/Resource/Eav/Attribute.php +39 -0
  8. app/code/community/Morningtime/TextfieldLayeredNav/Model/Catalog/Resource/Eav/Mysql4/Product.php +138 -0
  9. app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogIndex/Indexer/Eav.php +48 -0
  10. app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogRule/Rule/Condition/Product.php +42 -0
  11. app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogSearch/Advanced.php +70 -0
  12. app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogSearch/Mysql4/Search/Collection.php +124 -0
  13. app/code/community/Morningtime/TextfieldLayeredNav/Model/Eav/Entity/Attribute.php +23 -0
  14. app/code/community/Morningtime/TextfieldLayeredNav/Model/Eav/Entity/Attribute/Frontend/Default.php +44 -0
  15. app/code/community/Morningtime/TextfieldLayeredNav/Model/Eav/Mysql4/Entity/Attribute.php +141 -0
  16. app/code/community/Morningtime/TextfieldLayeredNav/controllers/Adminhtml/Catalog/Product/AttributeController.php +57 -0
  17. app/code/community/Morningtime/TextfieldLayeredNav/etc/config.xml +92 -0
  18. app/design/adminhtml/default/default/template/morningtime/textfieldlayerednav/catalog/product/attribute/js.phtml +306 -0
  19. app/etc/modules/Morningtime_TextfieldLayeredNav.xml +25 -0
  20. lib/Varien/Data/Form/Element/Textfilter.php +77 -0
  21. package.xml +40 -0
app/code/community/Morningtime/TextfieldLayeredNav/Block/Adminhtml/Catalog/Product/Attribute/Edit/Tab/Main.php ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Block_Adminhtml_Catalog_Product_Attribute_Edit_Tab_Main extends Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main
12
+ {
13
+
14
+ protected function _prepareForm()
15
+ {
16
+ $model = Mage::registry('entity_attribute');
17
+
18
+ $form = new Varien_Data_Form(array(
19
+ 'id' => 'edit_form',
20
+ 'action' => $this->getData('action'),
21
+ 'method' => 'post'
22
+ ));
23
+
24
+ $disableAttributeFields = array(
25
+ 'sku' => array(
26
+ 'is_global',
27
+ 'is_unique',
28
+ ),
29
+ 'url_key' => array(
30
+ 'is_unique',
31
+ ),
32
+ );
33
+
34
+ $fieldset = $form->addFieldset('base_fieldset',
35
+ array('legend'=>Mage::helper('catalog')->__('Attribute Properties'))
36
+ );
37
+ if ($model->getAttributeId()) {
38
+ $fieldset->addField('attribute_id', 'hidden', array(
39
+ 'name' => 'attribute_id',
40
+ ));
41
+ }
42
+
43
+ $this->_addElementTypes($fieldset);
44
+
45
+ $yesno = array(
46
+ array(
47
+ 'value' => 0,
48
+ 'label' => Mage::helper('catalog')->__('No')
49
+ ),
50
+ array(
51
+ 'value' => 1,
52
+ 'label' => Mage::helper('catalog')->__('Yes')
53
+ ));
54
+
55
+ $fieldset->addField('attribute_code', 'text', array(
56
+ 'name' => 'attribute_code',
57
+ 'label' => Mage::helper('catalog')->__('Attribute Code'),
58
+ 'title' => Mage::helper('catalog')->__('Attribute Code'),
59
+ 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'),
60
+ 'class' => 'validate-code',
61
+ 'required' => true,
62
+ ));
63
+
64
+ $scopes = array(
65
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
66
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('catalog')->__('Website'),
67
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
68
+ );
69
+
70
+ if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') {
71
+ unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
72
+ }
73
+
74
+ $fieldset->addField('is_global', 'select', array(
75
+ 'name' => 'is_global',
76
+ 'label' => Mage::helper('catalog')->__('Scope'),
77
+ 'title' => Mage::helper('catalog')->__('Scope'),
78
+ 'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'),
79
+ 'values'=> $scopes
80
+ ));
81
+
82
+ $inputTypes = array(
83
+ array(
84
+ 'value' => 'text',
85
+ 'label' => Mage::helper('catalog')->__('Text Field')
86
+ ),
87
+ array(
88
+ 'value' => 'textarea',
89
+ 'label' => Mage::helper('catalog')->__('Text Area')
90
+ ),
91
+ array(
92
+ 'value' => 'date',
93
+ 'label' => Mage::helper('catalog')->__('Date')
94
+ ),
95
+ array(
96
+ 'value' => 'boolean',
97
+ 'label' => Mage::helper('catalog')->__('Yes/No')
98
+ ),
99
+ array(
100
+ 'value' => 'multiselect',
101
+ 'label' => Mage::helper('catalog')->__('Multiple Select')
102
+ ),
103
+ /* MT start */
104
+ array(
105
+ 'value' => 'textfilter',
106
+ 'label' => Mage::helper('catalog')->__('Textfield for Filter')
107
+ ),
108
+ /* MT out */
109
+ array(
110
+ 'value' => 'select',
111
+ 'label' => Mage::helper('catalog')->__('Dropdown')
112
+ ),
113
+ array(
114
+ 'value' => 'price',
115
+ 'label' => Mage::helper('catalog')->__('Price')
116
+ ),
117
+ array(
118
+ 'value' => 'gallery',
119
+ 'label' => Mage::helper('catalog')->__('Gallery')
120
+ ),
121
+ array(
122
+ 'value' => 'media_image',
123
+ 'label' => Mage::helper('catalog')->__('Media Image')
124
+ ),
125
+ );
126
+
127
+ $response = new Varien_Object();
128
+ $response->setTypes(array());
129
+ Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
130
+
131
+ $_disabledTypes = array();
132
+ $_hiddenFields = array();
133
+ foreach ($response->getTypes() as $type) {
134
+ $inputTypes[] = $type;
135
+ if (isset($type['hide_fields'])) {
136
+ $_hiddenFields[$type['value']] = $type['hide_fields'];
137
+ }
138
+ if (isset($type['disabled_types'])) {
139
+ $_disabledTypes[$type['value']] = $type['disabled_types'];
140
+ }
141
+ }
142
+ Mage::register('attribute_type_hidden_fields', $_hiddenFields);
143
+ Mage::register('attribute_type_disabled_types', $_disabledTypes);
144
+
145
+
146
+ $fieldset->addField('frontend_input', 'select', array(
147
+ 'name' => 'frontend_input',
148
+ 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'),
149
+ 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'),
150
+ 'value' => 'text',
151
+ 'values'=> $inputTypes
152
+ ));
153
+
154
+ $fieldset->addField('default_value_text', 'text', array(
155
+ 'name' => 'default_value_text',
156
+ 'label' => Mage::helper('catalog')->__('Default value'),
157
+ 'title' => Mage::helper('catalog')->__('Default value'),
158
+ 'value' => $model->getDefaultValue(),
159
+ ));
160
+
161
+ $fieldset->addField('default_value_yesno', 'select', array(
162
+ 'name' => 'default_value_yesno',
163
+ 'label' => Mage::helper('catalog')->__('Default value'),
164
+ 'title' => Mage::helper('catalog')->__('Default value'),
165
+ 'values' => $yesno,
166
+ 'value' => $model->getDefaultValue(),
167
+ ));
168
+
169
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
170
+ $fieldset->addField('default_value_date', 'date', array(
171
+ 'name' => 'default_value_date',
172
+ 'label' => Mage::helper('catalog')->__('Default value'),
173
+ 'title' => Mage::helper('catalog')->__('Default value'),
174
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
175
+ 'value' => $model->getDefaultValue(),
176
+ 'format' => $dateFormatIso
177
+ ));
178
+
179
+ $fieldset->addField('default_value_textarea', 'textarea', array(
180
+ 'name' => 'default_value_textarea',
181
+ 'label' => Mage::helper('catalog')->__('Default value'),
182
+ 'title' => Mage::helper('catalog')->__('Default value'),
183
+ 'value' => $model->getDefaultValue(),
184
+ ));
185
+
186
+ $fieldset->addField('is_unique', 'select', array(
187
+ 'name' => 'is_unique',
188
+ 'label' => Mage::helper('catalog')->__('Unique Value'),
189
+ 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'),
190
+ 'note' => Mage::helper('catalog')->__('Not shared with other products'),
191
+ 'values' => $yesno,
192
+ ));
193
+
194
+ $fieldset->addField('is_required', 'select', array(
195
+ 'name' => 'is_required',
196
+ 'label' => Mage::helper('catalog')->__('Values Required'),
197
+ 'title' => Mage::helper('catalog')->__('Values Required'),
198
+ 'values' => $yesno,
199
+ ));
200
+
201
+ $fieldset->addField('frontend_class', 'select', array(
202
+ 'name' => 'frontend_class',
203
+ 'label' => Mage::helper('catalog')->__('Input Validation for Store Owner'),
204
+ 'title' => Mage::helper('catalog')->__('Input Validation for Store Owner'),
205
+ 'values'=> array(
206
+ array(
207
+ 'value' => '',
208
+ 'label' => Mage::helper('catalog')->__('None')
209
+ ),
210
+ array(
211
+ 'value' => 'validate-number',
212
+ 'label' => Mage::helper('catalog')->__('Decimal Number')
213
+ ),
214
+ array(
215
+ 'value' => 'validate-digits',
216
+ 'label' => Mage::helper('catalog')->__('Integer Number')
217
+ ),
218
+ array(
219
+ 'value' => 'validate-email',
220
+ 'label' => Mage::helper('catalog')->__('Email')
221
+ ),
222
+ array(
223
+ 'value' => 'validate-url',
224
+ 'label' => Mage::helper('catalog')->__('Url')
225
+ ),
226
+ array(
227
+ 'value' => 'validate-alpha',
228
+ 'label' => Mage::helper('catalog')->__('Letters')
229
+ ),
230
+ array(
231
+ 'value' => 'validate-alphanum',
232
+ 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)')
233
+ ),
234
+ )
235
+ ));
236
+ /*
237
+ $fieldset->addField('use_in_super_product', 'select', array(
238
+ 'name' => 'use_in_super_product',
239
+ 'label' => Mage::helper('catalog')->__('Apply To Configurable/Grouped Product'),
240
+ 'values' => $yesno,
241
+ )); */
242
+
243
+ $fieldset->addField('apply_to', 'apply', array(
244
+ 'name' => 'apply_to[]',
245
+ 'label' => Mage::helper('catalog')->__('Apply To'),
246
+ 'values' => Mage_Catalog_Model_Product_Type::getOptions(),
247
+ 'mode_labels' => array(
248
+ 'all' => Mage::helper('catalog')->__('All Product Types'),
249
+ 'custom' => Mage::helper('catalog')->__('Selected Product Types')
250
+ ),
251
+ 'required' => true
252
+ ));
253
+
254
+ $fieldset->addField('is_configurable', 'select', array(
255
+ 'name' => 'is_configurable',
256
+ 'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'),
257
+ 'values' => $yesno,
258
+ ));
259
+ // -----
260
+
261
+
262
+ // frontend properties fieldset
263
+ $fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
264
+
265
+ $fieldset->addField('is_searchable', 'select', array(
266
+ 'name' => 'is_searchable',
267
+ 'label' => Mage::helper('catalog')->__('Use in quick search'),
268
+ 'title' => Mage::helper('catalog')->__('Use in quick search'),
269
+ 'values' => $yesno,
270
+ ));
271
+
272
+ $fieldset->addField('is_visible_in_advanced_search', 'select', array(
273
+ 'name' => 'is_visible_in_advanced_search',
274
+ 'label' => Mage::helper('catalog')->__('Use in advanced search'),
275
+ 'title' => Mage::helper('catalog')->__('Use in advanced search'),
276
+ 'values' => $yesno,
277
+ ));
278
+
279
+ $fieldset->addField('is_comparable', 'select', array(
280
+ 'name' => 'is_comparable',
281
+ 'label' => Mage::helper('catalog')->__('Comparable on Front-end'),
282
+ 'title' => Mage::helper('catalog')->__('Comparable on Front-end'),
283
+ 'values' => $yesno,
284
+ ));
285
+
286
+
287
+ $fieldset->addField('is_filterable', 'select', array(
288
+ 'name' => 'is_filterable',
289
+ 'label' => Mage::helper('catalog')->__("Use In Layered Navigation"),
290
+ 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
291
+ 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
292
+ 'values' => array(
293
+ array('value' => '0', 'label' => Mage::helper('catalog')->__('No')),
294
+ array('value' => '1', 'label' => Mage::helper('catalog')->__('Filterable (with results)')),
295
+ array('value' => '2', 'label' => Mage::helper('catalog')->__('Filterable (no results)')),
296
+ ),
297
+ ));
298
+
299
+ $fieldset->addField('is_filterable_in_search', 'select', array(
300
+ 'name' => 'is_filterable_in_search',
301
+ 'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"),
302
+ 'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
303
+ 'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
304
+ 'values' => $yesno,
305
+ ));
306
+
307
+ $fieldset->addField('is_used_for_price_rules', 'select', array(
308
+ 'name' => 'is_used_for_price_rules',
309
+ 'label' => Mage::helper('catalog')->__('Use for Price Rule Conditions'),
310
+ 'title' => Mage::helper('catalog')->__('Use for Price Rule Conditions'),
311
+ 'values' => $yesno,
312
+ ));
313
+
314
+ $fieldset->addField('position', 'text', array(
315
+ 'name' => 'position',
316
+ 'label' => Mage::helper('catalog')->__('Position'),
317
+ 'title' => Mage::helper('catalog')->__('Position In Layered Navigation'),
318
+ 'note' => Mage::helper('catalog')->__('Position of attribute in layered navigation block'),
319
+ 'class' => 'validate-digits',
320
+ ));
321
+
322
+ $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array(
323
+ 'name' => 'is_html_allowed_on_front',
324
+ 'label' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'),
325
+ 'title' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'),
326
+ 'values' => $yesno,
327
+ ));
328
+ if (!$model->getId()) {
329
+ $htmlAllowed->setValue(1);
330
+ }
331
+
332
+ $fieldset->addField('is_visible_on_front', 'select', array(
333
+ 'name' => 'is_visible_on_front',
334
+ 'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
335
+ 'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
336
+ 'values' => $yesno,
337
+ ));
338
+
339
+ $fieldset->addField('used_in_product_listing', 'select', array(
340
+ 'name' => 'used_in_product_listing',
341
+ 'label' => Mage::helper('catalog')->__('Used in product listing'),
342
+ 'title' => Mage::helper('catalog')->__('Used in product listing'),
343
+ 'note' => Mage::helper('catalog')->__('Depends on design theme'),
344
+ 'values' => $yesno,
345
+ ));
346
+ $fieldset->addField('used_for_sort_by', 'select', array(
347
+ 'name' => 'used_for_sort_by',
348
+ 'label' => Mage::helper('catalog')->__('Used for sorting in product listing'),
349
+ 'title' => Mage::helper('catalog')->__('Used for sorting in product listing'),
350
+ 'note' => Mage::helper('catalog')->__('Depends on design theme'),
351
+ 'values' => $yesno,
352
+ ));
353
+
354
+ if ($model->getId()) {
355
+ $form->getElement('attribute_code')->setDisabled(1);
356
+ $form->getElement('frontend_input')->setDisabled(1);
357
+
358
+ if (isset($disableAttributeFields[$model->getAttributeCode()])) {
359
+ foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) {
360
+ $form->getElement($field)->setDisabled(1);
361
+ }
362
+ }
363
+ }
364
+ if (!$model->getIsUserDefined() && $model->getId()) {
365
+ $form->getElement('is_unique')->setDisabled(1);
366
+ }
367
+
368
+ $form->addValues($model->getData());
369
+
370
+ $form->getElement('apply_to')->setSize(5);
371
+
372
+ if ($applyTo = $model->getApplyTo()) {
373
+ $applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo);
374
+ $form->getElement('apply_to')->setValue($applyTo);
375
+ } else {
376
+ $form->getElement('apply_to')->addClass('no-display ignore-validate');
377
+ }
378
+
379
+ $this->setForm($form);
380
+
381
+ /* MT start
382
+ return parent::_prepareForm();
383
+ */
384
+ }
385
+
386
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Block/Adminhtml/Catalog/Product/Attribute/Edit/Tab/Options.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Block_Adminhtml_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
12
+ {
13
+
14
+ public function getOptionValues()
15
+ {
16
+ $attributeType = $this->getAttributeObject()->getFrontendInput();
17
+ $defaultValues = $this->getAttributeObject()->getDefaultValue();
18
+ /* MT start
19
+ if ($attributeType == 'select' || $attributeType == 'multiselect') {
20
+ */
21
+ if ($attributeType == 'select' || $attributeType == 'textfilter' || $attributeType == 'multiselect') {
22
+ /* MT end */
23
+ $defaultValues = explode(',', $defaultValues);
24
+ } else {
25
+ $defaultValues = array();
26
+ }
27
+
28
+ switch ($attributeType) {
29
+ case 'select':
30
+ /* MT add */
31
+ case 'textfilter':
32
+ /* MT end */
33
+ $inputType = 'radio';
34
+ break;
35
+ case 'multiselect':
36
+ $inputType = 'checkbox';
37
+ break;
38
+ default:
39
+ $inputType = '';
40
+ break;
41
+ }
42
+
43
+ $values = $this->getData('option_values');
44
+ if (is_null($values)) {
45
+ $values = array();
46
+ $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
47
+ ->setAttributeFilter($this->getAttributeObject()->getId())
48
+ ->setPositionOrder('desc', true)
49
+ ->load();
50
+
51
+ foreach ($optionCollection as $option) {
52
+ $value = array();
53
+ if (in_array($option->getId(), $defaultValues)) {
54
+ $value['checked'] = 'checked="checked"';
55
+ } else {
56
+ $value['checked'] = '';
57
+ }
58
+
59
+ $value['intype'] = $inputType;
60
+ $value['id'] = $option->getId();
61
+ $value['sort_order'] = $option->getSortOrder();
62
+ foreach ($this->getStores() as $store) {
63
+ $storeValues = $this->getStoreOptionValues($store->getId());
64
+ if (isset($storeValues[$option->getId()])) {
65
+ $value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
66
+ }
67
+ else {
68
+ $value['store'.$store->getId()] = '';
69
+ }
70
+ }
71
+ $values[] = new Varien_Object($value);
72
+ }
73
+ $this->setData('option_values', $values);
74
+ }
75
+
76
+ return $values;
77
+ }
78
+
79
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes
12
+ {
13
+ protected function _setFieldset($attributes, $fieldset, $exclude=array())
14
+ {
15
+ $this->_addElementTypes($fieldset);
16
+ foreach ($attributes as $attribute) {
17
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
18
+ if (!$attribute || !$attribute->getIsVisible()) {
19
+ continue;
20
+ }
21
+ if ( ($inputType = $attribute->getFrontend()->getInputType())
22
+ && !in_array($attribute->getAttributeCode(), $exclude)
23
+ && ('media_image' != $inputType)
24
+ ) {
25
+
26
+ $fieldType = $inputType;
27
+ $rendererClass = $attribute->getFrontend()->getInputRendererClass();
28
+ if (!empty($rendererClass)) {
29
+ $fieldType = $inputType . '_' . $attribute->getAttributeCode();
30
+ $fieldset->addType($fieldType, $rendererClass);
31
+ }
32
+
33
+ $element = $fieldset->addField($attribute->getAttributeCode(), $fieldType,
34
+ array(
35
+ 'name' => $attribute->getAttributeCode(),
36
+ 'label' => __($attribute->getFrontend()->getLabel()),
37
+ 'class' => $attribute->getFrontend()->getClass(),
38
+ 'required' => $attribute->getIsRequired(),
39
+ 'note' => $attribute->getNote(),
40
+ )
41
+ )
42
+ ->setEntityAttribute($attribute);
43
+
44
+ $element->setAfterElementHtml($this->_getAdditionalElementHtml($element));
45
+
46
+ /* MT start
47
+ if ($inputType == 'select' || $inputType == 'multiselect') {
48
+ */
49
+ if ($inputType == 'select' || $inputType == 'multiselect' || $inputType == 'textfilter') {
50
+ /* MT end */
51
+ $element->setValues($attribute->getSource()->getAllOptions(true, true));
52
+ } elseif ($inputType == 'date') {
53
+ $element->setImage($this->getSkinUrl('images/grid-cal.gif'));
54
+ $element->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Block/Catalog/Product/Compare/List.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Block_Catalog_Product_Compare_List extends Mage_Catalog_Block_Product_Compare_List
12
+ {
13
+
14
+ public function getProductAttributeValue($product, $attribute)
15
+ {
16
+ if (!$product->hasData($attribute->getAttributeCode())) {
17
+ return '&nbsp;';
18
+ }
19
+
20
+ /* MT start
21
+ if ($attribute->getSourceModel() || in_array($attribute->getFrontendInput(), array('select','boolean','multiselect'))) {
22
+ */
23
+ if ($attribute->getSourceModel() || in_array($attribute->getFrontendInput(), array('select','textfilter','boolean','multiselect'))) {
24
+ /* MT end */
25
+ //$value = $attribute->getSource()->getOptionText($product->getData($attribute->getAttributeCode()));
26
+ $value = $attribute->getFrontend()->getValue($product);
27
+ }
28
+ else {
29
+ $value = $product->getData($attribute->getAttributeCode());
30
+ }
31
+ return $value ? $value : '&nbsp;';
32
+ }
33
+
34
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Block/CatalogSearch/Advanced/Form.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Block_CatalogSearch_Advanced_Form extends Mage_CatalogSearch_Block_Advanced_Form
12
+ {
13
+
14
+ public function getAttributeInputType($attribute)
15
+ {
16
+ $dataType = $attribute->getBackend()->getType();
17
+ $imputType = $attribute->getFrontend()->getInputType();
18
+ /* MT start
19
+ if ($imputType == 'select' || $imputType == 'multiselect') {
20
+ */
21
+ if ($imputType == 'select' || $imputType == 'textfilter' || $imputType == 'multiselect') {
22
+ /* MT end */
23
+ return 'select';
24
+ }
25
+
26
+ if ($imputType == 'boolean') {
27
+ return 'yesno';
28
+ }
29
+
30
+ if ($imputType == 'price') {
31
+ return 'price';
32
+ }
33
+
34
+ if ($dataType == 'int' || $dataType == 'decimal') {
35
+ return 'number';
36
+ }
37
+
38
+ if ($dataType == 'datetime') {
39
+ return 'date';
40
+ }
41
+
42
+ return 'string';
43
+ }
44
+
45
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/Catalog/Entity/Attribute.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_Catalog_Entity_Attribute extends Mage_Catalog_Model_Entity_Attribute
12
+ {
13
+ public function getBackendTypeByInput($type)
14
+ {
15
+ switch ($type) {
16
+ case 'text':
17
+ case 'gallery':
18
+ case 'media_image':
19
+ case 'multiselect':
20
+ return 'varchar';
21
+
22
+ case 'image':
23
+ case 'textarea':
24
+ return 'text';
25
+
26
+ case 'date':
27
+ return 'datetime';
28
+
29
+ case 'select':
30
+ /* MT start */
31
+ case 'textfilter':
32
+ /* MT end */
33
+ case 'boolean':
34
+ return 'int';
35
+
36
+
37
+ case 'price':
38
+ return 'decimal';
39
+ /*
40
+ default:
41
+ Mage::dispatchEvent('eav_attribute_get_backend_type_by_input', array('model'=>$this, 'type'=>$type));
42
+ if ($this->hasBackendTypeByInput()) {
43
+ return $this->getData('backend_type_by_input');
44
+ }
45
+ Mage::throwException('Unknown frontend input type');
46
+ */
47
+ }
48
+ }
49
+
50
+ public function getDefaultValueByInput($type)
51
+ {
52
+ $field = '';
53
+ switch ($type) {
54
+ case 'select':
55
+ /* MT start */
56
+ case 'textfilter':
57
+ /* MT end */
58
+ case 'gallery':
59
+ case 'media_image':
60
+ case 'multiselect':
61
+ return '';
62
+
63
+ case 'text':
64
+ case 'price':
65
+ case 'image':
66
+ $field = 'default_value_text';
67
+ break;
68
+
69
+ case 'textarea':
70
+ $field = 'default_value_textarea';
71
+ break;
72
+
73
+ case 'date':
74
+ $field = 'default_value_date';
75
+ break;
76
+
77
+ case 'boolean':
78
+ $field = 'default_value_yesno';
79
+ break;
80
+ /*
81
+ default:
82
+ Mage::dispatchEvent('eav_attribute_get_default_value_by_input', array('model'=>$this, 'type'=>$type));
83
+ if ($this->hasBackendTypeByInput()) {
84
+ return $this->getData('backend_type_by_input');
85
+ }
86
+ Mage::throwException('Unknown frontend input type');
87
+ */
88
+ }
89
+
90
+ return $field;
91
+ }
92
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/Catalog/Resource/Eav/Attribute.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_Catalog_Resource_Eav_Attribute extends Mage_Catalog_Model_Resource_Eav_Attribute
12
+ {
13
+
14
+ public function getSourceModel()
15
+ {
16
+ $model = $this->getData('source_model');
17
+ if (empty($model)) {
18
+ /* MT start
19
+ if ($this->getBackendType() == 'int' && $this->getFrontendInput() == 'select') {
20
+ */
21
+ if ($this->getBackendType() == 'int' && ($this->getFrontendInput() == 'select' || $this->getFrontendInput() == 'textfilter')) {
22
+ /* MT end */
23
+ return 'eav/entity_attribute_source_table';
24
+ }
25
+ }
26
+ return $model;
27
+ }
28
+
29
+ public function isAllowedForRuleCondition()
30
+ {
31
+ /* MT start
32
+ $allowedInputTypes = array('text', 'multiselect', 'textarea', 'date', 'datetime', 'select', 'boolean', 'price');
33
+ */
34
+ $allowedInputTypes = array('text', 'multiselect', 'textarea', 'date', 'datetime', 'select', 'textfilter', 'boolean', 'price');
35
+ /* MT end */
36
+ return $this->getIsVisible() && in_array($this->getFrontendInput(), $allowedInputTypes);
37
+ }
38
+
39
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/Catalog/Resource/Eav/Mysql4/Product.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_Catalog_Resource_Eav_Mysql4_Product extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product
12
+ {
13
+
14
+ protected function _processSaveData($saveData)
15
+ {
16
+ extract($saveData);
17
+ $insertEntity = true;
18
+ $entityIdField = $this->getEntityIdField();
19
+ $entityId = $newObject->getId();
20
+ $condition = $this->_getWriteAdapter()->quoteInto("$entityIdField=?", $entityId);
21
+
22
+ if (!empty($entityId)) {
23
+ $select = $this->_getWriteAdapter()->select()
24
+ ->from($this->getEntityTable(), $entityIdField)
25
+ ->where($condition);
26
+ if ($this->_getWriteAdapter()->fetchOne($select)) {
27
+ $insertEntity = false;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Process base row
33
+ */
34
+ if ($insertEntity) {
35
+ $this->_getWriteAdapter()->insert($this->getEntityTable(), $entityRow);
36
+ $entityId = $this->_getWriteAdapter()->lastInsertId();
37
+ $newObject->setId($entityId);
38
+ } else {
39
+ $this->_getWriteAdapter()->update($this->getEntityTable(), $entityRow, $condition);
40
+ }
41
+
42
+ /**
43
+ * insert attribute values
44
+ */
45
+ if (!empty($insert)) {
46
+ foreach ($insert as $attrId=>$value) {
47
+ $attribute = $this->getAttribute($attrId);
48
+
49
+ /* MT start */
50
+ if ($attribute->frontend_input == 'textfilter') {
51
+ $value = $this->_mtGetValue($attribute, $value);
52
+ }
53
+ /* MT end */
54
+
55
+ $this->_insertAttribute($newObject, $attribute, $value);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * update attribute values
61
+ */
62
+ if (!empty($update)) {
63
+ foreach ($update as $attrId=>$v) {
64
+ $attribute = $this->getAttribute($attrId);
65
+
66
+ /* MT start */
67
+ if ($attribute->frontend_input == 'textfilter') {
68
+ $v['value'] = $this->_mtGetValue($attribute, $v['value']);
69
+ }
70
+ /* MT end */
71
+
72
+ $this->_updateAttribute($newObject, $attribute, $v['value_id'], $v['value']);
73
+ }
74
+ }
75
+
76
+ /**
77
+ * delete empty attribute values
78
+ */
79
+ if (!empty($delete)) {
80
+ foreach ($delete as $table=>$values) {
81
+ $this->_deleteAttributes($newObject, $table, $values);
82
+ }
83
+ }
84
+
85
+ return $this;
86
+ }
87
+
88
+ protected function _mtGetValue($attribute, $value)
89
+ {
90
+
91
+ $writeFilter = Mage::getSingleton('core/resource')->getConnection('core_write');
92
+ $eav_attribute = Mage::getSingleton('core/resource')->getTableName('eav_attribute');
93
+ $eav_attribute_option_value = Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value');
94
+ $eav_attribute_option = Mage::getSingleton('core/resource')->getTableName('eav_attribute_option');
95
+ $textFilterResult = $writeFilter->query("select o.option_id from ".$eav_attribute." a, ".$eav_attribute_option_value." v, ".$eav_attribute_option." o
96
+ where a.attribute_id='".$attribute->attribute_id."'
97
+ and a.attribute_id=o.attribute_id
98
+ and o.option_id=v.option_id
99
+ and v.value='".$value."'");
100
+
101
+ $filterOptionId = 0; $i=0;
102
+ while ($rowFilter = $textFilterResult->fetch()) {
103
+ $filterOptionId=$rowFilter['option_id'];
104
+ $i++;
105
+ }
106
+
107
+ if ($i==0) { // new option: add & return option_id as $filterOptionId
108
+
109
+ $stores = Mage::getModel('core/store')
110
+ ->getResourceCollection()
111
+ ->setLoadDefault(true)
112
+ ->load();
113
+
114
+ $write = $this->_getWriteAdapter();
115
+ $data = array(
116
+ 'attribute_id' => $attribute->attribute_id,
117
+ 'sort_order' => 0,
118
+ );
119
+ $write->insert($eav_attribute_option, $data);
120
+
121
+ $filterOptionId = $write->lastInsertId();
122
+
123
+ foreach ($stores as $store) {
124
+ $data = array(
125
+ 'option_id' => $filterOptionId,
126
+ 'store_id' => $store->getId(),
127
+ 'value' => $value,
128
+ );
129
+ $write->insert($eav_attribute_option_value, $data);
130
+ }
131
+
132
+ }
133
+
134
+ // set option ID
135
+ return $filterOptionId;
136
+ }
137
+
138
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogIndex/Indexer/Eav.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_CatalogIndex_Indexer_Eav extends Mage_CatalogIndex_Model_Indexer_Eav
12
+ {
13
+
14
+ protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
15
+ {
16
+ if ($attribute->getIsFilterable() == 0 && $attribute->getIsVisibleInAdvancedSearch() == 0) {
17
+ return false;
18
+ }
19
+ /* MT start
20
+ if ($attribute->getFrontendInput() != 'select' && $attribute->getFrontendInput() != 'multiselect') {
21
+ */
22
+ if ($attribute->getFrontendInput() != 'select' && $attribute->getFrontendInput() != 'textfilter' && $attribute->getFrontendInput() != 'multiselect') {
23
+ /* MT end */
24
+ return false;
25
+ }
26
+
27
+ return true;
28
+ }
29
+
30
+ protected function _getIndexableAttributeConditions()
31
+ {
32
+ /* MT start
33
+ $conditions = "frontend_input IN ('select', 'multiselect') AND (is_filterable IN (1, 2) OR is_visible_in_advanced_search = 1)";
34
+ */
35
+ $conditions = "frontend_input IN ('select', 'textfilter', 'multiselect') AND (is_filterable IN (1, 2) OR is_visible_in_advanced_search = 1)";
36
+ /* MT end */
37
+ return $conditions;
38
+
39
+ $conditions = array();
40
+ /* MT start
41
+ $conditions['frontend_input'] = array('select', 'multiselect');
42
+ */
43
+ $conditions['frontend_input'] = array('select', 'textfilter', 'multiselect');
44
+ /* MT end */
45
+ $conditions['or']['is_filterable'] = array(1, 2);
46
+ $conditions['or']['is_visible_in_advanced_search'] = 1;
47
+ }
48
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogRule/Rule/Condition/Product.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_CatalogRule_Rule_Condition_Product extends Mage_CatalogRule_Model_Rule_Condition_Product
12
+ {
13
+
14
+ public function getValueElementType()
15
+ {
16
+ if ($this->getAttribute()==='attribute_set_id') {
17
+ return 'select';
18
+ }
19
+ if (!is_object($this->getAttributeObject())) {
20
+ return 'text';
21
+ }
22
+ switch ($this->getAttributeObject()->getFrontendInput()) {
23
+ case 'select':
24
+ return 'select';
25
+
26
+ /* MT start */
27
+ case 'textfilter':
28
+ return 'textfilter';
29
+ /* MT end */
30
+
31
+ case 'multiselect':
32
+ return 'multiselect';
33
+
34
+ case 'date':
35
+ return 'date';
36
+
37
+ default:
38
+ return 'text';
39
+ }
40
+ }
41
+
42
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogSearch/Advanced.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_CatalogSearch_Advanced extends Mage_CatalogSearch_Model_Advanced
12
+ {
13
+
14
+ protected function _addSearchCriteria($attribute, $value)
15
+ {
16
+ $name = $attribute->getFrontend()->getLabel();
17
+
18
+ if (is_array($value) && (isset($value['from']) || isset($value['to']))){
19
+ if (isset($value['currency'])) {
20
+ $currencyModel = Mage::getModel('directory/currency')->load($value['currency']);
21
+ $from = $currencyModel->format($value['from'], array(), false);
22
+ $to = $currencyModel->format($value['to'], array(), false);
23
+ } else {
24
+ $currencyModel = null;
25
+ }
26
+
27
+ if (strlen($value['from']) > 0 && strlen($value['to']) > 0) {
28
+ // -
29
+ $value = sprintf('%s - %s', ($currencyModel ? $from : $value['from']), ($currencyModel ? $to : $value['to']));
30
+ } elseif (strlen($value['from']) > 0) {
31
+ // and more
32
+ $value = Mage::helper('catalogsearch')->__('%s and greater', ($currencyModel ? $from : $value['from']));
33
+ } elseif (strlen($value['to']) > 0) {
34
+ // to
35
+ $value = Mage::helper('catalogsearch')->__('up to %s', ($currencyModel ? $to : $value['to']));
36
+ }
37
+ }
38
+
39
+ /* MT start
40
+ if (($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') && is_array($value)) {
41
+ */
42
+ if (($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'textfilter' || $attribute->getFrontendInput() == 'multiselect') && is_array($value)) {
43
+ /* MT end */
44
+ foreach ($value as $k=>$v){
45
+ $value[$k] = $attribute->getSource()->getOptionText($v);
46
+
47
+ if (is_array($value[$k]))
48
+ $value[$k] = $value[$k]['label'];
49
+ }
50
+ $value = implode(', ', $value);
51
+ /* MT start
52
+ } else if ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'multiselect') {
53
+ */
54
+ } else if ($attribute->getFrontendInput() == 'select' || $attribute->getFrontendInput() == 'textfilter' || $attribute->getFrontendInput() == 'multiselect') {
55
+ /* MT end */
56
+ $value = $attribute->getSource()->getOptionText($value);
57
+ if (is_array($value))
58
+ $value = $value['label'];
59
+ } else if ($attribute->getFrontendInput() == 'boolean') {
60
+ $value = $value == 1
61
+ ? Mage::helper('catalogsearch')->__('Yes')
62
+ : Mage::helper('catalogsearch')->__('No');
63
+ }
64
+
65
+ $searchCriterias = $this->_searchCriterias;
66
+ $searchCriterias[] = array('name'=>$name, 'value'=>$value);
67
+ return $searchCriterias;
68
+ }
69
+
70
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/CatalogSearch/Mysql4/Search/Collection.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_CatalogSearch_Mysql4_Search_Collection
12
+ extends Mage_CatalogSearch_Model_Mysql4_Search_Collection
13
+ {
14
+
15
+ protected function _isAttributeTextAndSearchable($attribute)
16
+ {
17
+ /* MT start
18
+ if (($attribute->getIsSearchable() && !in_array($attribute->getFrontendInput(), array('select', 'multiselect')))
19
+ */
20
+ if (($attribute->getIsSearchable() && !in_array($attribute->getFrontendInput(), array('select', 'textfilter', 'multiselect')))
21
+ /* MT end */
22
+ && (in_array($attribute->getBackendType(), array('varchar', 'text')) || $attribute->getBackendType() == 'static')) {
23
+ return true;
24
+ }
25
+ return false;
26
+ }
27
+
28
+ protected function _hasAttributeOptionsAndSearchable($attribute)
29
+ {
30
+ /* MT start
31
+ if ($attribute->getIsSearchable() && in_array($attribute->getFrontendInput(), array('select', 'multiselect'))) {
32
+ */
33
+ if ($attribute->getIsSearchable() && in_array($attribute->getFrontendInput(), array('select', 'textfilter', 'multiselect'))) {
34
+ /* MT end */
35
+ return true;
36
+ }
37
+
38
+ return false;
39
+ }
40
+
41
+ protected function _getSearchInOptionSql($query)
42
+ {
43
+ $attributeIds = array();
44
+ $attributeTables = array();
45
+ $storeId = (int)$this->getStoreId();
46
+
47
+ /**
48
+ * Collect attributes with options
49
+ */
50
+ foreach ($this->_getAttributesCollection() as $attribute) {
51
+ if ($this->_hasAttributeOptionsAndSearchable($attribute)) {
52
+ $attributeTables[$attribute->getFrontendInput()] = $attribute->getBackend()->getTable();
53
+ $attributeIds[] = $attribute->getId();
54
+ }
55
+ }
56
+ if (empty($attributeIds)) {
57
+ return false;
58
+ }
59
+
60
+ $resource = Mage::getSingleton('core/resource');
61
+ $optionTable = $resource->getTableName('eav/attribute_option');
62
+ $optionValueTable = $resource->getTableName('eav/attribute_option_value');
63
+ $attributesTable = $resource->getTableName('eav/attribute');
64
+
65
+ /**
66
+ * Select option Ids
67
+ */
68
+ $select = $this->getConnection()->select()
69
+ ->from(array('default'=>$optionValueTable), array('option_id','option.attribute_id', 'store_id'=>'IFNULL(store.store_id, default.store_id)', 'a.frontend_input'))
70
+ ->joinLeft(array('store'=>$optionValueTable),
71
+ $this->getConnection()->quoteInto('store.option_id=default.option_id AND store.store_id=?', $storeId),
72
+ array())
73
+ ->join(array('option'=>$optionTable),
74
+ 'option.option_id=default.option_id',
75
+ array())
76
+ ->join(array('a' => $attributesTable), 'option.attribute_id=a.attribute_id', array())
77
+ ->where('default.store_id=0')
78
+ ->where('option.attribute_id IN (?)', $attributeIds)
79
+ ->where('IFNULL(store.value, default.value) LIKE :search_query');
80
+ $options = $this->getConnection()->fetchAll($select, array('search_query'=>$this->_searchQuery));
81
+ if (empty($options)) {
82
+ return false;
83
+ }
84
+
85
+ // build selects of entity ids for specified options ids by frontend input
86
+ $select = array();
87
+ foreach (array(
88
+ 'select' => 'value = %d',
89
+ /* MT start */
90
+ 'textfilter' => 'value = %d',
91
+ /* MT end */
92
+ 'multiselect' => 'FIND_IN_SET(%d, value)')
93
+ as $frontendInput => $condition) {
94
+ if (isset($attributeTables[$frontendInput])) {
95
+ $where = array();
96
+ foreach ($options as $option) {
97
+ if ($frontendInput === $option['frontend_input']) {
98
+ $where[] = sprintf("attribute_id=%d AND store_id=%d AND {$condition}", $option['attribute_id'], $option['store_id'], $option['option_id']);
99
+ }
100
+ }
101
+ if ($where) {
102
+ $select[$frontendInput] = (string)$this->getConnection()->select()
103
+ ->from($attributeTables[$frontendInput], 'entity_id')
104
+ ->where(implode(' OR ', $where));
105
+ }
106
+ }
107
+ }
108
+
109
+ // search in catalogindex for products as part of configurable/grouped/bundle products (current store)
110
+ $where = array();
111
+ foreach ($options as $option) {
112
+ $where[] = sprintf('attribute_id=%d AND value=%d', $option['attribute_id'], $option['option_id']);
113
+ }
114
+ if ($where) {
115
+ $select[] = (string)$this->getConnection()->select()
116
+ ->from($resource->getTableName('catalogindex/eav'), 'entity_id')
117
+ ->where(implode(' OR ', $where))
118
+ ->where("store_id={$storeId}");
119
+ }
120
+
121
+ return implode(' UNION ', $select);
122
+ }
123
+
124
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/Eav/Entity/Attribute.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_Eav_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute
12
+ {
13
+
14
+ public function usesSource()
15
+ {
16
+ /* MT start
17
+ return $this->getFrontendInput()==='select' || $this->getFrontendInput()==='multiselect';
18
+ */
19
+ return $this->getFrontendInput()==='select' || $this->getFrontendInput()==='multiselect' || $this->getFrontendInput()==='textfilter';
20
+ /* MT end */
21
+ }
22
+
23
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/Eav/Entity/Attribute/Frontend/Default.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_Eav_Entity_Attribute_Frontend_Default extends Mage_Eav_Model_Entity_Attribute_Frontend_Default
12
+ {
13
+
14
+ public function getValue(Varien_Object $object)
15
+ {
16
+ $value = $object->getData($this->getAttribute()->getAttributeCode());
17
+ /* MT start
18
+ if (in_array($this->getConfigField('input'), array('select','boolean'))) {
19
+ */
20
+ if (in_array($this->getConfigField('input'), array('select','textfilter','boolean'))) {
21
+ /* MT end */
22
+ $valueOption = $this->getOption($value);
23
+ if (!$valueOption) {
24
+ $opt = new Mage_Eav_Model_Entity_Attribute_Source_Boolean();
25
+ if ($options = $opt->getAllOptions()) {
26
+ foreach ($options as $option) {
27
+ if ($option['value'] == $value) {
28
+ $valueOption = $option['label'];
29
+ }
30
+ }
31
+ }
32
+ }
33
+ $value = $valueOption;
34
+ }
35
+ elseif ($this->getConfigField('input')=='multiselect') {
36
+ $value = $this->getOption($value);
37
+ if (is_array($value)) {
38
+ $value = implode(', ', $value);
39
+ }
40
+ }
41
+ return $value;
42
+ }
43
+
44
+ }
app/code/community/Morningtime/TextfieldLayeredNav/Model/Eav/Mysql4/Entity/Attribute.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ class Morningtime_TextfieldLayeredNav_Model_Eav_Mysql4_Entity_Attribute extends Mage_Eav_Model_Mysql4_Entity_Attribute
12
+ {
13
+
14
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
15
+ {
16
+ $frontendLabel = $object->getFrontendLabel();
17
+ if (is_array($frontendLabel)) {
18
+ if (!isset($frontendLabel[0]) || is_null($frontendLabel[0]) || $frontendLabel[0]=='') {
19
+ Mage::throwException(Mage::helper('eav')->__('Frontend label is not defined'));
20
+ }
21
+ $object->setFrontendLabel($frontendLabel[0]);
22
+
23
+ if ($object->getData('modulePrefix')) {
24
+ $str = $object->getData('modulePrefix') . Mage_Core_Model_Translate::SCOPE_SEPARATOR . $frontendLabel[0];
25
+ }
26
+ else {
27
+ $str = $frontendLabel[0];
28
+ }
29
+ Mage::getModel('core/translate_string')
30
+ ->setString($str)
31
+ ->setTranslate($frontendLabel[0])
32
+ ->setStoreTranslations($frontendLabel)
33
+ ->save();
34
+ }
35
+ $applyTo = $object->getApplyTo();
36
+
37
+ if (is_array($applyTo)) {
38
+ $object->setApplyTo(implode(',', $applyTo));
39
+ }
40
+
41
+ /**
42
+ * @todo need use default source model of entity type !!!
43
+ */
44
+ if (!$object->getId()) {
45
+ /* MT start
46
+ if ($object->getFrontendInput()=='select') {
47
+ */
48
+ if ($object->getFrontendInput()=='select' || $object->getFrontendInput()=='textfilter') {
49
+ /* MT end */
50
+ $object->setSourceModel('eav/entity_attribute_source_table');
51
+ }
52
+
53
+
54
+ }
55
+
56
+ }
57
+
58
+ protected function _saveOption(Mage_Core_Model_Abstract $object)
59
+ {
60
+ $option = $object->getOption();
61
+ if (is_array($option)) {
62
+ $write = $this->_getWriteAdapter();
63
+ $optionTable = $this->getTable('attribute_option');
64
+ $optionValueTable = $this->getTable('attribute_option_value');
65
+ $stores = Mage::getModel('core/store')
66
+ ->getResourceCollection()
67
+ ->setLoadDefault(true)
68
+ ->load();
69
+
70
+ if (isset($option['value'])) {
71
+ $attributeDefaultValue = array();
72
+ if (!is_array($object->getDefault())) {
73
+ $object->setDefault(array());
74
+ }
75
+
76
+ foreach ($option['value'] as $optionId => $values) {
77
+ $intOptionId = (int) $optionId;
78
+ if (!empty($option['delete'][$optionId])) {
79
+ if ($intOptionId) {
80
+ $condition = $write->quoteInto('option_id=?', $intOptionId);
81
+ $write->delete($optionTable, $condition);
82
+ }
83
+
84
+ continue;
85
+ }
86
+
87
+ if (!$intOptionId) {
88
+ $data = array(
89
+ 'attribute_id' => $object->getId(),
90
+ 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
91
+ );
92
+ $write->insert($optionTable, $data);
93
+ $intOptionId = $write->lastInsertId();
94
+ }
95
+ else {
96
+ $data = array(
97
+ 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
98
+ );
99
+ $write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
100
+ }
101
+
102
+ if (in_array($optionId, $object->getDefault())) {
103
+ if ($object->getFrontendInput() == 'multiselect') {
104
+ $attributeDefaultValue[] = $intOptionId;
105
+ /* MT start
106
+ } else if ($object->getFrontendInput() == 'select') {
107
+ */
108
+ } else if ($object->getFrontendInput() == 'select' || $object->getFrontendInput() == 'textfilter') {
109
+ /* MT end */
110
+ $attributeDefaultValue = array($intOptionId);
111
+ }
112
+ }
113
+
114
+
115
+ // Default value
116
+ if (!isset($values[0])) {
117
+ Mage::throwException(Mage::helper('eav')->__('Default option value is not defined'));
118
+ }
119
+
120
+ $write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
121
+ foreach ($stores as $store) {
122
+ if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
123
+ $data = array(
124
+ 'option_id' => $intOptionId,
125
+ 'store_id' => $store->getId(),
126
+ 'value' => $values[$store->getId()],
127
+ );
128
+ $write->insert($optionValueTable, $data);
129
+ }
130
+ }
131
+ }
132
+
133
+ $write->update($this->getMainTable(), array(
134
+ 'default_value' => implode(',', $attributeDefaultValue)
135
+ ), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
136
+ }
137
+ }
138
+ return $this;
139
+ }
140
+
141
+ }
app/code/community/Morningtime/TextfieldLayeredNav/controllers/Adminhtml/Catalog/Product/AttributeController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+
11
+ include_once("Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php");
12
+ class Morningtime_TextfieldLayeredNav_Adminhtml_Catalog_Product_AttributeController extends Mage_Adminhtml_Catalog_Product_AttributeController
13
+ {
14
+
15
+ public function editAction()
16
+ {
17
+ $id = $this->getRequest()->getParam('attribute_id');
18
+ $model = Mage::getModel('catalog/entity_attribute');
19
+
20
+ if ($id) {
21
+ $model->load($id);
22
+
23
+ if (! $model->getId()) {
24
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('This attribute no longer exists'));
25
+ $this->_redirect('*/*/');
26
+ return;
27
+ }
28
+
29
+ // entity type check
30
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
31
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('You cannot edit this attribute'));
32
+ $this->_redirect('*/*/');
33
+ return;
34
+ }
35
+ }
36
+
37
+ // set entered data if was error when we do save
38
+ $data = Mage::getSingleton('adminhtml/session')->getAttributeData(true);
39
+ if (! empty($data)) {
40
+ $model->setData($data);
41
+ }
42
+
43
+ Mage::register('entity_attribute', $model);
44
+
45
+ $this->_initAction()
46
+ ->_addBreadcrumb($id ? Mage::helper('catalog')->__('Edit Product Attribute') : Mage::helper('catalog')->__('New Product Attribute'), $id ? Mage::helper('catalog')->__('Edit Product Attribute') : Mage::helper('catalog')->__('New Product Attribute'))
47
+ ->_addContent($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit')->setData('action', $this->getUrl('*/catalog_product_attribute/save')))
48
+ ->_addLeft($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_edit_tabs'))
49
+ ->_addJs(
50
+ $this->getLayout()->createBlock('adminhtml/template')
51
+ ->setIsPopup((bool)$this->getRequest()->getParam('popup'))
52
+ ->setTemplate('morningtime/textfieldlayerednav/catalog/product/attribute/js.phtml')
53
+ )
54
+ ->renderLayout();
55
+ }
56
+
57
+ }
app/code/community/Morningtime/TextfieldLayeredNav/etc/config.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Morningtime
5
+ * TextfieldLayeredNav module
6
+ *
7
+ * @category Morningtime
8
+ * @package Morningtime_TextfieldLayeredNav
9
+ * @author Mathijs Koenraadt (info@morningtime.com)
10
+ * @copyright Copyright (c) 2009 Morningtime, http://www.morningtime.com
11
+ * @license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
12
+ */
13
+ -->
14
+ <config>
15
+ <modules>
16
+ <Morningtime_TextfieldLayeredNav>
17
+ <version>1.3.2.1</version>
18
+ </Morningtime_TextfieldLayeredNav>
19
+ </modules>
20
+ <global>
21
+ <blocks>
22
+ <adminhtml>
23
+ <rewrite>
24
+ <catalog_product_attribute_edit_tab_main>Morningtime_TextfieldLayeredNav_Block_Adminhtml_Catalog_Product_Attribute_Edit_Tab_Main</catalog_product_attribute_edit_tab_main>
25
+ <catalog_product_attribute_edit_tab_options>Morningtime_TextfieldLayeredNav_Block_Adminhtml_Catalog_Product_Attribute_Edit_Tab_Options</catalog_product_attribute_edit_tab_options>
26
+ <catalog_product_edit_tab_attributes>Morningtime_TextfieldLayeredNav_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes</catalog_product_edit_tab_attributes>
27
+ </rewrite>
28
+ </adminhtml>
29
+ <catalog>
30
+ <rewrite>
31
+ <product_compare_list>Morningtime_TextfieldLayeredNav_Block_Catalog_Product_Compare_List</product_compare_list>
32
+ </rewrite>
33
+ </catalog>
34
+ <catalogsearch>
35
+ <rewrite>
36
+ <advanced_form>Morningtime_TextfieldLayeredNav_Block_CatalogSearch_Advanced_Form</advanced_form>
37
+ </rewrite>
38
+ </catalogsearch>
39
+ </blocks>
40
+ <models>
41
+ <catalog>
42
+ <rewrite>
43
+ <resource_eav_attribute>Morningtime_TextfieldLayeredNav_Model_Catalog_Resource_Eav_Attribute</resource_eav_attribute>
44
+ <entity_attribute>Morningtime_TextfieldLayeredNav_Model_Catalog_Entity_Attribute</entity_attribute>
45
+ </rewrite>
46
+ </catalog>
47
+ <catalog_resource_eav_mysql4>
48
+ <rewrite>
49
+ <product>Morningtime_TextfieldLayeredNav_Model_Catalog_Resource_Eav_Mysql4_Product</product>
50
+ </rewrite>
51
+ </catalog_resource_eav_mysql4>
52
+ <catalogindex>
53
+ <rewrite>
54
+ <indexer_eav>Morningtime_TextfieldLayeredNav_Model_CatalogIndex_Indexer_Eav</indexer_eav>
55
+ </rewrite>
56
+ </catalogindex>
57
+ <catalogrule>
58
+ <rewrite>
59
+ <rule_condition_product>Morningtime_TextfieldLayeredNav_Model_CatalogRule_Rule_Condition_Product</rule_condition_product>
60
+ </rewrite>
61
+ </catalogrule>
62
+ <catalogsearch>
63
+ <rewrite>
64
+ <advanced>Morningtime_TextfieldLayeredNav_Model_CatalogSearch_Advanced</advanced>
65
+ <mysql4_search_collection>Morningtime_TextfieldLayeredNav_Model_CatalogSearch_Mysql4_Search_Collection</mysql4_search_collection>
66
+ </rewrite>
67
+ </catalogsearch>
68
+ <eav>
69
+ <rewrite>
70
+ <entity_attribute_frontend_default>Morningtime_TextfieldLayeredNav_Model_Eav_Entity_Attribute_Frontend_Default</entity_attribute_frontend_default>
71
+ <entity_attribute>Morningtime_TextfieldLayeredNav_Model_Eav_Entity_Attribute</entity_attribute>
72
+ </rewrite>
73
+ </eav>
74
+ <eav_mysql4>
75
+ <rewrite>
76
+ <entity_attribute>Morningtime_TextfieldLayeredNav_Model_Eav_Mysql4_Entity_Attribute</entity_attribute>
77
+ </rewrite>
78
+ </eav_mysql4>
79
+ </models>
80
+ </global>
81
+ <admin>
82
+ <routers>
83
+ <adminhtml>
84
+ <args>
85
+ <modules>
86
+ <Morningtime_TextfieldLayeredNav_Adminhtml before="Mage_Adminhtml">Morningtime_TextfieldLayeredNav_Adminhtml</Morningtime_TextfieldLayeredNav_Adminhtml>
87
+ </modules>
88
+ </args>
89
+ </adminhtml>
90
+ </routers>
91
+ </admin>
92
+ </config>
app/design/adminhtml/default/default/template/morningtime/textfieldlayerednav/catalog/product/attribute/js.phtml ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Morningtime
4
+ * TextfieldLayeredNav module
5
+ *
6
+ * @category Morningtime
7
+ * @package Morningtime_TextfieldLayeredNav
8
+ * @author Mathijs Koenraadt (info@morningtime.com)
9
+ */
10
+ ?>
11
+ <script type="text/javascript">
12
+ function saveAndContinueEdit(){
13
+ editForm.submit($('edit_form').action+'back/edit/tab/' + product_attribute_tabsJsTabs.activeTab.id);
14
+ }
15
+
16
+
17
+ function toggleApplyVisibility(select) {
18
+ if ($(select).value == 1) {
19
+ $(select).next('select').removeClassName('no-display');
20
+ $(select).next('select').removeClassName('ignore-validate');
21
+
22
+ } else {
23
+ $(select).next('select').addClassName('no-display');
24
+ $(select).next('select').addClassName('ignore-validate');
25
+ var options = $(select).next('select').options;
26
+ for( var i=0; i < options.length; i++) {
27
+ options[i].selected = false;
28
+ }
29
+ }
30
+ }
31
+
32
+ function checkOptionsPanelVisibility(){
33
+ if($('matage-options-panel')){
34
+ var panel = $('matage-options-panel');
35
+ /* MT start
36
+ if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect')){
37
+ */
38
+ if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='textfilter')){
39
+ /* MT end */
40
+ panel.show();
41
+ }
42
+ else {
43
+ panel.hide();
44
+ }
45
+ }
46
+ }
47
+
48
+ function bindAttributeInputType()
49
+ {
50
+ checkOptionsPanelVisibility();
51
+ switchDefaultValueField();
52
+ checkIsConfigurableVisibility();
53
+ /* MT start
54
+ if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
55
+ */
56
+ if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' | $('frontend_input').value=='textfilter' || $('frontend_input').value=='price')){
57
+ /* MT end */
58
+ if($('is_filterable')){
59
+ $('is_filterable').disabled = false;
60
+ }
61
+ if($('is_filterable_in_search')){
62
+ $('is_filterable_in_search').disabled = false;
63
+ }
64
+ if($('backend_type') && $('backend_type').options){
65
+ for(var i=0;i<$('backend_type').options.length;i++){
66
+ if($('backend_type').options[i].value=='int') $('backend_type').selectedIndex = i;
67
+ }
68
+ }
69
+ }
70
+ else {
71
+ if($('is_filterable')){
72
+ $('is_filterable').selectedIndex=0;
73
+ $('is_filterable').disabled = true;
74
+ }
75
+ if($('is_filterable_in_search')){
76
+ $('is_filterable_in_search').disabled = true;
77
+ }
78
+ }
79
+
80
+ if ($('frontend_input') && ($('frontend_input').value=='multiselect'
81
+ || $('frontend_input').value=='gallery'
82
+ || $('frontend_input').value=='textarea')) {
83
+ if ($('used_for_sort_by')) {
84
+ $('used_for_sort_by').disabled = true;
85
+ }
86
+ }
87
+ else {
88
+ if ($('used_for_sort_by')) {
89
+ $('used_for_sort_by').disabled = false;
90
+ }
91
+ }
92
+
93
+ if ($('frontend_input') && ($('frontend_input').value=='text' || $('frontend_input').value=='textarea')) {
94
+ if($('is_html_allowed_on_front')){
95
+ $('is_html_allowed_on_front').disabled = false;
96
+ }
97
+ }
98
+ else {
99
+ if($('is_html_allowed_on_front')){
100
+ $('is_html_allowed_on_front').selectedIndex=0;
101
+ $('is_html_allowed_on_front').disabled = true;
102
+ }
103
+ }
104
+
105
+ switchIsFilterable();
106
+ }
107
+
108
+ function switchIsFilterable()
109
+ {
110
+ if ($('is_filterable')) {
111
+ if ($('is_filterable').selectedIndex == 0) {
112
+ $('position').disabled = true;
113
+ } else {
114
+ $('position').disabled = false;
115
+ }
116
+ }
117
+ }
118
+
119
+ function disableApplyToValue(value)
120
+ {
121
+ var applyToSelect = $('apply_to');
122
+ for (i=0;i<applyToSelect.options.length;i++) {
123
+ if (value == applyToSelect.options[i].value) {
124
+ applyToSelect.options[i].disabled = true;
125
+ applyToSelect.options[i].selected = false;
126
+ }
127
+ }
128
+ }
129
+
130
+ function switchDefaultValueField()
131
+ {
132
+ if (!$('frontend_input')) {
133
+ return;
134
+ }
135
+
136
+ var currentValue = $('frontend_input').value;
137
+
138
+ var defaultValueTextVisibility = false;
139
+ var defaultValueTextareaVisibility = false;
140
+ var defaultValueDateVisibility = false;
141
+ var defaultValueYesnoVisibility = false;
142
+ var scopeVisibility = true;
143
+
144
+ switch (currentValue) {
145
+ case 'select':
146
+ optionDefaultInputType = 'radio';
147
+ break;
148
+
149
+ /* MT start */
150
+ case 'textfilter':
151
+ optionDefaultInputType = 'radio';
152
+ break;
153
+ /* MT end */
154
+
155
+ case 'multiselect':
156
+ optionDefaultInputType = 'checkbox';
157
+ break;
158
+
159
+ case 'date':
160
+ defaultValueDateVisibility = true;
161
+ break;
162
+
163
+ case 'boolean':
164
+ defaultValueYesnoVisibility = true;
165
+ break;
166
+
167
+ case 'textarea':
168
+ defaultValueTextareaVisibility = true;
169
+ break;
170
+
171
+ case 'media_image':
172
+ defaultValueTextVisibility = false;
173
+ break;
174
+ case 'price':
175
+ scopeVisibility = false;
176
+ default:
177
+ defaultValueTextVisibility = true;
178
+ break;
179
+ }
180
+
181
+ var applyToSelect = $('apply_to');
182
+ switch (currentValue) {
183
+ <?php foreach (Mage::helper('catalog')->getAttributeDisabledTypes() as $type=>$disabled): ?>
184
+ case '<?php echo $type; ?>':
185
+ <?php foreach ($disabled as $one): ?>
186
+ disableApplyToValue('<?php echo $one; ?>');
187
+ <?php endforeach; ?>
188
+ break;
189
+ <?php endforeach; ?>
190
+ default:
191
+ for (i=0;i<applyToSelect.options.length;i++) {
192
+ applyToSelect.options[i].disabled = false;
193
+ }
194
+ break;
195
+ }
196
+
197
+ switch (currentValue) {
198
+ case 'media_image':
199
+ $('front_fieldset').previous().hide();
200
+ $('front_fieldset').hide();
201
+
202
+ setRowVisibility('is_required', false);
203
+ setRowVisibility('is_unique', false);
204
+ setRowVisibility('frontend_class', false);
205
+ break;
206
+
207
+ <?php foreach (Mage::helper('catalog')->getAttributeHiddenFields() as $type=>$fields): ?>
208
+ case '<?php echo $type; ?>':
209
+ <?php foreach ($fields as $one): ?>
210
+ <?php if ($one == '_front_fieldset'): ?>
211
+ $('front_fieldset').previous().hide();
212
+ $('front_fieldset').hide();
213
+ <?php elseif ($one == '_default_value'): ?>
214
+ defaultValueTextVisibility =
215
+ defaultValueTextareaVisibility =
216
+ defaultValueDateVisibility =
217
+ defaultValueYesnoVisibility = false;
218
+ <?php elseif ($one == '_scope'): ?>
219
+ scopeVisibility = false;
220
+ <?php else: ?>
221
+ setRowVisibility('<?php echo $one; ?>', false);
222
+ <?php endif; ?>
223
+ <?php endforeach; ?>
224
+ break;
225
+ <?php endforeach; ?>
226
+
227
+ default:
228
+ $('front_fieldset').previous().show();
229
+ $('front_fieldset').show();
230
+ setRowVisibility('is_required', true);
231
+ setRowVisibility('is_unique', true);
232
+ setRowVisibility('frontend_class', true);
233
+ setRowVisibility('is_configurable', true);
234
+ break;
235
+ }
236
+
237
+ setRowVisibility('default_value_text', defaultValueTextVisibility);
238
+ setRowVisibility('default_value_textarea', defaultValueTextareaVisibility);
239
+ setRowVisibility('default_value_date', defaultValueDateVisibility);
240
+ setRowVisibility('default_value_yesno', defaultValueYesnoVisibility);
241
+ setRowVisibility('is_global', scopeVisibility);
242
+
243
+ var elems = document.getElementsByName('default[]');
244
+ for (var i = 0; i < elems.length; i++) {
245
+ elems[i].type = optionDefaultInputType;
246
+ }
247
+ }
248
+
249
+ function setRowVisibility(id, isVisible)
250
+ {
251
+ if ($(id)) {
252
+ var td = $(id).parentNode;
253
+ var tr = $(td.parentNode);
254
+
255
+ if (isVisible) {
256
+ tr.show();
257
+ } else {
258
+ tr.blur();
259
+ tr.hide();
260
+ }
261
+ }
262
+ }
263
+
264
+ function checkIsConfigurableVisibility()
265
+ {
266
+ if (!$('is_configurable') || !$('is_global') || !$('frontend_input')) return;
267
+ /* MT start
268
+ if ($F('is_global')==1 && $F('frontend_input')=='select') {
269
+ */
270
+ if ($F('is_global')==1 && ($F('frontend_input')=='select' || $F('frontend_input')=='textfilter')) {
271
+ /* MT end */
272
+ setRowVisibility('is_configurable', true);
273
+ } else {
274
+ setRowVisibility('is_configurable', false);
275
+ }
276
+ }
277
+
278
+ function updateRequriedOptions()
279
+ {
280
+ /* MT start
281
+ if ($F('frontend_input')=='select' && $F('is_required')==1) {
282
+ */
283
+ if (($F('frontend_input')=='select' || $F('frontend_input')=='textfilter') && $F('is_required')==1) {
284
+ /* MT end */
285
+ $('option-count-check').addClassName('required-options-count');
286
+ } else {
287
+ $('option-count-check').removeClassName('required-options-count');
288
+ }
289
+ }
290
+
291
+ if($('frontend_input')){
292
+ Event.observe($('frontend_input'), 'change', updateRequriedOptions);
293
+ Event.observe($('frontend_input'), 'change', bindAttributeInputType);
294
+ Event.observe($('is_global'), 'change', checkIsConfigurableVisibility);
295
+ }
296
+
297
+ if ($('is_filterable')) {
298
+ Event.observe($('is_filterable'), 'change', switchIsFilterable);
299
+ }
300
+
301
+ if ($('is_required')) {
302
+ Event.observe($('is_required'), 'change', updateRequriedOptions);
303
+ }
304
+ bindAttributeInputType();
305
+
306
+ </script>
app/etc/modules/Morningtime_TextfieldLayeredNav.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Morningtime
5
+ * TextfieldLayeredNav module
6
+ *
7
+ * @category Morningtime
8
+ * @package Morningtime_TextfieldLayeredNav
9
+ * @author Mathijs Koenraadt (info@morningtime.com)
10
+ * @copyright Copyright (c) 2009 Morningtime, http://www.morningtime.com
11
+ * @license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
12
+ */
13
+ -->
14
+ <config>
15
+ <modules>
16
+ <Morningtime_TextfieldLayeredNav>
17
+ <active>true</active>
18
+ <codePool>community</codePool>
19
+ <depends>
20
+ <Mage_Catalog />
21
+ </depends>
22
+ <version>1.3.2.1</version>
23
+ </Morningtime_TextfieldLayeredNav>
24
+ </modules>
25
+ </config>
lib/Varien/Data/Form/Element/Textfilter.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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 Varien
22
+ * @package Varien_Data
23
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Form text element
29
+ *
30
+ * @category Varien
31
+ * @package Varien_Data
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Varien_Data_Form_Element_Textfilter extends Varien_Data_Form_Element_Abstract
35
+ {
36
+ public function __construct($attributes=array())
37
+ {
38
+ parent::__construct($attributes);
39
+ $this->setType('text');
40
+ $this->setExtType('textfield');
41
+ }
42
+
43
+ public function getHtml()
44
+ {
45
+ $this->addClass('input-text');
46
+ return parent::getHtml();
47
+ }
48
+
49
+ public function getElementHtml()
50
+ {
51
+
52
+ $values = $this->getValues();
53
+ if (sizeof($values) > 1) {
54
+ $logic = array();
55
+ foreach ($values as $value) {
56
+ $logic[$value['value']] = $value['label'];
57
+ }
58
+ if ($this->getEscapedValue() == 0) {
59
+ $val = "";
60
+ } else {
61
+ $val = $logic[$this->getEscapedValue()];
62
+ }
63
+ } else {
64
+ $val = "";
65
+ }
66
+
67
+ $html = '<input id="'.$this->getHtmlId().'" name="'.$this->getName()
68
+ .'" value="'.stripslashes($val).'" '.$this->serialize($this->getHtmlAttributes()).'/>'."\n";
69
+ $html.= $this->getAfterElementHtml();
70
+ return $html;
71
+ }
72
+
73
+ public function getHtmlAttributes()
74
+ {
75
+ return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'readonly', 'maxlength');
76
+ }
77
+ }
package.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Morningtime_TextfieldLayeredNav</name>
4
+ <version>1.3.2.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Until now, you could only use Dropdown and Multiselect attributes for layered navigation. This extension adds a new texfield element, called textfilter.</summary>
10
+ <description>== WHAT DOES IT DO? ==
11
+ This is an admin module only. You can setup an attribute with "Textfield for Filter" as type. Now you can enter text on the product edit page (textfield). The entered data can be used for Layered Navigation, because it functions like a Magento Dropdown.
12
+
13
+ The advantage is, you don't need to go back to the attribute option page to add a new option every t ime. You can add options directly on the fly when creating products.
14
+
15
+ See screenshots for better understanding.
16
+
17
+ == INSTALLATION ==
18
+ - Get key from Magento Connect
19
+ - Install via Connect Manager
20
+ - Refresh cache
21
+ - Re-login to admin
22
+
23
+ == CONFIGURATION ==
24
+ No config settings.
25
+
26
+ == USAGE ==
27
+ Add a new product attribute and choose "Textfield for Filter" instead of Dropdown or Multiselect. "Textfilter" is a textfield that can be used for layered navigation!
28
+
29
+ Rebuild your search indexes (cache).
30
+
31
+ == CUSTOMIZATION ==
32
+ No options available.</description>
33
+ <notes>Stable Release</notes>
34
+ <authors><author><name>Mathijs Koenraadt (MSc)</name><user>auto-converted</user><email>info@morningtime.com</email></author></authors>
35
+ <date>2009-06-24</date>
36
+ <time>14:12:12</time>
37
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="morningtime"><dir name="textfieldlayerednav"><dir name="catalog"><dir name="product"><dir name="attribute"><file name="js.phtml" hash="e28eb1c566381048b000c16f63fcb8d9"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Morningtime_TextfieldLayeredNav.xml" hash="04d99f1c93b4ea0598a2651ac01785e2"/></dir></target><target name="magecommunity"><dir name="Morningtime"><dir name="TextfieldLayeredNav"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Main.php" hash="b2bae8c5e2d77927cc923a0e82c57635"/><file name="Options.php" hash="df916a987b2647e3009f8553051f3142"/></dir></dir></dir><dir name="Edit"><dir name="Tab"><file name="Attributes.php" hash="2fed5f68e944cf2a00278c6f9c1bd181"/></dir></dir></dir></dir></dir><dir name="CatalogSearch"><dir name="Advanced"><file name="Form.php" hash="98ec46f050d5bcb19baa39881fe8362d"/></dir></dir><dir name="Catalog"><dir name="Product"><dir name="Compare"><file name="List.php" hash="986c1e5a9a39860575f12fa89a471db8"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="AttributeController.php" hash="ce84c2d2499ca04f367aee4a44dde0c1"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="edc196e2001b0bba18fc627dcfdbd39b"/></dir><dir name="Model"><dir name="CatalogIndex"><dir name="Indexer"><file name="Eav.php" hash="b6a2cebae4472f6a7d8fc454108d0b0c"/></dir></dir><dir name="CatalogRule"><dir name="Rule"><dir name="Condition"><file name="Product.php" hash="59c56dcea83bedbcfdea86098f95589c"/></dir></dir></dir><dir name="CatalogSearch"><file name="Advanced.php" hash="11ead71aa5f7fc84c458f2300ef7339b"/><dir name="Mysql4"><dir name="Search"><file name="Collection.php" hash="192ff7e112757cb4546b72d3fc032f66"/></dir></dir></dir><dir name="Catalog"><dir name="Entity"><file name="Attribute.php" hash="983198e589726391c2ffbc7688e9cf0e"/></dir><dir name="Resource"><dir name="Eav"><file name="Attribute.php" hash="50116c0d286f468c02a18a9399b242b2"/><dir name="Mysql4"><file name="Product.php" hash="ae44a7dc154263469b540b371fd2e3fa"/></dir></dir></dir></dir><dir name="Eav"><dir name="Entity"><file name="Attribute.php" hash="3283d0d1246180d566999050ffded866"/><dir name="Attribute"><dir name="Frontend"><file name="Default.php" hash="1e9448a83ab954d77b4c701bae48df7c"/></dir></dir></dir><dir name="Mysql4"><dir name="Entity"><file name="Attribute.php" hash="98d9dc4622ed297fa9597f96e5057922"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Varien"><dir name="Data"><dir name="Form"><dir name="Element"><file name="Textfilter.php" hash="34f421cec04b6ed4b011238fdffa3ffb"/></dir></dir></dir></dir></target></contents>
38
+ <compatible/>
39
+ <dependencies/>
40
+ </package>