Posts tagged Magento

Problemas exportando base de datos Magento desde phpmyadmin

0

Es muy habitual exportar la base de datos de Magento de phpMyAdmin para hacer una migración.

Para esto habrá que tener muy en cuenta el acordarse de marcar la opción “Deshabilitar la revisión de las claves foráneasDocumentación”.
Para esto tendremos que hacer la exportanción de tipo personalizada.

En el caso de tener ya un fichero SQL que nos da error al importar, por no tener las foreign keys desactivadas, no hay problema. Habrá que editar el fichero con un editor de texto y añadir al principio
SET FOREIGN_KEY_CHECKS = 0;
y al final
SET FOREIGN_KEY_CHECKS = 1;

Magento borra los videos de Youtube en CMS

0

Cuando se pega un iframe con un video de youtube el editor de las páginas CMS de magento borra estos videos.

Se se pega la forma antigua de embeber youtube esto no pasa, pero la mejor solución para que funcione con iframe es retocar el editor.

Para eso nos vamos a js/mage/adminhtml/wysiwyg/tiny_mce/setup.js y buscamos el bloque siguiente

var settings = {
        mode : (mode != undefined ? mode : 'none'),
        elements : this.id,
        theme : 'advanced',
        plugins : plugins,
        theme_advanced_buttons1 : magentoPlugins + 'magentowidget,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect',
        theme_advanced_buttons2 : 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor',
        theme_advanced_buttons3 : 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,ltr,rtl,|,fullscreen',
        theme_advanced_buttons4 : 'insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak',
        theme_advanced_toolbar_location : 'top',
        theme_advanced_toolbar_align : 'left',
        theme_advanced_statusbar_location : 'bottom',
        theme_advanced_resizing : true,

y le añadimos esto

extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder|allowTransparency],style,script',

Problema solucionado, con esto ya no se eliminarán lo videos

La busqueda de Magento no funciona.

3

Parece ser que desde la versión 1.3.2.4 a la 1.5.1.0 Magento viene con un pequeño bug por el cual la búsqueda no funciona y no devuelve resultados.

El primer paso es reindexar todo por si esto lo solucionara (casi nunca lo soluciona)

Si esto no funciona, desafortunadamented la solución pasa por modificar un fichero del core.

El fichero que hay que editar es app/code/core/Mage/CatalogSearch/Block/Result.php

Descomentar la linea 149 y 150

$this->getListBlock()
->setCollection($this->_getProductCollection());

Modificar la linea 172

$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();

por esta

$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();

Una vez está esto parcheado solo nos queda reindexar y la búsqueda debería volver a funcionar.

Como cambiar el conjunto de atributos de Magento

0

Por defecto en Magento no se puede cambiar el conjunto de atributos asignados a un producto, pero con muy poquito esfuerzo podemos conseguirlo.

Para esto tendremos que tocar el core de Magento por lo que siempre es recomendable hacer una copia en code/local para no tener problema con las actualizaciones.

En primer lugar tendremos que cambiar el fichero app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php y sobre la linea 253 añadir

 $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
    ->setEntityTypeFilter(Mage::getModel('catalog/product')
    ->getResource()->getTypeId())->load()->toOptionHash();

    array_unshift($statuses, array('label'=>'', 'value'=>''));
    $this->getMassactionBlock()->addItem('attribute_set', array(
    'label'=> Mage::helper('catalog')->__('Change attribute set'),
    'url' => $this->getUrl('*/*/massAttributeSet', array('_current'=>true)),
    'additional' => array(
    'visibility' => array(
    'name' => 'attribute_set',
    'type' => 'select',
    'class' => 'required-entry',
    'label' => Mage::helper('catalog')->__('Attribute Set'),
    'values' => $sets
    )
    )
    ));

Luego en app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php añadimos esta nueva función

  public function massAttributeSetAction(){
    
    	$productIds = $this->getRequest()->getParam('product');
    	$storeId = (int)$this->getRequest()->getParam(‘store’, 0);
    	if(!is_array($productIds)) {
    		$this->_getSession()->addError($this->__('Please select product(s)'));
    	} else {
    		try {
    			foreach ($productIds as $productId) {
    				$product = Mage::getSingleton('catalog/product')
    				->unsetData()
    				->setStoreId($storeId)
    				->load($productId)
    				->setAttributeSetId($this->getRequest()->getParam('attribute_set'))
    				->setIsMassupdate(true)
    				->save();
    			}
    			Mage::dispatchEvent('catalog_product_massupdate_after', array('products'=>$productIds));
    			$this->_getSession()->addSuccess(
    			$this->__('Total of %d record(s) were successfully updated', count($productIds)));
    		} catch (Exception $e) {
    			$this->_getSession()->addError($e->getMessage());
    		}
    	}
    
    	$this->_redirect('*/*/', array('store'=>(int)$this->getRequest()->getParam('store', 0)));
    }

