Skip to content

Instantly share code, notes, and snippets.

View 0-Sony's full-sized avatar

Phuong LÊ 0-Sony

View GitHub Profile
@0-Sony
0-Sony / overrideMagentoController.xml
Last active July 5, 2018 09:24
Override Magento Controllers
<!-- file config.xml -->
<config>
<modules>
<Namespace_Module>
<version>0.1.0</version>
</Namespace_Module>
</modules>
<frontend>
<routers>
<tag> <!-- tag can be for example : catalog,checkout,etc -->
@0-Sony
0-Sony / customLayoutPage.xml
Last active August 12, 2016 13:11
Create a new custom Layout page Template which will be visible in back office for page cms
<!-- local/Namespace/Module/etc/config.xml -->
<config>
<global>
<page>
<layouts>
<template_name translate="label" module="Namespace_Module"><!-- Example template_name : homepage -->
<label>Template_Label</label><!-- Example : Homepage -->
<template>path/template.phtml</template>
<layout_handle>handle_name</layout_handle> <!-- Example : namespace_homepage -->
</template_name>
@0-Sony
0-Sony / config.xml
Last active December 22, 2015 11:18
Declare all Blocks, Models, Helpers, layout and observers for a module
<!-- local/Namespace/module/etc/config.xml -->
<?xml version="1.0" encoding="utf-8"?>
<config>
<global>
<blocks>
<namespace_module>
<class>Namespace_Module_Block</class>
</namespace_module>
</blocks>
<models>
@0-Sony
0-Sony / cmsBlockInstaller.php
Last active August 12, 2016 13:09
Cms Block Installer
<!-- local/Namespace/Module/data/namespace_module_setup/data-install.0.0.1.php -->
<?php
/**
* CMS Blocks Installer
*/
try {
$block1Content = <<<HTML
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
@0-Sony
0-Sony / addProductAttribute.php
Last active July 11, 2019 23:39
Add Custom Attribute for products in custom Attributes set
<!-- local/Namespace/Catalog/data/Namespace_catalog_setup/data-install-0.0.1.php -->
<?php
try {
/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
/**
* Custom attribute creation
@0-Sony
0-Sony / Data.php
Last active December 22, 2015 10:38
Adding manageable pictures in backoffice magento to push in any page.
<!-- local/Namespace/MyModule/Helper/Data.php -->
<?php
class Namespace_Module_Helper_Data extends Mage_core_Helper_Abstract {
public function isActivated
{
return Mage::getStoreConfig('namespace_module/active_picture');
}
@0-Sony
0-Sony / jsTranslate.js
Last active February 17, 2017 11:26
Js translate. An Example to translate js into js file.
/** Build your Js **/
alert(Translator.translate('My Text to translate'));
alert(Translator.translate('Another Text to translate'));
@0-Sony
0-Sony / getListItemHtml.php
Last active July 24, 2017 14:15
Use only one template to display product using a helper
<?php
class Namespace_Catalog_Helper_Data extends Mage_core_Helper_Abstract {
const BLOCK_TYPE = "namespace_catalog/product_list_item";
const TEMPLATE = "catalog/product/list/item.phtml";
/**
* Get product list item HTML
*
@0-Sony
0-Sony / Adminhtml_System_Config_Editor.php
Last active May 6, 2016 09:05
Add Wysiwyg To system config Magento
<?php
/** Create a block adminhtml **/
class Namespace_Module_Block_Adminhtml_System_Config_Editor extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
{
/**
* Allowed Wysiwyg
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
@0-Sony
0-Sony / changeCategoryName.php
Last active August 12, 2016 13:02
Change Name Category programmaticaly
<?php
/** Location : Namespace/module/data/namespace_module_setup/install-0.1.0.php
try {
$storeId = 4 // your target store;
/**
* Set the right Store
*/
Mage::app()->setCurrentStore($storeId);
$_helperCategory = Mage::helper('catalog/category');