Skip to content

Instantly share code, notes, and snippets.

@oreales
oreales / curl
Created April 21, 2015 11:21
test varnish local con curl
curl -I -H 'Host:my.site.com' http://localhost:6081/
@oreales
oreales / custom_layout_update.xml
Created April 12, 2015 17:07
magento Removing canonical and replacing it in custom_layout_update
<!-- con esto podemos usarlo en layout xml de CMS o categorías concretas para alterar comportamiento para esa pagina nada más -->
<reference name="head">
<action method="removeItem"><type>link_rel</type><href>http://loladerek.es/propuestas-lola-derek/cojines-de-moda</href></action>
<action method="removeItem"><type>link_rel</type><href>http://loladerek.es/propuestas-lola-derek/cojines-de-moda?___SID=U</href></action>
<action method="addLinkRel"><rel>canonical</rel><href>http://loladerek.es/decoracion/textil-hogar/cojines</href></action>
</reference>
@oreales
oreales / insertProductWeight.sql
Created March 19, 2015 13:34
Insert product weights for all products without weight in database (Magento)
#select to view all products without weight in database:
#TAKE CARE that weight attribute id is the right value
SELECT p.sku, w.value FROM catalog_product_entity as p
LEFT JOIN catalog_product_entity_decimal as w ON (p.entity_id = w.entity_id AND w.attribute_id = 101)
WHERE w.value IS NOT NULL;
#insert weight in catalog_product_entity_decimal for all products without value in that table:
#TAKE CARE to use the right entity_ids (depending on magento version)
@oreales
oreales / .htaccess
Created November 9, 2014 00:46
fuentes htaccess para cargar fuentes desde servidor balanceado
############################################
## para cargar fuentes desde origin externo
## o local cuando es balanceada la carga en magento
## para que se carguen las fuentes desde el subdominio
<FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
@oreales
oreales / layout.xml
Created September 24, 2014 11:52
NOINDEX / NOFOLLOW en magento usando layout
<!-- con esto podemos usarlo en layout xml de CMS o categorías concretas para alterar comportamiento para esa pagina nada más -->
<reference name="head">
<action method="setRobots"><value>NOINDEX,FOLLOW</value></action>
</reference>
@oreales
oreales / gmtoffset.php
Created July 28, 2014 16:07
Magent date with gmtoffset correcto
#Magento guarda la fecha y hora en que se produce un pedido (o cualquier cambio en otra entidad)
#en hora universal. Luego a la hora de mostrar la hora localmente, tenemos que asegurarnos que usamos esta llamada:
Mage::getSingleton('core/date')->date(null, $order->getCreatedAt());
@oreales
oreales / local.xml
Created July 23, 2014 12:08
Quitar filtro de categoria en Layered Navigation Magento
<!-- añadir esto al local.xml para quitar la categoría de los filtros de layered navigation -->
<catalog_category_layered>
<reference name="catalog.leftnav">
<action method="unsetChild"><child>category_filter</child></action>
</reference>
</catalog_category_layered>
@oreales
oreales / crontabs-by-user.sh
Created July 15, 2014 15:54
crontab de cada usuario en unix
for user in $(cut -f1 -d: /etc/passwd); do echo $user; sudo crontab -u $user -l; done
@oreales
oreales / largest-tables.sql
Created July 11, 2014 22:21
Largest MySQL tables in a database
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
@oreales
oreales / .htaccess
Last active August 29, 2015 14:01
.htaccess rewrite a www y https
############################################
## rewrites to https y www
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]