Con esto ya podemos acceder a los productos y desde la rejilla principal podremos cambiar el conjunto de atributos.

[/sourcecode]

No se pueden previsualizar los correos electronicos transaccionable de Magento

0

Con la versión 1.6.1 se introdujo un bug nuevo en la previsualización de lo correos electrónicos transaccionables de Magento.
Si bien este error está reportado como bug en la versión 1.6.2 no está solucionado.

En el error se debe a la introducción de un htmlescape justo antes del renderizado.
Para solucionarlo no queda otra que modificar el core.

Nos vamos a app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php y comentamos la linea donde pone todo esto

$template->setTemplateText(
    $this->escapeHtml($template->getTemplateText())
);

Con el problema estará solucionado.
Esperemos que en próximas versiones lo dejen bien.

Eliminar pedidos de prueba y clientes de prueba de Magento

0

Con Magento es normal hacer pruebas en una tienda que luego se pasa a producción.
Al haber configurado multiples parametros (metodos de envio, metodos de pago….) es indispensable pasar la base de datos de test a producción pasando también todas las pruebas.

Magento no lleva de serie un sistema para borrar pedidos. Aun así la manera mas fácil sería borrarlos de golpe mediante SQL.

Aquí tenemos el script necesario para eliminar los pedidos de prueba de Magento. Para las ordenes elegiremos el que necesitemos según nuestra base de datos

