Get the current currency code and symbol in magento

Get the current currency code and symbol in magento

Get the current currency code and symbol in magento

I have tried many times but I didn’t got success . But today I got the solution to show the currency symbol of product price:
Currency Code :

<?php echo $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode(); ?>

Currency Symbol :

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>

Magento: Getting product type

I got product type following way in phtml file

$product=Mage::getModel('catalog/product')->load($product_id);
$productType=$product->getTypeID();
//Simple Product    
if($productType == 'simple')
{   
  echo "Simple Product";
}                           
//Configurable Product
if($productType == 'configurable')
{   
  echo "Configurable Product";
}

Source:
http://stackoverflow.com/a/12419301

Magento: How do I get attribute set name & id?

Whenever you have a product object, you can access its attribute set like this:

$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
$attributeSetModel->load($product->getAttributeSetId());
$attributeSetName  = $attributeSetModel->getAttributeSetName();
$attributeSetID  = $attributeSetModel->getAttributeSetID();

This will give you the name of the attribute set, which you can then compare using strcmp:

if(0 == strcmp($attributeSetName, 'My Attribute Set') {
    print $product->getAttributeText('attribute');
}

Hope that helps!
Source:
http://stackoverflow.com/a/2095238

jQuery: How to add ‘onchange’ attribute in a ‘select’ tag?

<select id="sel_id">
</select>

Works for me if I use the native setAttribute().

Also, remember that you need quotes around the selector.

$("#sel_id")[0].setAttribute("onchange", "foo()");

the final html will be

<select id="sel_id" onchange="foo();" >
</select>

Also remember to define foo in the global namespace, and not inside jQuery’s .ready() function.

Source:
http://stackoverflow.com/a/3638016

Magento Dataflow Export/Import form the command line

One issue with Magento is the overhead involved in importing/exporting data which can cause timeouts when run from the web. Here is a script which will run from the command line….

<?php
//THIS SCRIPT JUST INITIALS THE PROFILE TO BE RUN VIA MAGENTO ADMIN "RUN PROFILE IN POPUP". Its the same thing as click just via this file that you can run via cron
$profileId = 8; // SYSTEM - IMPORT/EXPORT - ADVANCED PROFILES <-- you need to go into your magento admin and grab the exact profile ID
 
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
 
$profile = Mage::getModel('dataflow/profile');
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);
Mage::getSingleton('admin/session')->setUser($userModel);
$profile->load($profileId);
if (!$profile->getId()) {
    Mage::getSingleton('adminhtml/session')->addError('ERROR: Incorrect profile id');
}
 
Mage::register('current_convert_profile', $profile);
$profile->run();
$recordCount = 0;
$batchModel = Mage::getSingleton('dataflow/batch');
echo "EXPORT COMPLETE. BATCHID: " . $batchModel->getId();
?>

Source:
http://www.premasolutions.com/content/magento-dataflow-exportimport-form-command-line

Un-Ban Yourself from WHMCS Administration

Here’s how to un-ban yourself:

  1. Log into your cPanel or website database administration panel
  2. Enter phpMyAdmin
  3. Look for a database ending in _whmcs
  4. Browse that database
  5. Browse the table named tblbannedips
  6. Refer to your WHMCS ban notification where it says your banned IP address (such as “Your IP 12.345.12.345″)
  7. Find the entry in the tblbannedips where the ip column matches your IP address
  8. Click the X in that row to delete the ban
  9. Re-access your WHMCS ban-free!

Source:
http://www.seodenver.com/whmcs-banned-ip-address/

Excel: Excel CEILING Function Tutorial

The CEILING function is used to round a number upwards to the nearest multiple of a specified value.

For example, the function can be used to round up the costs of items to the nearest dime ( $ 0.10 ) to avoid having to deal with smaller change such as pennies ($ 0.01 ) and nickels ($ 0.05 ).

The syntax for the CEILING function is:

= CEILING ( Number, Significance )

Number – the value to be rounded.

Significance – the function rounds the Number specified above up to the nearest multiple of this value.
Example: Using Excel’s CEILING Function

For help with this example, see the image above.

Enter the following data into cells D1 to D3: 34.57, 23.82, 31.16

Click on cell E1 in the spreadsheet – this is where the function will be located.

Click on the Formulas tab of the ribbon menu.

Choose Math & Trig from the ribbon to open the function drop down list.

Click on CEILING in the list to bring up the function’s dialog box.

In the dialog box, click on the Number line.

Click on cell D1 in the spreadsheet.

In the dialog box, click on the Significance line.

Type in 0.10 – the number in D1 will be rounded up to the nearest multiple of 0.10.

Click OK.

The answer 34.60 should appear in cell E1 since 34.60 is the nearest multiple of 0.10
( 0.10 * 6 ) higher than 34.57.

Drag the fill handle in the bottom right corner of cell E1 down to cells D2 and D3 to copy the function to those cells.

The cells D2 and D3 should have the answers 23.90 and 31.20 respectively.

When you click on cell E1 the complete function = CEILING ( D1 , 0.1 ) appears in the formula bar above the worksheet.

Source:
http://spreadsheets.about.com/od/excelfunctions/qt/90128_ceiling.htm

Excel: Multiply a range of numbers by a number

Important This procedure replaces the numbers in the range with the result of the multiplication.

In an empty cell, enter the number that you want to multiply by.
Select the cell, and on the Edit menu, click Copy.
Select the range of numbers that you want to multiply.
On the Edit menu, click Paste Special.
Under Operation, click Multiply.
Click OK.
Delete the content of the cell entered in the first step.

Source:
http://office.microsoft.com/en-us/excel-help/multiply-numbers-HP003056141.aspx#BMmultiply_a_range_of_numbers_by_a_numb

Javascript: Making the entire div clickable

We could make an entire div tag clickable by redirecting the click to a page and by changing the cursor sytle to a pointer. This is good if you want your logo or your banner to be clickable, specially if the logo is embedded together with the banner. Making the entire banner clickable would be very beneficial to your site.

<div onclick="location.href='http://www.tildemark.com/';" style="cursor: pointer;">
</div>

Source:
http://www.tildemark.com/making-the-entire-div-clickable/

Magento: Getting product attributes values and labels

I have found that it is very useful to be able to get attributes from the system and use them in places other than a products category page. I always forget the exact syntax to use so, this is going to be my unofficial cheat sheet.

This is how to get a drop down lists options. I don’t think it will work for a mulit-select attribute. I stick the value/label pairs into an array to use how I please.
(more…)

Page 5 of 24«2345678»

Pin It on Pinterest