Tuesday, July 19

How to get Customer Group Id in Magento

Here is the script to get customer group id in Magento

<?php
$login = Mage::getSingleton( 'customer/session' )->isLoggedIn(); //Check if User is Logged In
if($login)
{
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); //Get Customers Group ID
if($groupId == 2) //My wholesale customer id was 2 So I checked for 2. You can check according to your requirement
{
echo 'You are a wholesale Customer';
}
}
?> 

Hope it helps .. Thanks...

Saturday, July 16

How to Add Customer Group field while Create Account in magento

Here is the step by step procedure to add customer group in account registration form


Step 1: go to app/code/core/Mage/customer/etc/config.xml and add the following code

<fieldsets><customer_account>
<group_id><create>1</create><update>1</update></group_id>
</customer_account></fieldsets>

Step : 2 Now go to register.phtml which resides app/design/frontend/your_interface/Your_theme/template/customer/form/Register.phtml and write the following code under the section where you wan't to put.

<li>
<label for="customer_groups" class="required"><em>*</em><?php echo $this->__('Customer Groups') ?></label>
<select name="customer_groups" id="customer_groups" title="<?php echo $this->__('Customer Groups') ?>" class="validate-group required-entry input-text">
<?php $cu_groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
<?php foreach($cu_groups as $cuGroups){ ?>
<option value="<?php echo $cuGroups['value'] ?>"><?php echo $cuGroups['label'] ?></option>
<?php } ?>
</select>
</li>

Step 3: open accountcontroller.php in app/code/core/mage/customer/controllers/accountcontroller.php and add the following code in the "initialize customer group id" part

<?php
$customer->setGroupId($this->getRequest()->getPost('customer_groups'));
?>

now you can get the customer group field while registering account.

Hope it Helps.. Thanks....

Tuesday, July 12

How to set Different Prices for each store in Magento

Follow these steps to change the price for product for each store in magento

Step 1.  In the Admin panel, goto System, Configuration, Catolog, then Price.

Step 2. Change Price from Global to Website.

Step 3. You should see “Website” on the price page for the product now, instead of “Global”.

Step 4. For each product you want to set different prices on – select the product, then in the upper left corner you will see the option to chose your store view.  Select the first store

Step 5. Set the price for the first store and click “Save and Continue Editing”

Step 6. Select the store view for your second store and set the price for that store

Step 7. Repeat step 6 until all of your store have the prices you want.

Hope it helps .. Thanks...

Wednesday, July 6

How to get All Store Details in Magento

Here is the script to get all store Ids and Name in Magento

<?php
$allStores = Mage::app()->getStores();
foreach ($allStores as $_eachStoreId => $val)
{
$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
$_storeName = Mage::app()->getStore($_eachStoreId)->getName();
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
echo $_storeId;
echo $_storeCode;
echo $_storeName;
}
?>

Hope it Helps.. Thanks...