Skip to content

Instantly share code, notes, and snippets.

View St0iK's full-sized avatar
☘️
🇬🇷

Dimitris Stoikidis St0iK

☘️
🇬🇷
View GitHub Profile
@St0iK
St0iK / upgrade-1.0.0-1.0.1.php
Last active August 29, 2015 14:10
Creating Magento product attributes programatically
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute('catalog_product','brown_product_info',
array (
'group' => 'General',
'type' => 'text',
'visible_on_front' => true,
'label' => 'Brown Product Info',
SHOW TABLES like 'customer_%'; --> 16 tables
customer_address_entity
customer_address_entity_datetime
customer_address_entity_decimal
customer_address_entity_int
customer_address_entity_text
customer_address_entity_varchar
customer_eav_attribute
customer_eav_attribute_website
@St0iK
St0iK / magento-attributes-custom-options.md
Last active August 29, 2015 14:11
Magento Attributes & Custom Options

Magento Attribute:

An attribute in Magento is defined as any property of a Catalog Category (Entity Type ID - 3), Catalog Product (Entity Type ID - 4), Customer (Entity Type ID - 1), Customer Address (Entity Type ID - 2), Order (Entity Type ID - 5), and some more. These include Product ID, Product Title, SKU, Image, Description, Customer First Name, Customer Last Name, and so on.

All the attributes are stored in the Database Table "eav_attribute", and all these attributes depend upon their Entity Types, which are stored in the DB Table "eav_entity_type".

A store owner can add as many additional attributes as desired. These can be grouped into attribute sets, so similar products can be created with the same attributes. If you sell TVs, shoes, books, and power tools you could create four attribute sets - one specific to TVs, one for shoes, one for books, and one for power tools. When adding new power tool Products to your Catalog, you simply select the “power tool” attribute set, and the appropriate fie

@St0iK
St0iK / upgrade-0.0.1-0.0.2.php
Last active August 29, 2015 14:12
Magento update script & Updating attributes
<?php
$this->startSetup();
/** Update previous attributes
* S.O.S we need to use frontend_label instead of 'label'
* http://www.webguys.de/magento/eav-attribute-setup/
*
* Column full name instead of column alias on updateAttribute
*
**/
@St0iK
St0iK / express_checkout_fix.md
Last active August 29, 2015 14:13
Magento Paypal Express Checkout Fix

Multistore with different currencies. Express Checkout send the payment to paypal with the BaseCurrency Fix

Create a new file under

app/code/local/Mage/Paypal/Model/Express/Checkout.php

Replace

@St0iK
St0iK / Observer.php
Last active August 29, 2015 14:13
Magento Event Observer with Save before and Save
class YourNamespace_YourModule_Model_Observer
{
public function customer_address_save_before($observer)
{
$address = $observer->getCustomerAddress();
//echo "<pre>"; print_r($address->getData()); exit;
// do something here
}
public function customer_address_save_after($observer)
var App = {
myProperty : 'someValue',
jqueryVar1 : $('.someClass'),
jqueryVar2 : $('.someOtherClass'),
jqueryVar3 : $('#id'),
myConfig:{
useCaching:true,
language: 'en'
},
<?php
/**
* Implements hook_form_alter().
*
* Redirects user logins to the front page.
*/
function HOOK_form_user_login_alter(&$form, &$form_state) {
$form['#action'] = url('user', array('query' => array('destination' => '<front>')));
}
<?php
/**
* Implements hook_block_info().
*/
function creode_product_types_block_block_info()
{
$blocks = array();
$blocks['product_types_block'] = array(
'info' => t('Product types'),
@St0iK
St0iK / wow.php
Created July 29, 2015 00:37
wow..
<?php
/**
* Implements hook_form_alter().
*/
function vw_shipping_messages_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'commerce_checkout_pane_settings_form') {
//echo "called";
$shipping_messages = variable_get('shipping_messages');