Skip to content

Instantly share code, notes, and snippets.

View dinhkhanh's full-sized avatar

Trần Đình Khánh dinhkhanh

View GitHub Profile
@dinhkhanh
dinhkhanh / catalog.patch
Created June 18, 2014 14:11
Always include catalog in product url
Index: app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php
===================================================================
--- app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php (revision 2102)
+++ app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php (working copy)
@@ -553,7 +553,11 @@
->from($this->getTable('core/url_rewrite'), array('product_id', 'request_path'))
->where('store_id=?', Mage::app()->getStore()->getId())
->where('is_system=?', 1)
- ->where('category_id=? OR category_id is NULL', $this->_urlRewriteCategory)
+// excluding this clause to facilitate one URL per product, and one that includes the category
@dinhkhanh
dinhkhanh / mysql.sql
Created June 17, 2014 14:24
Add 'Newest' to product listing dropdown sorter
UPDATE `catalog_eav_attribute`
SET `used_for_sort_by` = 1
WHERE attribute_id = (
SELECT attribute_id FROM `eav_attribute` WHERE `entity_type_id` = (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_model` = "catalog/product") AND `attribute_code` = "created_at");
UPDATE `eav_attribute`
SET frontend_label = "Newest"
WHERE `entity_type_id` = (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_model` = "catalog/product") and `attribute_code` = "created_at";
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby