Skip to content

Instantly share code, notes, and snippets.

@rodrigowebjump
rodrigowebjump / Magento Catalog List Block - limit products
Created October 23, 2014 21:23
Magento Catalog List Block - limit products
Module to allow limit products in catalog list block
{{block type="catalog/product_list" category_id="4" product_limit="5" template="catalog/product/list.phtml"}}
https://github.com/ProxiBlue/CatalogListFilters
Ref: http://magento.stackexchange.com/questions/10880/magento-limit-number-of-products-displayed-in-grid-on-homepage
@rodrigowebjump
rodrigowebjump / Magento system.xml field depends with multiple values
Created October 22, 2014 12:20
Magento system.xml field depends with multiple values Magento campo dependente com múltiplos valores
<depends>
<fruit separator=",">apples,bananas</fruit>
</depends>
mkdir demo
cd demo
wget http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.8.1.0.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc
@rodrigowebjump
rodrigowebjump / magento-format-number.php
Created September 16, 2014 13:39
Magento format number locale Magento formatar número respeitando a localização
<?php echo Zend_Locale_Format::toNumber($_interest, array('locale' => new Zend_Locale(Mage::app()->getLocale()->getLocale()))); ?>
@rodrigowebjump
rodrigowebjump / emulate-click-on-element.js
Created September 11, 2014 20:02
Javascript emulate click on element Simular click em elemento From http://jsfiddle.net/oscarj24/GR9jU/
$(document).ready(function() {
$('#click').click(function() {
open($('#ts'));
});
});
function open(elem) {
if (document.createEvent) {
// check to see if your store is in secure mode
$isSecure = Mage::app()->getStore()->isCurrentlySecure();
<?php
/**
* truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
*
* @param string $text String to truncate.
* @param integer $length Length of returned string, including ellipsis.
* @param string $ending Ending to be appended to the trimmed string.
* @param boolean $exact If false, $text will not be cut mid-word
* @param boolean $considerHtml If true, HTML tags would be handled correctly
*
@rodrigowebjump
rodrigowebjump / ignore untracked files
Created August 28, 2014 17:37
Git ignore untracked files temporarily without change .gitignore Git ignorar arquivos não versionados temporariamente sem alterar o .gitignore
git status -u no
Create an observer and add event listener to catalog_product_collection_load_before
/**
* Fires before a product collection is loaded
*
* @param Varien_Event_Observer $observer
*/
public function catalog_product_collection_load_before($observer)
{
$collection = $observer->getCollection();