Skip to content

Instantly share code, notes, and snippets.

@herveguetin
herveguetin / Amasty_Shopby_Helper_Attributes.php
Last active Aug 29, 2015
Bugfix - Make sure to sort filter options by sort order set in Magento attribute option edit
View Amasty_Shopby_Helper_Attributes.php
<?php
/**
* @return array
*/
public function getAllFilterableOptionsAsHash()
{
if (is_null($this->_optionsHash)) {
$hash = array();
$attributes = $this->getFilterableAttributes();
@herveguetin
herveguetin / translation_var_order.csv
Created Apr 27, 2014
Manage different var positions in Magento translations
View translation_var_order.csv
%1$s %2$s private sales Ventes privées %2$s %1$s
@herveguetin
herveguetin / 001_customer_account_navigation_active_link.xml
Last active Mar 3, 2016
Add custom active links to customer account navigation in Magento
View 001_customer_account_navigation_active_link.xml
@herveguetin
herveguetin / product_entity_type_id.php
Created May 20, 2014
Retrieve product entity type ID in Magento
View product_entity_type_id.php
<?php
Mage::getModel('eav/entity_type')->loadByCode(Mage_Catalog_Model_Product::ENTITY)->getEntityTypeId();
@herveguetin
herveguetin / first_product_category.php
Created May 20, 2014
Retrieve first active category of product in Magento
View first_product_category.php
<?php
// $product must be an instance of Mage_Catalog_Model_Product
$productCategoryIds = $product->getCategoryIds();
$productCategory = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('is_active', true)
->addAttributeToFilter('entity_id', array('in' => $productCategoryIds))
->setPageSize(1)
->getFirstItem();
@herveguetin
herveguetin / kill_solr
Last active Nov 6, 2015
SolR basic snippets
View kill_solr
lsof -i :8983
# and kill returned pid
@herveguetin
herveguetin / catalog_category_attribute_price.php
Created May 26, 2014
Create a new price attribute for category in Magento
View catalog_category_attribute_price.php
<?php
$catalogInstaller = new Mage_Catalog_Model_Resource_Setup('core_setup');
$catalogInstaller->addAttribute('catalog_category', 'myattribute_code', array(
'type' => 'decimal',
'label' => Mage::helper('myHelper')->__('Price From'),
'input' => 'text',
'input_renderer' => 'adminhtml/catalog_product_helper_form_price',
'required' => false,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'sort_order' => 9999,
@herveguetin
herveguetin / store_date_interval.php
Created May 26, 2014
Check if current Magento store date is in given range
View store_date_interval.php
<?php
Mage::app()->getLocale()->isStoreDateInInterval(null, $myfromDate, $myToDate);
@herveguetin
herveguetin / test_order_success_page.md
Created May 26, 2014
Test Magento order success page
View test_order_success_page.md

In Mage_Checkout_OnepageController, temporarely comment out $session->clear();

@herveguetin
herveguetin / translate_specific_string_module.md
Created May 26, 2014
Translating strings from specific modules in Magento