/* reset orders 1 */
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE `sales_order_entity_varchar`;
TRUNCATE `sales_order_int`;
TRUNCATE `sales_order_text`;
TRUNCATE `sales_order_varchar`;
TRUNCATE `sales_quote`;
TRUNCATE `sales_quote_address`;
TRUNCATE `sales_quote_address_decimal`;
TRUNCATE `sales_quote_address_int`;
TRUNCATE `sales_quote_address_text`;
TRUNCATE `sales_quote_address_varchar`;
TRUNCATE `sales_quote_decimal`;
TRUNCATE `sales_quote_entity`;
TRUNCATE `sales_quote_entity_datetime`;
TRUNCATE `sales_quote_entity_decimal`;
TRUNCATE `sales_quote_entity_int`;
TRUNCATE `sales_quote_entity_text`;
TRUNCATE `sales_quote_entity_varchar`;
TRUNCATE `sales_quote_int`;
TRUNCATE `sales_quote_item`;
TRUNCATE `sales_quote_item_decimal`;
TRUNCATE `sales_quote_item_int`;
TRUNCATE `sales_quote_item_text`;
TRUNCATE `sales_quote_item_varchar`;
TRUNCATE `sales_quote_rule`;
TRUNCATE `sales_quote_text`;
TRUNCATE `sales_quote_varchar`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;

ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_address_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_address_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_address_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_address_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_item_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_item_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_item_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_item_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_rule` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_quote_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;

/* reset orders 2*/
SET FOREIGN_KEY_CHECKS=0;

TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;            # ??
TRUNCATE `sales_invoiced_aggregated_order`;        # ??
TRUNCATE `log_quote`;
 
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;

/* reset customers */
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;
TRUNCATE `log_customer`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;

ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;

-- Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;

Tienda multi idioma con Magento

6

Si una tienda quiere ser realmente competitiva en internet es recomendable que sea multi-idioma con, como minimo, el idioma nativo e inglés.

Magento trae de serí un fantastico sistema de traducción.
Lo primero es tener claro el concepto “Vista de una tienda”. Mediante las vistas de una tienda se puede controlar lo que se muestra según la vista, pudiendo por ejemplo mostrar unos productos u otros según la opción. De todos modos el potencial y su uso real suele ser para las traducciones.

Para generar una nueva vista los pasos son

  1. Ir al menú Sistema/Configuración de tiendas
  2. Pulsar sobre el botón “Crear una vista de tienda”

Al pulsar sobre esta opción seremos redirigidos a una nueva ventana donde se nos pedira:

  1. Tienda: Magento es también multi-tieda. Tendremos que seleccionar la tienda sobre la que queremos hacer la vista. Lo normal es tener solo una
  2. Nombre: Nombre de la vista. Es lo que se mostrará en el desplegable de idiomas. Para nuestro ejemplo pondremos English.
  3. Código: Codigo interno para saber en que vista estamos. Está bien seguir una nomenclatura tipo nombretienda_idioma (p.e. tienda_en)
  4. Estado: Indica si se activa o no esa vista en el frontend
  5. Ordenar: Es el orden el que se quiere mostrar en el combo de idiomas

 

Una vez completado guardamos los cambios.

Ya tenemos creada la vista pero ¡no le hemos dicho nada del idioma!,  ¿donde se especifica?

Para especificar el idioma de la vista hay que hacer lo siguiente:

  1. Ir al menú Sistema/Configuración
  2. En el combo “Alcance de la configuración actual” situado a la izquierda, seleccionar la vista que queremos
  3. En el menu de la izquierda “General/General” seleccionar la opción “Locale Options” y cambiar el idioma en la opción “Local”. Por defecto hereda la de la tienda. Habra que quitar el check “Use Website” y cambiar al deseado.

Este mismo paso lo podemos realizar para cualquier otra configuración, como por ejemplo para el pais por defecto.

Solo nos queda guardar los cambios y si todo está habilitado nos aparecerá el nuevo idioma en el frontend.

 

Comentar que para traducir tanto, productos, como categorias, como CMS todo se basa en la elección de la vista.

 

Recuperar administrador magento

1

Aunque nunca debería ocurrir puede que se olvide la contraseña de administrador y que el envio de contraseñas no funcione. ¿Qué hacemos en esos casos?
Si podemos entrar a la BD con algún administrado podemos sustituir la contraseña, que estará encriptada, por esta

04916760f92deb05d911581176305dd6:KC

Esta contraseña es 123456.
Solo tendremos que volver a entrar al admin con la contraseña 123456 y “voila”.

Solo nos queda cambiar la contraseña por una de nuestro agrado.

Usar servidor smtp externo con Magento

0

Aunque parezca increible Magento no tiene por defecto la opcion de usar otro servidor smtp que no sea localhost.

Para poder usar otros servidor hay dos opciones:

  1. Usar esta extensión de aschrode
  2. modificar el core del propio magento o usar esta extension.

Para modificar el core, aunque no es muy complicado si que puede producir dolores de cabeza si se actualiza, ya que eliminará nuestros cambios. Para esto recomendamos hacer una copia de los fichero que modificamos a la carpeta app/local

La información la he sacado de este hilo y funciona

http://www.magentocommerce.com/boards/viewthread/1073/P30/#t57392

Dejo aqui lo que hay que hacer.

1) Modify FILE: app/code/core/Zend/Mime.php

Change line 42:
const LINEEND = “”;
with
const LINEEND = “\n”;

IMPORTANT: leave double quotes FOR “\n”

2) ModifyFILE: app/code/core/Mage/Core/Model/Email/Template.php

2a) New getMail() function (added a block of code to specify smtp config):

public function getMail()
{
if (is_null($this->_mail)) {

/*Start of added code to specify config*/
$my_smtp_host = Mage::getStoreConfig(‘system/smtp/host’); // Take it from Magento backoffice or you can specify it here
$my_smtp_port = Mage::getStoreConfig(‘system/smtp/port’); // Take it from Magento backoffice or you can specify it here

$config = array(
‘ssl’ => ‘tls’, //optional
‘port’ => $my_smtp_port, //optional – default 25
‘auth’ => ‘login’,
‘username’ => ‘mailaccount@domain.com’,
‘password’ => ‘password’
);

$transport = new Zend_Mail_Transport_Smtp($my_smtp_host, $config);

Zend_Mail::setDefaultTransport($transport);
/*End of added code to specify config*/

$this->_mail = new Zend_Mail(‘utf-8′);
}
return $this->_mail;
}

2b) Comment those lines into send() function:

//ini_set(‘SMTP’, Mage::getStoreConfig(‘system/smtp/host’));
//ini_set(‘smtp_port’, Mage::getStoreConfig(‘system/smtp/port’));

El paso 2b no lo he hecho y funciona perfectamente.

Go to Top