Skip to content

Instantly share code, notes, and snippets.

@hyhoocchan
hyhoocchan / TriggerEvent.js
Created November 10, 2015 03:27
Trigger Event Prototype by jQuery
Element.prototype.triggerEvent = function(eventName)
{
if (document.createEvent)
{
var evt = document.createEvent('HTMLEvents');
evt.initEvent(eventName, true, true);
return this.dispatchEvent(evt);
}
if (this.fireEvent)
return this.fireEvent('on' + eventName);
@hyhoocchan
hyhoocchan / GetAttributeOptionIds.php
Last active October 12, 2015 04:54
Get All Attribute Option IDs
<?php
$attributeId = Mage::getModel('eav/entity_attribute')->getResource()->getIdByCode('catalog_product','attrinute_code');
$collection =Mage::getResourceModel('eav/entity_attribute_option_collection')
->setPositionOrder('asc')
->setAttributeFilter($attributeId)
->setStoreFilter(0)
->load();
$collection->getAllIds();
?>
@hyhoocchan
hyhoocchan / UpdateImages.php
Created October 7, 2015 02:56
Update Image Script
<?php
/**
* Created by Nick Howard, Magento Developer.
*/
class Mage_Catalog_Model_Convert_Adapter_Extend_UpdateImages extends Mage_Dataflow_Model_Convert_Adapter_Abstract
{
public function load()
{
// you have to create this method, enforced by Mage_Dataflow_Model_Convert_Adapter_Interface
;
if (typeof Forix == "undefined") {
var Forix = {};
}
Forix.FilterState = {
clearFiltersBtn: null,
clearAllBtn: null,
clearCancelBtn: null,
filterApplylBtn: null,
@hyhoocchan
hyhoocchan / IndexController.php
Last active September 28, 2015 03:46
Use more robot field on multi site magento
<?php
/**
* Created by PhpStorm.
* User: chan
* Date: 21/09/2015
* Time: 16:04
*/
require_once 'Mage/Cms/controllers/IndexController.php';
@hyhoocchan
hyhoocchan / Api.php
Last active October 2, 2015 06:14
Add more field in OrderList API
<?php
class Forix_ApiExt_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api {
/**
* Retrieve list of orders. Filtration could be applied
*
* @param null|object|array $filters
* @return array
*/
public function items($filters = null)
@hyhoocchan
hyhoocchan / adminxmlfile
Last active September 23, 2015 10:28
[Order] Add more field for order grid
// Admin layout XML file
<sales_order_grid_update_handle>
<reference name="sales_order.grid">
<action method="addColumnAfter">
<columnId>forix_order_type</columnId>
<arguments helper="salesext/admin_render/getOrderTypeOption"/>
<after>shipping_name</after>
</action>
</reference>
</sales_order_grid_update_handle>
@hyhoocchan
hyhoocchan / CreateProductAttribute.php
Last active September 23, 2015 07:54
[Catalog/Product] - Create product attribute - multiselect
<?php
// Used for multi select
$installer->addAttribute('catalog_product', "hair_style", array(
'group' => 'Your Group',
'type' => 'varchar',
'input' => 'multiselect',
'label' => 'Hair Style',
'visible' => 1,
'sort_order' => 20,
@hyhoocchan
hyhoocchan / ProductCollectionSample.php
Last active September 23, 2015 03:19
[Catalog] Product collection filter by multi category
<?php
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
//Remove filter default by root category by set flag
$collection->setFlag('disable_root_category_filter', true);
//Check visible
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);