From 8b94f6213ebdef047b1e4c057ad2e805dbe8ad53 Mon Sep 17 00:00:00 2001 From: Marius Strajeru Date: Mon, 23 Mar 2015 10:49:35 +0200 Subject: [PATCH] v2.2.0 --- README.md | 43 +++++--- .../Product/View/Type/Configurable/Config.php | 15 ++- .../Easylife/Switcher/etc/config.xml | 4 +- .../base/default/layout/easylife_switcher.xml | 100 +++++++++--------- .../view/type/configurable/config.phtml | 68 ++++++------ app/etc/modules/Easylife_Switcher.xml | 22 ++-- app/locale/es_ES/Easylife_Switcher.csv | 98 ++++++++--------- js/easylife_switcher/product.js | 13 ++- .../default/css/easylife_switcher/styles.css | 1 - 9 files changed, 196 insertions(+), 168 deletions(-) diff --git a/README.md b/README.md index c8200e8..703d1cd 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,26 @@ -Easylife Switcher -======== - -Configurable products switcher v2.1.1 - -This is a Magento extension that allows you to change the configurable products dropdowns to labels, colors or images. -It also allows you to set default configurations, keep the selected options when changing an option from above. -You can also change the product image or entire media block when the congiruable option is changed and display the simple product image or media block. -For a full list of features with screenshots included check the [Features list] (https://github.com/tzyganu/Switcher/wiki/features) and the [Configuration](https://github.com/tzyganu/Switcher/wiki/configuration) section. - -Please visit the [wiki](https://github.com/tzyganu/Switcher/wiki) for a full description. - -Extension is compatible with CE versions 1.7 and after. -The CE 1.9.1 version already comes with a configurable swatches extension. -If you use this extension and disable the core configurable swatches it works without an issue. -If you have both of them enabled, this extension shamelessly hides the elements generated by the core module. -It still seams to work, but test carefully specially if you use a custom theme. +Easylife Switcher +======== + +Configurable products switcher v2.2.0 + +Notice +---------- + +Most probably version 2.2.0 is going to be the last version of this module (unless someone finds a flagrant bug). +Magento already has a color swatch module included in the core starting with version 1.9.1 Use that one. + +What it does +------- + +This is a Magento extension that allows you to change the configurable products dropdowns to labels, colors or images. +It also allows you to set default configurations, keep the selected options when changing an option from above. +You can also change the product image or entire media block when the congiruable option is changed and display the simple product image or media block. +For a full list of features with screenshots included check the [Features list] (https://github.com/tzyganu/Switcher/wiki/features) and the [Configuration](https://github.com/tzyganu/Switcher/wiki/configuration) section. + +Please visit the [wiki](https://github.com/tzyganu/Switcher/wiki) for a full description. + +Extension is compatible with CE versions 1.7 and after. +The CE 1.9.1 version already comes with a configurable swatches extension. +If you use this extension and disable the core configurable swatches it works without an issue. +If you have both of them enabled, this extension shamelessly hides the elements generated by the core module. +It still seams to work, but test carefully specially if you use a custom theme. diff --git a/app/code/community/Easylife/Switcher/Block/Catalog/Product/View/Type/Configurable/Config.php b/app/code/community/Easylife/Switcher/Block/Catalog/Product/View/Type/Configurable/Config.php index f307397..b1384b2 100644 --- a/app/code/community/Easylife/Switcher/Block/Catalog/Product/View/Type/Configurable/Config.php +++ b/app/code/community/Easylife/Switcher/Block/Catalog/Product/View/Type/Configurable/Config.php @@ -269,6 +269,7 @@ public function getJsonAdditionalConfig() $config['switch_media_callback'] = Mage::getStoreConfig(self::XML_MEDIA_CALLBACK_PATH); $config['allow_no_stock_select'] = $this->getAllowNoStockSelect(); $config['keep_values'] = Mage::getStoreConfigFlag(self::XML_KEEP_SELECTED_VALUES); + $config['image_size'] = $this->_getImageDimensions(self::XML_OPTIONS_IMAGE_RESIZE); if (!$this->getProduct()->hasPreconfiguredValues()) { if ($this->getDefaultValues()) { @@ -487,9 +488,19 @@ public function getSwitchImages() if (!empty($dimensions)) { $image->resize($dimensions[0], $dimensions[1]); } - $images[$id][$product->getId()] = (string)$image; + $images[$id][$product->getId()]['src'] = (string)$image; + $label = $product->getData('image_label'); + if (empty($label)) { + $label = $product->getName(); + } + $images[$id][$product->getId()]['alt'] = $this->escapeHtml($label); } elseif (Mage::getStoreConfigFlag(self::XML_USE_CONF_IMAGE)) { - $images[$id][$product->getId()] = (string)$this->getConfProductImage(); + $images[$id][$product->getId()] ['src']= (string)$this->getConfProductImage(); + $label = $this->getProduct()->getData('image_label'); + if (empty($label)) { + $label = $this->getProduct()->getName(); + } + $images[$id][$product->getId()]['alt'] = $this->escapeHtml($label); } } } diff --git a/app/code/community/Easylife/Switcher/etc/config.xml b/app/code/community/Easylife/Switcher/etc/config.xml index 0e605c7..8c3a57c 100644 --- a/app/code/community/Easylife/Switcher/etc/config.xml +++ b/app/code/community/Easylife/Switcher/etc/config.xml @@ -19,7 +19,7 @@ - 2.1.1 + 2.2.0 @@ -41,7 +41,7 @@ Easylife_Switcher_Model_Resource - + easylife_switcher_hascode
diff --git a/app/design/frontend/base/default/layout/easylife_switcher.xml b/app/design/frontend/base/default/layout/easylife_switcher.xml index 3268b78..149e924 100644 --- a/app/design/frontend/base/default/layout/easylife_switcher.xml +++ b/app/design/frontend/base/default/layout/easylife_switcher.xml @@ -1,51 +1,51 @@ - - - - - - - easylife_switcher/event.simulate.js - - - easylife_switcher/product.js - - - css/easylife_switcher/styles.css - - - skin_js - js/configurableswatches/product-media.js - - - skin_js - js/configurableswatches/swatches-product.js - - - - - - + + + + + + + easylife_switcher/event.simulate.js + + + easylife_switcher/product.js + + + css/easylife_switcher/styles.css + + + skin_js + js/configurableswatches/product-media.js + + + skin_js + js/configurableswatches/swatches-product.js + + + + + + \ No newline at end of file diff --git a/app/design/frontend/base/default/template/easylife_switcher/catalog/product/view/type/configurable/config.phtml b/app/design/frontend/base/default/template/easylife_switcher/catalog/product/view/type/configurable/config.phtml index 39ed7ba..13272af 100644 --- a/app/design/frontend/base/default/template/easylife_switcher/catalog/product/view/type/configurable/config.phtml +++ b/app/design/frontend/base/default/template/easylife_switcher/catalog/product/view/type/configurable/config.phtml @@ -1,35 +1,35 @@ - -isEnabled()) : ?> - + +isEnabled()) : ?> + \ No newline at end of file diff --git a/app/etc/modules/Easylife_Switcher.xml b/app/etc/modules/Easylife_Switcher.xml index a034685..844f8fe 100644 --- a/app/etc/modules/Easylife_Switcher.xml +++ b/app/etc/modules/Easylife_Switcher.xml @@ -1,12 +1,12 @@ - - - - - community - true - - - - - + + + + + community + true + + + + + \ No newline at end of file diff --git a/app/locale/es_ES/Easylife_Switcher.csv b/app/locale/es_ES/Easylife_Switcher.csv index 1becd51..7616d3e 100644 --- a/app/locale/es_ES/Easylife_Switcher.csv +++ b/app/locale/es_ES/Easylife_Switcher.csv @@ -1,49 +1,49 @@ -"Allow out of stock products to be selected","Permitir seleccionar productos sin existencias" -Attribute,Atributo -"Autoselect first option if none specified","Autoseleccionar primera opción si no hay ninguna seleccionada" -"Block type for media section. Leave empty to use default","Tipo bloque para la sección media. Dejar vacío para utilizar la opción por defecto" -Cancel,Cancelar -"Change images when these attributes are changed","Cambiar imagen cuando estos atributos cambien" -"Change media content when these attributes are changed","Cambiar contenido media cuando estos atributos cambien" -"Changing the configurable value of these attributes will trigger the main image to change, if available.","Cambiando el valor de los atributos hará que la imagen principal cambie, si está disponible." -"Changing the configurable value of these attributes will trigger the media block to change.","Cambiando el valor de los atributos hará que el bloque media cambie." -Colors,Colores -"Configurable attributes transforms","Transformaciones de los atributos configurables" -"Configure Colors","Configurar colores" -"Configure Images","Configurar imágenes" -"Custom images","Imágenes personalizadas" -Default,Por defecto -"Dom Media block selector","Selector DOM del bloque media" -"Dom selector for main image","Selector DOM para imagen principal" -"Easylife Switcher","Easylife Switcher" -Enabled,Habilitado -"Fill Options","Rellenar opciones" -Images,Imágenes -"JS callback to be executed after the main image is changed.","JS callback que se ejecutará al cambiar la imagen principal." -"JS callback to be executed after the media block is changed.","JS callback que se ejecutará al cambiar el bloque ." -"Keep previously selected values","Mantener valores seleccionados previamente" -"Label / Options image size","Etiqueta / Opciones tamaño de imagen" -Labels,Etiquetas -"Main image size","Tamaño imagen principal" -"No image switch","Sin cambio de imagen" -"No transformation","Sin transformación" -"Prototype expression that selects the main image element","Expresión Prototype que selecciona el elemento de la imagen principal" -"Prototype expression that selects the media block container","Expresión Prototype que selecciona el contenedor del bloque media" -"Recommended if you have 2 or more configurable attributes.","Recomendado si tiene 2 o más atributos en el configurable." -Save,Guardar -Settings,Configuración -"Show added configurable prices in label","Mostrar precios configurables añadidos en la etiqueta" -"Show out of stock configurations","Mostrar opciones fuera de existencia" -"Simple product images","Imágenes producto simple" -"Switch all media section","Cambiar toda la sección media" -"Switch main image","Cambiar imagen principal" -"Switch product images","Cambiar imágenes de producto" -"Template for media block. Leave empty to use default.","Plantilla para el bloque de media. Dejar vacío para valor por defecto." -"There was a problem uploading images","Hubo un problema subiendo imágenes" -Transformation,Transformación -"Transformation settings","Configuración de las transformaciones" -"Use Configuration for default store view","Usar la configuración por defecto de la vista de tienda" -"Use configurable product image if the simple one does not have images","Usar la imagen del configurable si las vistas simples no tienen" -"Use this image attribute","Usar este atributo de imagen" -"Use values like 100x80 or simply 100. Leave empty for no resize","Usar valores como 100x80 o solo 100. Dejarlo vacío para no reescalar" -[none],[ninguno] +"Allow out of stock products to be selected","Permitir seleccionar productos sin existencias" +Attribute,Atributo +"Autoselect first option if none specified","Autoseleccionar primera opción si no hay ninguna seleccionada" +"Block type for media section. Leave empty to use default","Tipo bloque para la sección media. Dejar vacío para utilizar la opción por defecto" +Cancel,Cancelar +"Change images when these attributes are changed","Cambiar imagen cuando estos atributos cambien" +"Change media content when these attributes are changed","Cambiar contenido media cuando estos atributos cambien" +"Changing the configurable value of these attributes will trigger the main image to change, if available.","Cambiando el valor de los atributos hará que la imagen principal cambie, si está disponible." +"Changing the configurable value of these attributes will trigger the media block to change.","Cambiando el valor de los atributos hará que el bloque media cambie." +Colors,Colores +"Configurable attributes transforms","Transformaciones de los atributos configurables" +"Configure Colors","Configurar colores" +"Configure Images","Configurar imágenes" +"Custom images","Imágenes personalizadas" +Default,Por defecto +"Dom Media block selector","Selector DOM del bloque media" +"Dom selector for main image","Selector DOM para imagen principal" +"Easylife Switcher","Easylife Switcher" +Enabled,Habilitado +"Fill Options","Rellenar opciones" +Images,Imágenes +"JS callback to be executed after the main image is changed.","JS callback que se ejecutará al cambiar la imagen principal." +"JS callback to be executed after the media block is changed.","JS callback que se ejecutará al cambiar el bloque ." +"Keep previously selected values","Mantener valores seleccionados previamente" +"Label / Options image size","Etiqueta / Opciones tamaño de imagen" +Labels,Etiquetas +"Main image size","Tamaño imagen principal" +"No image switch","Sin cambio de imagen" +"No transformation","Sin transformación" +"Prototype expression that selects the main image element","Expresión Prototype que selecciona el elemento de la imagen principal" +"Prototype expression that selects the media block container","Expresión Prototype que selecciona el contenedor del bloque media" +"Recommended if you have 2 or more configurable attributes.","Recomendado si tiene 2 o más atributos en el configurable." +Save,Guardar +Settings,Configuración +"Show added configurable prices in label","Mostrar precios configurables añadidos en la etiqueta" +"Show out of stock configurations","Mostrar opciones fuera de existencia" +"Simple product images","Imágenes producto simple" +"Switch all media section","Cambiar toda la sección media" +"Switch main image","Cambiar imagen principal" +"Switch product images","Cambiar imágenes de producto" +"Template for media block. Leave empty to use default.","Plantilla para el bloque de media. Dejar vacío para valor por defecto." +"There was a problem uploading images","Hubo un problema subiendo imágenes" +Transformation,Transformación +"Transformation settings","Configuración de las transformaciones" +"Use Configuration for default store view","Usar la configuración por defecto de la vista de tienda" +"Use configurable product image if the simple one does not have images","Usar la imagen del configurable si las vistas simples no tienen" +"Use this image attribute","Usar este atributo de imagen" +"Use values like 100x80 or simply 100. Leave empty for no resize","Usar valores como 100x80 o solo 100. Dejarlo vacío para no reescalar" +[none],[ninguno] diff --git a/js/easylife_switcher/product.js b/js/easylife_switcher/product.js index c7f3f6e..588b1fa 100644 --- a/js/easylife_switcher/product.js +++ b/js/easylife_switcher/product.js @@ -104,7 +104,7 @@ Easylife.Switcher = Class.create(Product.Config, { var inStock = that.isInStock(attributeId, optVal); var labelClass = that.getLabelClass(elem, attributeId, optVal, inStock); - $(newId).insert(''); + $(newId).insert(''); //change the select value on click that.bindClickEvent(selectid, optVal, inStock); @@ -116,6 +116,13 @@ Easylife.Switcher = Class.create(Product.Config, { } return transformed; }, + getImageSizeHTML: function() { + if (!this.config.image_size) { + return ''; + } + var sizes = this.config.image_size; + return ' style="width:' + sizes[0] + 'px;height:' + sizes[1] + 'px;line-height:' + sizes[1] + 'px"'; + }, /** * bind click event on labels */ @@ -311,7 +318,9 @@ Easylife.Switcher = Class.create(Product.Config, { var image = eval(this.getConfigValue(this.config, 'main_image_selector', false)); if (productImage && image) { //change the src - $(image).src = productImage; + $(image).src = productImage['src']; + $(image).alt = productImage['alt']; + $(image).title = productImage['alt']; //hack for default theme zoomer //don't call the callback on the first page load var callback = this.getConfigValue(this.config, 'switch_image_callback', false); diff --git a/skin/frontend/base/default/css/easylife_switcher/styles.css b/skin/frontend/base/default/css/easylife_switcher/styles.css index 1fe97d5..c412ba4 100644 --- a/skin/frontend/base/default/css/easylife_switcher/styles.css +++ b/skin/frontend/base/default/css/easylife_switcher/styles.css @@ -32,7 +32,6 @@ padding: 0; text-align: center; width: auto; - min-width: 40px; float:left; } .switcher-field label {