Web Interface Language Codes
hl=af Afrikaans
hl=ak Akan
hl=sq Albanian
hl=am Amharic
hl=ar Arabic
hl=hy Armenian
hl=az Azerbaijani
hl=eu Basque
hl=be Belarusian
hl=bem Bemba
hl=bn Bengali
hl=bh Bihari
hl=xx-bork Bork, bork, bork!
hl=bs Bosnian
hl=br Breton
hl=bg Bulgarian
hl=km Cambodian
hl=ca Catalan
hl=chr Cherokee
hl=ny Chichewa
hl=zh-CN Chinese (Simplified)
hl=zh-TW Chinese (Traditional)
hl=co Corsican
hl=hr Croatian
hl=cs Czech
hl=da Danish
hl=nl Dutch
hl=xx-elmer Elmer Fudd
hl=en English
hl=eo Esperanto
hl=et Estonian
hl=ee Ewe
hl=fo Faroese
hl=tl Filipino
hl=fi Finnish
hl=fr French
hl=fy Frisian
hl=gaa Ga
hl=gl Galician
hl=ka Georgian
hl=de German
hl=el Greek
hl=gn Guarani
hl=gu Gujarati
hl=xx-hacker Hacker
hl=ht Haitian Creole
hl=ha Hausa
hl=haw Hawaiian
hl=iw Hebrew
hl=hi Hindi
hl=hu Hungarian
hl=is Icelandic
hl=ig Igbo
hl=id Indonesian
hl=ia Interlingua
hl=ga Irish
hl=it Italian
hl=ja Japanese
hl=jw Javanese
hl=kn Kannada
hl=kk Kazakh
hl=rw Kinyarwanda
hl=rn Kirundi
hl=xx-klingon Klingon
hl=kg Kongo
hl=ko Korean
hl=kri Krio (Sierra Leone)
hl=ku Kurdish
hl=ckb Kurdish (SoranĂ®)
hl=ky Kyrgyz
hl=lo Laothian
hl=la Latin
hl=lv Latvian
hl=ln Lingala
hl=lt Lithuanian
hl=loz Lozi
hl=lg Luganda
hl=ach Luo
hl=mk Macedonian
hl=mg Malagasy
hl=ms Malay
hl=ml Malayalam
hl=mt Maltese
hl=mi Maori
hl=mr Marathi
hl=mfe Mauritian Creole
hl=mo Moldavian
hl=mn Mongolian
hl=sr-ME Montenegrin
hl=ne Nepali
hl=pcm Nigerian Pidgin
hl=nso Northern Sotho
hl=no Norwegian
hl=nn Norwegian (Nynorsk)
hl=oc Occitan
hl=or Oriya
hl=om Oromo
hl=ps Pashto
hl=fa Persian
hl=xx-pirate Pirate
hl=pl Polish
hl=pt-BR Portuguese (Brazil)
hl=pt-PT Portuguese (Portugal)
hl=pa Punjabi
hl=qu Quechua
hl=ro Romanian
hl=rm Romansh
hl=nyn Runyakitara
hl=ru Russian
hl=gd Scots Gaelic
hl=sr Serbian
hl=sh Serbo-Croatian
hl=st Sesotho
hl=tn Setswana
hl=crs Seychellois Creole
hl=sn Shona
hl=sd Sindhi
hl=si Sinhalese
hl=sk Slovak
hl=sl Slovenian
hl=so Somali
hl=es Spanish
hl=es-419 Spanish (Latin American)
hl=su Sundanese
hl=sw Swahili
hl=sv Swedish
hl=tg Tajik
hl=ta Tamil
hl=tt Tatar
hl=te Telugu
hl=th Thai
hl=ti Tigrinya
hl=to Tonga
hl=lua Tshiluba
hl=tum Tumbuka
hl=tr Turkish
hl=tk Turkmen
hl=tw Twi
hl=ug Uighur
hl=uk Ukrainian
hl=ur Urdu
hl=uz Uzbek
hl=vi Vietnamese
hl=cy Welsh
hl=wo Wolof
hl=xh Xhosa
hl=yi Yiddish
hl=yo Yoruba
hl=zu Zulu
Friday, 21 December 2012
Create custom pagination in magento
Hope you known about block, xml in Magento.
Here is an extracted code that would help you to create pagination with custom collection in magento.
>> First paste the following code in your block class (e.g. product.php)
<?php
class example extends parentclass
{
private $_itemPerPage = 2;
private $_pageFrame = 8;
private $_curPage = 1;
public function getCollection($collection = 'null')
{
if($collection != 'null'){
$page = $this->getRequest()->getParam('p');
if($page) $this->_curPage = $page;
$collection->setCurPage($this->_curPage);
$collection->setPageSize($this->_itemPerPage);
return $collection;
}
}
public function getPagerHtml($collection = 'null')
{
$html = false;
if($collection == 'null') return;
if($collection->count() > $this->_itemPerPage)
{
$curPage = $this->getRequest()->getParam('p');
$pager = (int)($collection->count() / $this->_itemPerPage);
$count = ($collection->count() % $this->_itemPerPage == 0) ? $pager : $pager + 1 ;
$url = $this->getPagerUrl();
$start = 1;
$end = $this->_pageFrame;
$html .= '<ol>';
if(isset($curPage) && $curPage != 1){
$start = $curPage - 1;
$end = $start + $this->_pageFrame;
}else{
$end = $start + $this->_pageFrame;
}
if($end > $count){
$start = $count - ($this->_pageFrame-1);
}else{
$count = $end-1;
}
for($i = $start; $i<=$count; $i++)
{
if($i >= 1){
if($curPage){
$html .= ($curPage == $i) ? '<li class="current">'. $i .'</li>' : '<li><a href="'.$url.'&p='.$i.'">'. $i .'</a></li>';
}else{
$html .= ($i == 1) ? '<li class="current">'. $i .'</li>' : '<li><a href="'.$url.'&p='.$i.'">'. $i .'</a></li>';
}
}
}
$html .= '</ol>';
}
return $html;
}
public function getPagerUrl() // You need to change this function as per your url.
{
$cur_url = mage::helper('core/url')->getCurrentUrl();
$new_url = preg_replace('/\&p=.*/', '', $cur_url);
return $new_url;
}
}
?>
>> Now you have to modify your frontend phtml page. (e.g. custom.phtml)
<?php
$_collections = $this->getProductCollection(); // Default Collection on which you'll implement pagination.
$_productCollection = $this->getCollection($_collections); // calling the function that have been created in block page.
foreach ($_productCollection as $_product):
------------------ Your code here ------------
endforeach;
?>
<?php if($this->getPagerHtml($this->getProductCollection())):?> // pass the default collection as parameter
<div class="pages">
<span><?php echo $this->__('Page : ');?></span>
<?php echo $this->getPagerHtml($this->getProductCollection());?>
</div>
<?php endif;?>
Here is an extracted code that would help you to create pagination with custom collection in magento.
>> First paste the following code in your block class (e.g. product.php)
<?php
class example extends parentclass
{
private $_itemPerPage = 2;
private $_pageFrame = 8;
private $_curPage = 1;
public function getCollection($collection = 'null')
{
if($collection != 'null'){
$page = $this->getRequest()->getParam('p');
if($page) $this->_curPage = $page;
$collection->setCurPage($this->_curPage);
$collection->setPageSize($this->_itemPerPage);
return $collection;
}
}
public function getPagerHtml($collection = 'null')
{
$html = false;
if($collection == 'null') return;
if($collection->count() > $this->_itemPerPage)
{
$curPage = $this->getRequest()->getParam('p');
$pager = (int)($collection->count() / $this->_itemPerPage);
$count = ($collection->count() % $this->_itemPerPage == 0) ? $pager : $pager + 1 ;
$url = $this->getPagerUrl();
$start = 1;
$end = $this->_pageFrame;
$html .= '<ol>';
if(isset($curPage) && $curPage != 1){
$start = $curPage - 1;
$end = $start + $this->_pageFrame;
}else{
$end = $start + $this->_pageFrame;
}
if($end > $count){
$start = $count - ($this->_pageFrame-1);
}else{
$count = $end-1;
}
for($i = $start; $i<=$count; $i++)
{
if($i >= 1){
if($curPage){
$html .= ($curPage == $i) ? '<li class="current">'. $i .'</li>' : '<li><a href="'.$url.'&p='.$i.'">'. $i .'</a></li>';
}else{
$html .= ($i == 1) ? '<li class="current">'. $i .'</li>' : '<li><a href="'.$url.'&p='.$i.'">'. $i .'</a></li>';
}
}
}
$html .= '</ol>';
}
return $html;
}
public function getPagerUrl() // You need to change this function as per your url.
{
$cur_url = mage::helper('core/url')->getCurrentUrl();
$new_url = preg_replace('/\&p=.*/', '', $cur_url);
return $new_url;
}
}
?>
>> Now you have to modify your frontend phtml page. (e.g. custom.phtml)
<?php
$_collections = $this->getProductCollection(); // Default Collection on which you'll implement pagination.
$_productCollection = $this->getCollection($_collections); // calling the function that have been created in block page.
foreach ($_productCollection as $_product):
------------------ Your code here ------------
endforeach;
?>
<?php if($this->getPagerHtml($this->getProductCollection())):?> // pass the default collection as parameter
<div class="pages">
<span><?php echo $this->__('Page : ');?></span>
<?php echo $this->getPagerHtml($this->getProductCollection());?>
</div>
<?php endif;?>
How to add a breadcrumb to any Magento page.
>> Here's a easy solution to add breadcrumb to any page. In core block page find _prepareLayout() method.
<?php
public function _prepareLayout()
{
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
$breadcrumbs->addCrumb('home', array('label'=>Mage::helper('vendor')->__('GEAR WAREHOUSE'),
'title'=>Mage::helper('vendor')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
$breadcrumbs->addCrumb('my_account', array('label'=>Mage::helper('vendor')->__('My Account'),
'title'=>Mage::helper('vendor')->__('My Account'), 'link'=>Mage::getBaseUrl().'customer/account'));
$breadcrumbs->addCrumb('my_classified', array('label'=>Mage::helper('vendor')->__('Classified'),
'title'=>Mage::helper('vendor')->__('My Classified'), 'link'=>Mage::getBaseUrl().'vendor'));
$breadcrumbs->addCrumb('an_alias', array('label'=>'Edit',
'title'=>'Edit Classified', 'link'=>''));
}
?>
By using addCrumb() method you can set your breadcrumb to any page. In your phtml page you've to write the following code :
<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>
By default this code is written in layout page. (e.g. 1column.phtml)
<?php
public function _prepareLayout()
{
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
$breadcrumbs->addCrumb('home', array('label'=>Mage::helper('vendor')->__('GEAR WAREHOUSE'),
'title'=>Mage::helper('vendor')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
$breadcrumbs->addCrumb('my_account', array('label'=>Mage::helper('vendor')->__('My Account'),
'title'=>Mage::helper('vendor')->__('My Account'), 'link'=>Mage::getBaseUrl().'customer/account'));
$breadcrumbs->addCrumb('my_classified', array('label'=>Mage::helper('vendor')->__('Classified'),
'title'=>Mage::helper('vendor')->__('My Classified'), 'link'=>Mage::getBaseUrl().'vendor'));
$breadcrumbs->addCrumb('an_alias', array('label'=>'Edit',
'title'=>'Edit Classified', 'link'=>''));
}
?>
By using addCrumb() method you can set your breadcrumb to any page. In your phtml page you've to write the following code :
<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>
By default this code is written in layout page. (e.g. 1column.phtml)
Magento current product Id
if(Mage::registry('current_product')) {
$current_product_id = Mage::registry('current_product')->getId();
echo $current_product_id;
}
Thursday, 20 December 2012
Magento all product collection
Product collection :-
<?php
$collectionproduct=Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach($collectionproduct as $_product){
echo $_product->getName();
}
?>
<?php
$collectionproduct=Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach($collectionproduct as $_product){
echo $_product->getName();
}
?>
Magento Multilanguage
Extension Link:-http://www.magentocommerce.com/magento-connect/googletranslate.html
Code :-
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?> </label>
<!-- Google Element Translator Styling-->
<style>
.goog-te-combo{width: px !important;}
.goog-te-balloon-frame{display: none !important;}
font{background: transparent !important;}
a font:hover{ color: !important;}
#google_translate_element{height: 26px !important;overflow: hidden !important;}
.goog-te-banner-frame{display: none !important;}
body{top: 0px !important;}
</style>
<!-- Google Element Translator -->
<div id="google_language_drop">
<div id="google_translate_element" class="-blank"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
includedLanguages:
'en,de,af,sq,ar,hy,az,eu,be,bg,ca,zh-CN,zh-TW,hr,cs,da,nl,et,tl,fi,fr,gl,ka,el,ht,iw,hi,hu,is,id,ga,it,ja,ko,la,lv,lt,mk,ms,mt,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sw,sv,th,tr,uk,ur,vi,cy,yi',
pageLanguage: '<?php echo $this->__('en') ?>',
gaTrack: true,
gaId: 'UA-12345678-1'
}, 'google_translate_element');
}
</script>
<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
</div>
Monday, 16 July 2012
product add wishlist
<?php $wishlist = Mage::getModel('wishlist/item')->load($_product->getId(),'product_id');
if($wishlist->getId())
//product is added
echo "Added! - Product is in the wishlist!";
else
//add product to wishlist
echo "<a href='".$this->helper('wishlist')->getAddUrl($_product) ."'>Add This?</a>";
;?>
link :- http://stackoverflow.com/questions/6740696/check-whether-a-product-is-in-the-wishlist-or-not
Magento product add programmatically
CID= Category ID
Name= Product name
sku = Product Sku
weight = Product Weight.
<?php
$data=array("weight"=>"10","sku"=>"sku20","name"=>"productnew","description"=>"description","sdesc"=>"sdesc","price"=>"103","cid"=>"4");
?>
<?php
$newproduct = new Mage_Catalog_Model_Product();
$newproduct->setTypeId('simple');
$newproduct->setWeight($data['weight']);
$newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
$newproduct->setStatus(1);
$newproduct->setSku($data['sku']);
$newproduct->setTaxClassId(0);
$newproduct->setCategoryIds($data['cid']);
$newproduct->setWebsiteIDs(array(1));
$newproduct->setStoreIDs(array(1));
$newproduct->setStockData(array(
'is_in_stock' => 1,
'qty' => 199,
'manage_stock' => 1
));
$newproduct->setAttributeSetId(4);
$newproduct->setName($data['name']);
//$newproduct->setCategoryIds(array(3));
// array of categories it will relate to
$newproduct->setDescription($data['description']);
$newproduct->setShortDescription($data['sdesc']);
$newproduct->setPrice($data['price']);
//$newproduct->save();
?>
<?php
$fullImagePath="/opt/lampp/htdocs/wishlists/skin/frontend/default/default/images/a3.jpg";
$newproduct->setMediaGallery
(array('images'=>array (), 'values'=>array ()));
$newproduct->addImageToMediaGallery
($fullImagePath, array ('image','small_image','thumbnail'), false,
false);
//$newproduct->addImageToMediaGallery
($fullImagePath, array ('small_image'), false, false);
//$newproduct->addImageToMediaGallery
($fullImagePath, array ('thumbnail'), false, false);
$newproduct->save();
?>
Cart item remove
<?php
Mage::getSingleton('checkout/session')->clear();
foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
Mage::getSingleton('checkout/cart')->removeItem( $item->getId() )->save();
}
?>
OR
<?php echo $this->getUrl('checkout/cart/delete', array('id' => 'item_id')); ?>
Mage::getSingleton('checkout/session')->clear();
foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
Mage::getSingleton('checkout/cart')->removeItem( $item->getId() )->save();
}
?>
OR
<?php echo $this->getUrl('checkout/cart/delete', array('id' => 'item_id')); ?>
Subscribe to:
Posts (Atom)