Friday 29 March 2013

Multi languages in magento via google translate | atomatic product name change in magento

Replace the file at app/design/frontend/base/template/page/switch/language.phtml

<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->__('af') ?>',
                        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>

Multi order via product attribute in list page in magento

you can add multiorder in list and view page via this code. In this you can add multiple the product attribute at a single time.

You can download the code by this link:

http://www.magentocommerce.com/boards/viewthread/298824/


ADD New admin user via database in magento

insert a row in the admin_user table and then run this query:-


INSERT into admin_role
SELECT
NULL role_id,
(SELECT role_id FROM admin_role WHERE role_name = 'Administrators') parent_id,
2 tree_level,
0 sort_order,
'U' role_type,
(SELECT user_id FROM admin_user WHERE username = 'username') user_id,
'username' role_name


Friday 8 March 2013

To Show Custom Option , configuration option , quantity in list page.

Put the code in place of where add to cart is now: 

 <?php echo $this->helper('checkout')->formatPrice($_product->getFinalPrice()) ?>
 <form action="<?php echo Mage::getBaseUrl(); ?>checkout/cart/add/" method="post" style="display:block; clear:both;">

<?php

$product = Mage::getModel('catalog/product');
$product->load($_product->getId());

//print_r($product);
//exit();

$xml = "";
$hasAtts = 0;

// configurable products
$productType = $product->getTypeId();

if($productType == "configurable") {

// configurable products
$attValConfig = $product->getTypeInstance()->getConfigurableAttributesAsArray();

if(sizeof($attValConfig)) {

$hasAtts++;

foreach($attValConfig as $attValConfigSingle) {

$xml .= "<div class='floatoption1'>".$attValConfigSingle['frontend_label'].": ";

$xml .= "<select style='display:block; clear:both; margin-bottom:10px;' name='super_attribute[".$attValConfigSingle['attribute_id']."]'><option selected='selected'>Choose an option</option>";

foreach($attValConfigSingle['values'] as $attValConfigSingleVal) {

$baseprice = $this->getPriceHtml($product, true);
$strippedprice = str_replace("£", "", $baseprice);
$numprice = strip_tags($strippedprice);
$numpricea = (float)$numprice;
$optionprice = $attValConfigSingleVal['pricing_value'];
$numpriceb = (float)$optionprice;
$catprice = $numpricea + $numpriceb;
$catpricea = number_format($catprice,2);

if (is_numeric($numpriceb)) {
$xml .= "<option value='".$attValConfigSingleVal['value_index']."'>".$attValConfigSingleVal['label']." £".$catpricea."</option>";
}   else { $xml .= "<option value='".$attValConfigSingleVal['value_index']."'>Not Mumeric</option>"; }
}
$xml .= "</select></div>";

}

}


}
// end configurable products

$attVal = $product->getOptions();

if(sizeof($attVal)) {

$hasAtts++;

foreach($attVal as $optionVal) {




$xml .= "<div class='floatoption1'>Size:<select style='display:block; clear:both; margin-bottom:10px;' name='options[".$optionVal->getId()."]'><option selected='selected'>Choose an option</option>";

foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
$xml .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()." +".Mage::helper('core')->currency($valuesVal->getPrice())."</option>";
}

$xml .= "</select></div>";

}

}

$xml .= "<div class='floatoption2'>Qty: <input style='display:block; clear:both; margin-bottom:20px;' id='qty' class='input-text qty' type='text' value='1' maxlength='12' name='qty'/></div>";

echo($xml);

?>

<input type="hidden" name="product" value="<?php echo($_product->getId()); ?>" />
<div class="catbutton">
<button class="button" class="button btn-cart" type="submit"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></div>



</form>
<script type="text/javascript">
var productAddToCartForm_<?php echo $_product->getId(); ?> = new VarienForm('product_addtocart_form_<?php echo $_product->getId(); ?>');
productAddToCartForm_<?php echo $_product->getId(); ?>.submit = function(){
if (this.validator.validate()) {
this.form.submit();
}
}.bind(productAddToCartForm_<?php echo $_product->getId(); ?>);
</script>