Tuesday, February 28, 2012

Sencha touch nestedlist click event without switching card


listeners: {
itemtap: function(list, index, item, e) {
//is home menu
if (list == this.items.getAt(0)) {
switch(index) {
case 0: //first menu
                                        //things to do for this detected menu
                                        //get the tabpanel and switch the card of tabpanel
Ext.getCmp("divTabPanel").setActiveItem(1);
                                        //call nestedlist to go back...
this.onBackTap();
break;
}
}//if is home menu
},

//...
}

Monday, February 27, 2012

sencha touch nestedlist onclick


On click event for NestedList item is listerners: itemtap

Example:

var nestedList = new Ext.NestedList({
fullscreen: true,
title: 'Malpha Home',
displayField: 'text',
dock: 'top',
listeners: {
itemtap: function(list, index, element, record) {
                        //example of setting tabpanel active tab
Ext.getCmp("tabname").setActiveItem(1);
}
},
store: store
});


Sunday, February 26, 2012

magento shipping table rates import

Magento shipping method have to be set in 2 different environment.
One on config, and another on site.
To import or export the rates, you will need to select "site" / "Default sites" to have the options to import the rates.
Before setting up these rates, you will have to ensure that you have setup the regions / states on your targeted countries to market.
Its can be set manually in database table on table:
directory_country_region.
Once you have set it, you may run this script to insert the name to the translation table for region name:
directory_country_region_name
If you are lazy like me, i will just run this SQL script below to populate the name to the directory_country_region_name table:

INSERT INTO `directory_country_region_name` (`locale`, `region_id`, `name`) 
SELECT 'en_US', `region_id` , `default_name`
FROM `directory_country_region`
WHERE country_id='ID';

You will have to make sure that the directory_country_region.code field contain a unique code for your state / region. It's a norm to use countrycode-statename to ensure it is unique for every states you setup.
Example: ID-SUMUTR
which represent indonesia: sumatera utara.
In the import CSV, this will be the format of the csv (as of magento 1.6):
Country, Region/State, Zip/Postal Code, Order Subtotal (and above), Shipping Price
Notes:
Country should contain short 2 alphabet code of the country, such as ID = Indonesia
Region/state field will be the field to contain the region/state code.
Order subtotal is optional (0)
Zip / Postal code is optional (empty)
Shipping price will be the price in shop currency.





Thursday, February 23, 2012

external php calling login into magento

Magento contains its own call to session_start() when included into your php application.
To ensure that your session set is the same session as magento front end, you will need to include magento in this manner:


require_once("pathtomagento/includes/config.php");
require_once("pathtomagento/shop/app/Mage.php");


umask(0);
Mage::app();
//this is the magic call to ensure the session of front end tally with your php session

Mage::getSingleton('core/session', array('name'=>'frontend'));

To set someone as logged in:
$oCustomer = Mage::getSingleton('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->load(#id);


$oSession = Mage::getSingleton('customer/session');
$oSession->setCustomerAsLoggedIn($oCustomer);


Updated 2012 feb 25:
This method seems to lack of event triggering when customer is logged in.
When you login as a member A, view a product X. Then logout and view product X. Then login as member A again and view product X,
It will cause the product to be directed to an error 404.
This is due to an error in report log which caused a duplicate in table: report_viewed_product_index. Duplicate entry for UNQ_NEOSHOP_REPORT_VIEWED_PRODUCT_INDEX_CUSTOMER_ID_PRODUCT_ID (to be exact) Observer class triggered: app/code/core/Mage/Reports/Model/Event/Observer.php, method: catalogProductView

Suppose, when some logged in, it will trigger several core events, which related to "customer_login", but this does not seems to work when there is not front controller been dispatched.
One way to fix it is to run a action on the front controller and then continue with the code.
But problem is, the default module "" will trigger module cms which will display entire html of the magento cms front page.
To fix this, add your own custom controller, and a dummy action which does not echo anything.
And call magento to run this front controller by calling this way:

umask(0);
//this will enable sensitive error
//Mage::setIsDeveloperMode(true);
$oMageApp = Mage::app();
$oMageApp->getRequest()->setModuleName("yourmodulename");
$oMageApp->getRequest()->setActionName('yourmoduledummymethodname');
$oMageApp->getFrontController()->dispatch();

Sunday, February 19, 2012

magento Name gotcha

It seems that all module directory name must start with capital.
Example:
app/code/local/Mynamespace/MyModule

This will fail:
app/code/local/Mynamespace/myModule

Took me some time to figure this out... :(

Tuesday, February 14, 2012

magento available photo options

$this->helper('catalog/image')->init($_product, 'small_image')
$this->helper('catalog/image')->init($_product, 'image')
$this->helper('catalog/image')->init($_product, 'thumbnail')

Saturday, February 11, 2012

magento overide model customer resource customer

Took me ages to found the issue.
It turn out that if i overide xml pointing to the new class file is case sensitive and space sensitive.
This is how i've managed to override customer/model/resource/customer

 
  
   Namespace_MyModule_Model_Resource_Customer