Skip to content

Instantly share code, notes, and snippets.

Hervé Guétin herveguetin

Block or report user

Report or block herveguetin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@herveguetin
herveguetin / flat_source_table_select_varchar.php
Last active Aug 29, 2015
Save an attribute with a select input type with values that are not of "int" type and create correct column type in flat catalog tables (in Magento)
View flat_source_table_select_varchar.php
<?php
class Your_Module_Model_Catalog_Attribute_Source_Product_[Attribute] extends Mage_Eav_Model_Entity_Attribute_Source_Table
{
public function getAllOptions()
{
if (!$this->_options) {
$this->_options = array(
'option_1' => array('value' => 'value_1', 'label' => Mage::helper('adminhtml')->__('-- Not Selected --')),
'option_2' => array('value' => 'value_2', 'label' => 'Label 2'),
@herveguetin
herveguetin / clean_catalogsearch.sql
Last active Aug 29, 2015 — forked from leek/README.md
Clean Magento Database
View clean_catalogsearch.sql
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `catalogsearch_fulltext`;
TRUNCATE `catalogsearch_query`;
TRUNCATE `catalogsearch_result`;
--
-- Enterprise Edition
--
@herveguetin
herveguetin / checkout_total_discount_no_code.phtml
Last active Aug 29, 2015
Remove coupon code in parenthesis from discount total title in Magento
View checkout_total_discount_no_code.phtml
<?php
$title = ($this->getTotal()->getCode() == 'discount') ? preg_replace('@\(.*?\)@', '', $this->getTotal()->getTitle()) : $this->getTotal()->getTitle();
?>
@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 / 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 / canonical_url.php
Created May 26, 2014
Add canonical URL to Magento <head>
View canonical_url.php
<?php
$canonicalUrl = Mage::getBaseUrl(); // your logic...
$this->getLayout()
->getBlock('head')
->addLinkRel('canonical', $canonicalUrl);
@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
You can’t perform that action at this time.