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:
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.
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:
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:
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... :(
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')
$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
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
Sunday, February 5, 2012
Magento inline popup for product
Took me several days and many hours of researching,
Finally, ive made it up to the stage where i can declare glory to my objective :)
Magento uses many combination of configuration to customize to your setting.
Okay, i needed to do a popup to view product without showing a full layout product viewing page.
I didn't wanted to alter the core functionality, as i wanted both:
It would be much easier if i could just override the magento product view template by just copying existing template file into my template directory, and modify it as i needed. But this will override the entire product page, so we will no longer have access to the original full layout page.
Just for your reference, here is how its done:
--------------------
copy from:
app/design/frontend/base/default/template/catalog/product/view.phtml
to:
app/design/frontend/default/default/template/catalog/product/view.phtml
other optional files which you may override, but will need to have respective directories name, similar to the base template location:
app/design/frontend/base/default/template/catalog/product/view/*
---------------------
Now, i need to customize the base layout file for all my pages, the product listing, and product viewing page.
I need both, the base layout file to use 1column.phtml, listing page to use only category.phtml layout. And the full view product page to use product.phtml layout.
---------------------
create a file:
app/design/frontend/default/default/layout/local.xml
The content of the file can be edited as show in photo below.
Please take note on the tags: catalog_category_default (listing), catalog_product_view (view), checkout_onepage_index (checkout), default (default / base layout file)
Then upload the respective files to:
app/design/frontend/default/default/layout/template/page/category.phtml
~/product.phtml
~/1column.phtml
You may copy the layout files from app/design/frontend/base/default/template/page/1column.phtml to start out with.
----------------------
Next, i wanted to remove some of the items which i dont use.
So, edit the file app/design/frontend/default/default/layout/local.xml
And add in remove tags under default tag:
---------------------------
And here comes the difficult part, the standalone popup product viewing page, which does not replace existing product viewing full layout.
To do this, we will need to write our own customized module.
You may refer here to learn from begining:
http://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/
Okay, how are we going to allow the user to choose our layout from the CMS module?
Do this, edit:
app/code/local/[namespace]/[module]/etc/config.xml
directly under config tag, add in these tree:
config > global > page > layouts > yourpagename
Make sure to add in all the layout that you wish to be available on the CMS module, such as category.phtml and product.phtml
Once you are familiar with how to write blocks, have it configured to be installed, and integrated with custom blocks, then we can begin writing a extended version of the Catalog/product/view functionality without full layout.
inside your module path:
app/code/local/[namespace]/[module]/etc/config.xml
Create these tags:
config > frontend > layout > updates > mylayout > file > mylayout.xml (content)
global > helpers > mymodule > class > namespace_mymodule_Helper (content)
global > blocks > mymodule > rewrite > myproductview > namespace_mymodule_block_product_view (content)
Notice that the class file is declared for our custom layout "myproductview" which will be seen declared on the next file (mylayouts.xml).
We shall need helper class declared, as default product controller of magento will need a helper class to render the page.
Next, the final layout file:
app/design/frontend/default/default/layout/mylayouts.xml
Create the nodes:
layout > mymodule_product_view (as shown on the photo below)
Then,
Take note that this will also need you to create the file:
app/design/frontend/default/default/template/page/inline.phtml
The file shall content a non html or body tags, to be displayed as popup using lightbox or colorbox.
Now, create the controller file to extend magento product controller:
app/code/local/Namespace/Mymodule/controllers/ProductController.php
Next, create the helper file to extend magento product helper:
app/code/local/Namespace/Mymodule/Helper/Product/View.php
And, create the Block handler file to handle block view for product
app/code/local/Namespace/Mymodule/Blocks/Product/View.php
And finally, duplicate the file
app/design/frontend/base/default/template/catalog/product/view.phtml
Finally, ive made it up to the stage where i can declare glory to my objective :)
Magento uses many combination of configuration to customize to your setting.
Okay, i needed to do a popup to view product without showing a full layout product viewing page.
I didn't wanted to alter the core functionality, as i wanted both:
- Exists magento product viewing page with full page layout
- A "quick view" button to show just the non-layout based popup
It would be much easier if i could just override the magento product view template by just copying existing template file into my template directory, and modify it as i needed. But this will override the entire product page, so we will no longer have access to the original full layout page.
Just for your reference, here is how its done:
--------------------
copy from:
app/design/frontend/base/default/template/catalog/product/view.phtml
to:
app/design/frontend/default/default/template/catalog/product/view.phtml
other optional files which you may override, but will need to have respective directories name, similar to the base template location:
app/design/frontend/base/default/template/catalog/product/view/*
---------------------
Now, i need to customize the base layout file for all my pages, the product listing, and product viewing page.
I need both, the base layout file to use 1column.phtml, listing page to use only category.phtml layout. And the full view product page to use product.phtml layout.
---------------------
create a file:
app/design/frontend/default/default/layout/local.xml
The content of the file can be edited as show in photo below.
Please take note on the tags: catalog_category_default (listing), catalog_product_view (view), checkout_onepage_index (checkout), default (default / base layout file)
Then upload the respective files to:
app/design/frontend/default/default/layout/template/page/category.phtml
~/product.phtml
~/1column.phtml
You may copy the layout files from app/design/frontend/base/default/template/page/1column.phtml to start out with.
----------------------
Next, i wanted to remove some of the items which i dont use.
So, edit the file app/design/frontend/default/default/layout/local.xml
And add in remove tags under default tag:
---------------------------
And here comes the difficult part, the standalone popup product viewing page, which does not replace existing product viewing full layout.
To do this, we will need to write our own customized module.
You may refer here to learn from begining:
http://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/
Okay, how are we going to allow the user to choose our layout from the CMS module?
Do this, edit:
app/code/local/[namespace]/[module]/etc/config.xml
directly under config tag, add in these tree:
config > global > page > layouts > yourpagename
Make sure to add in all the layout that you wish to be available on the CMS module, such as category.phtml and product.phtml
Once you are familiar with how to write blocks, have it configured to be installed, and integrated with custom blocks, then we can begin writing a extended version of the Catalog/product/view functionality without full layout.
inside your module path:
app/code/local/[namespace]/[module]/etc/config.xml
Create these tags:
config > frontend > layout > updates > mylayout > file > mylayout.xml (content)
global > helpers > mymodule > class > namespace_mymodule_Helper (content)
global > blocks > mymodule > rewrite > myproductview > namespace_mymodule_block_product_view (content)
Notice that the class file is declared for our custom layout "myproductview" which will be seen declared on the next file (mylayouts.xml).
We shall need helper class declared, as default product controller of magento will need a helper class to render the page.
Next, the final layout file:
app/design/frontend/default/default/layout/mylayouts.xml
Create the nodes:
layout > mymodule_product_view (as shown on the photo below)
Take note that this will also need you to create the file:
app/design/frontend/default/default/template/page/inline.phtml
The file shall content a non html or body tags, to be displayed as popup using lightbox or colorbox.
Now, create the controller file to extend magento product controller:
app/code/local/Namespace/Mymodule/controllers/ProductController.php
Next, create the helper file to extend magento product helper:
app/code/local/Namespace/Mymodule/Helper/Product/View.php
And, create the Block handler file to handle block view for product
app/code/local/Namespace/Mymodule/Blocks/Product/View.php
And finally, duplicate the file
app/design/frontend/base/default/template/catalog/product/view.phtml
to
app/design/frontend/default/default/template/mymodule/product/view.phtml
and modify this file according to your requirement :)
to access the original product page from browser:
http://pathtomagento/catalog/product/view?id=[productid]&category=[categoryid]
to access your customized popup page (standalone) from browser:
http://pathtomagento/mymodule/product/view?id=[productid]&category=[categoryid]
Subscribe to:
Posts (Atom)