Skip to content

Instantly share code, notes, and snippets.

View cfaria's full-sized avatar
🍊
Citius, altius, fortius... Communiter

Carlos Faria cfaria

🍊
Citius, altius, fortius... Communiter
View GitHub Profile
<?php
require_once 'app/Mage.php';
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel('catalog/product')->getCollection();
//->addAttributeToFilter('entity_id', array('gt' => 14000));
$mediaApi = Mage::getModel("catalog/product_attribute_media_api");
@cfaria
cfaria / show_block.php
Created September 3, 2013 14:42
Show static block in template. Magento
<?php
//Check if block is active
$empty_category_block = Mage::getModel('cms/block')->load('block_id');
if($empty_category_block->getIsActive()) :
echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id'.$catid)->toHtml();
endif;
?>
<?php
//Show static block by widget filter
@cfaria
cfaria / main.sh
Created September 16, 2013 13:28
Extract tags content from XML
sed -n 's/.*<foo>\([^<]*\)<\/foo>.*/\1/p' filename.xml
@cfaria
cfaria / Breadcrumbs.php
Created October 1, 2013 11:58
Breadcrumbs in product always have category Magento app/code/core/Mage/Page/Block/Html/Breadcrumbs.php
protected function _toHtml() {
$cat_id = "";
if (Mage::registry('current_product')) {
$product_id = Mage::registry('current_product')->getId();
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
if ($product_id) {
@cfaria
cfaria / update_table.sql
Created April 25, 2014 09:45
Replace text in a table
UPDATE wp_posts SET post_content= REPLACE (post_content, '/temp/', '/blog/') WHERE post_content like '%/temp/%';
@cfaria
cfaria / labels-and-metas.sql
Created February 1, 2016 17:40 — forked from oreales/labels-and-metas.sql
magento-seo-sqls
#SQLs que dan una respuesta rápida a si un site esta utilizando algunas de las posibilidades SEO que da Magento o no:
#total de imagenes de producto en tu tienda
SELECT count(*) FROM catalog_product_entity_media_gallery_value;
#imagenes que NO tienen texto alternativo (y debieran)
SELECT count(*) FROM catalog_product_entity_media_gallery_value WHERE label IS NULL;
#imagenes que SI tienen texto alternativo (si son pocas...ese margen de mejora tienes)
SELECT count(*) FROM catalog_product_entity_media_gallery_value WHERE label IS NOT NULL;
@cfaria
cfaria / repeat-vs-firsttime.sql
Created February 1, 2016 17:40 — forked from Gabelbombe/repeat-vs-firsttime.sql
Magento: Customer Segmentation Reports (Repeat vs. First Time Buyers) in Donut Chart format (http://goo.gl/4MoAh0)
#################################################################
#################################################################
# ○ The number and percentage of customers who placed an order #
# ○ VS. number and percentage of repeat customer orders #
# #
# +------------------+-------+------------+ #
# | Type | Count | Percentage | #
# +------------------+-------+------------+ #
# | Total Customers | 35 | 100.0% | #
# | Single Customers | 1 | 2.9% | #
@cfaria
cfaria / ResetDefaultValues.php
Created September 22, 2016 16:00 — forked from kayintveen/ResetDefaultValues.php
Magento scripts that resets all products "use default values" setting of the admin store view. This script was created for a site that had thousands of products with deselected "Use Default Values" checkboxes in differente store-views
<?php
// Author: @kayintveen
// Credits: Microdesign B.V
// Created November 2015
//=====================================
// Enable Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
@cfaria
cfaria / gfonts.php
Created October 9, 2016 18:24 — forked from nikoskip/gfonts.php
Demo: http://nikoskip.me/gfonts.php | You only have to use the CSS import URL that Google gives you, for instance: http://fonts.googleapis.com/css?family=Cabin:500,700,500italic,700italic
<?php
$fontTypes = array('woff2', 'woff', 'ttf', 'svg', 'eot');
$gFontURL = 'http://fonts.googleapis.com/css?family=';
$uaFonts = array(
'woff2' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
'woff' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/4.0; GTB7.4; InfoPath.3; SV1; .NET CLR 3.1.76908; WOW64; en-US)',
'ttf' => 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-ca; LG-P505R Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
'svg' => 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10',

Configure

xdebug.ini

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1