Magento Admin Login Problem
comment few lines in following files to solve the admin login problem.
app\code\core\Mage\Core\Model\Session\Abstract\varien.php
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
then clear cache from var/cache folder
It will work ------------
Magento Home page Layout settings
Go to Admin Panel ->CMS->Pages
Here you can edit XML description .
Tutorial: Setup a new custom theme for your new Magento store
1.Upload these folders to your website:
/skin/frontend/default/NewTheme /app/design/frontend/default/NewTheme
Your folder will be called something other than gNewThemeh.
2.Login to the Admin
3.Navigate to System > Configuration > Design
4.Under the Themes section:
Type the name of your name theme in Templates, Skin and Layout. In this example the name of our theme would be NewTheme.
Type default in the Default textbox
Click Save Config at the top of the screen
Congratulations your new theme is now ready to go!
How to see block structure in front end
We can manage this from admin panel
select Main website view in Current Configuration Scope:
Under debus section select template path as yes.
it will show the folder structure in front end
Add Home Link with functional active state to Menu Bar (Alternative Method) |
- class="header-nav-container">
- class="header-nav">
class="no-display">
- class="home">"getUrl('')?>">
-
-
-
-
Add Category listing in left sidebar
CATEGORIES
Add Information Pages in left sidebar
getChildHtml() ?>
renderCategoriesMenuHtml(0,'level-top') ?>
getCollection(); ?>
INFORMATION
Add Manufacturer dropdown
/public_html/app/code/core/Mage/Catalog/Block/manufacturer.php
class Mage_Catalog_Block_Product_Manufacturer extends Mage_Core_Block_Template
{
public function getAllManu() {
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
return $manufacturers;
}
}
In left sidebar
getAllManu() as $manufacturer): ?>
OR
MANUFACTURERS
addFieldToFilter('attribute_code', array('eq'=>'manufacturer'))
->addStoreLabel(Mage::app()->getStore()->getId())
->load();
foreach($collection as $a){
$manufArray = $a->getSource()->getAllOptions(false);
foreach($a->getSource()->getAllOptions(false) as $option)
$manufArray[$option['value']] = $option['label'];
?>
Magento: Setup multiple currency shop
You can easily setup a multiple currency shop in Magento. By multiple currency shop, I mean giving the user to browse products in different currencies. Magento will provide a currency dropdown in category and product listing page. When you select your desired currency, the entire products price will be changed to your selected currency.
Here is a step-by-step procedure to setup multiple currency shop in Magento:-
- Go to System –> Configuration –> Currency Setup
- Under ‘Currency Options‘, select Allowed currencies.
The selected currencies will be displayed in currency dropdown in category and product listing page. Remember that your Base currency and Default display currency selection should also be selected in Allowed currencies.
- Click ‘Save Config‘ button.
- Go to System –> Manage Currency Rates
- Select Import Service. By default it is ‘Webservicex’.
- Click ‘Import‘ button. This will update the currency rates values.
- Click ‘Save Currency Rates‘ button.
- Go to category listing page. You will see currency selection dropdown list in left sidebar at top.
Now, user of your shop can browse product with price in their desired currency.
dditional Scenario:-
Suppose, you have two currencies (British pound and U.S. dollar) in your Magento shop. You also have two stores (Store A and Store B). You want to show British pound in Store A and U.S. dollar in Store B.
Here is the solution:-
- Follow the steps above to setup multiple currency Magento shop.
- You will have multiple currency shop.
- Follow these steps to show store specific currency:-
- Go to System -> Configuration -> GENERAL -> Currency Setup
- In left sidebar at top, you will see “Current Configuration Scope”
- Select your desired store from the selection list
- Now, under “Currency Options“, you will see “Default Display Currency”
- Select your desired currency from the selection list
You are done. In frontend, select the store for which you did the above changes. You will see the price in your desired currency.
Hope this helps. Thanks.
Currency drop down selector in header, Magento
Step 1: Create a new phtml file and directory
You will need to create a new directory, named “directory” and create a new file called “currency-top.phtml“:
/app/design/frontend/template/default/YOUR-TEMPLATE-NAME/template/directory/currency-top.phtml and write the following code in it :-
getCurrencyCount()>1): ?>
Step 2: Add curency code to directory.xml
Step 3: Add call to header file
getChildHtml('store_language') ?> //for showing language if you wish
getChildHtml('currency_top') ?>
Magento Framework Query
1.Where define database name,user name,and password of website
open magento folder
magento/app/etc/locale.xml
write in locale.xml
2)How to get the Current url path of any page in Magento
$currentUrl = $this->helper(‘core/url’)->getCurrentUrl();
3)How to get list of all categories in Magento
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*');
4)How to get name of all modules in present Magento Installation
$modules =Mage::getConfig()->getNode('modules')->children();
5)Problems in magento Installation
Most common problem during magento installation is timeout
problem which often occurs . A very simple solution to it is to open your php.ini and navigate to these lines
a)max_execution_time = 60
Change its value to 1800 and second line you will encounter is
max_input_time = 60
Change its value to 1800
Now reinstall magento and most probably time out problem will not trouble you
6)Adding javascript and css on pages ->The Magento way
$headBlock = $this->getLayout()->getBlock(‘head’);
$headBlock->addJs(‘anyfoldername/anyjavascriptname.js’);
7)removing javascript and css on pages ->The Magento way
$this->getLayout->getBlock(‘head’)->removeItem(‘js’, ‘calendar/calendar.js’);
8)Model query in magento or How to insert record in database in magento
class Sapera_Nag_Model_Nag extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init(‘nag/nag’);
}
public function nagmani()
{
$collection = Mage::getResourceModel(‘nag/nag_collection’);
$collection->getSelect()->where(‘status = ?’, 1)->order(‘title’);
return $collection;
}
public function nagVish($title,$nagin_title,$filename,$content,$status)
{
$write = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$write->query(“INSERT INTO nag(title,nagin_title,filename,content,status,created_time,update_time)VALUES (‘”.$title.”‘,’”.$nagin_title.”‘,’”.$filename.”‘,’”.$content.”‘,’”.$status.”‘, ’2010-11-03 17:08:29′, ’2010-11-04 17:08:32′)”);
return $write;
}
public function nagVish2($title,$nagin_title,$filename,$content,$status)
{
$getModel=Mage::getModel(‘nag/nag’);
$getModel->setNaginTitle($nagin_title);
$getModel->save();
return $getModel;
}
public function getSortColorCategories() {
$collection = Mage::getResourceModel(‘vmfabriccolorcat/vmfabriccolorcat_collection’);
$collection->getSelect()->where(‘status = ?’, 1)->order(‘sort_order’);
return $collection;
}
public function getFabricPartImage($fabricId, $designId, $partId) {
$collection = Mage::getResourceModel(‘vmsuitfabricdesignimage/vmsuitfabricdesignimage_collection’);
$collection->getSelect()->where(‘fabric_id = ?’, $fabricId)->where(‘design_id = ?’, $designId)->where(‘part_id = ?’, $partId);
$data = $collection->toArray();
$fabricImage = (isset($data['items'][0]['filename'])?$data['items'][0]['filename']:”);
return $fabricImage;
}
}
9)-view query in magento or coding of action script in magento
__(‘Module List’) ?>
/*
This shows how to load specific fields from a record in the database.
1) Note the load(15), this corresponds to saying “select * from table where table_id = 15″
2) You can then just use the get(fieldname) to pull specific data from the table.
3) If you have a field named news_id, then it becomes getNewsId, etc.
*/
/* fetch all ID Record*/
$raj = Mage::getModel(‘nag/nag’)->nagmani();
foreach($raj as $ne){
echo $ne['nag_id'].’—’;
echo $ne['content'].’—
’;
}
/* fetch single ID Record*/
/*
$news = Mage::getModel(‘nag/nag’)->load(2);
echo $news->getNewsId();
echo $news->getTitle();
echo $news->getContent();
echo $news->getStatus().’——–1
’;
/*
This shows an alternate way of loading datas from a record using the database the “Magento Way” (using blocks and controller).
Uncomment blocks in /app/code/local/Namespace/Module/controllers/IndexController.php if you want to use it.
*/
/* record show single record from controller*/
$object = $this->getNag();
echo ‘id: ‘.$object['nag_id'].’
’;
echo ‘title: ‘.$object['title'].’
’;
echo ‘nagin_title: ‘.$object['nagin_title'].’
’;
echo ‘content: ‘.$object['content'].’
’;
echo ‘status: ‘.$object['status'].’
’;
/*
This shows how to load multiple rows in a collection and save a change to them.
1) The setPageSize function will load only 5 records per page and you can set the current Page with the setCurPage function.
2) The $collection->walk(‘save’) allows you to save everything in the collection after all changes have been made.
*/
$i = 0;
$collection = Mage::getModel(‘nag/nag’)->getCollection();
$collection->setPageSize(5);
$collection->setCurPage(2);
$size = $collection->getSize();
$cnt = count($collection);
foreach ($collection as $item) {
$i = $i+1;
$item->setTitle($i);
echo $item->getTitle();
}
$collection->walk(‘save’);
/*
This shows how to load a single record and save a change.
1) Note the setTitle, this corresponds to the table field name, title, and then you pass it the text to change.
2) Call the save() function only on a single record.
*/
$object = Mage::getModel(‘nag/nag’)->load(1);
$object->setTitle(‘This is a changed title’);
$object->save();
?>
10:) block query in magento
class Sapera_Nag_Block_Nag extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getNag()
{
if (!$this->hasData(‘nag4′))
{
$this->setData(‘nag4′, Mage::registry(‘nag4′));
}
return $this->getData(‘nag4′);
}
}
11- controller coading in magento
class Sapera_Nag_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
/*
* Load an object by id
* Request looking like:
* http://site.com/nag?id=15
* or
* http://site.com/nag/id/15
*/
if(isset($_REQUEST['submit']))
{
echo $title=$_REQUEST['title'];
echo $nagin_title=$_REQUEST['nagin_title'];
echo $filename=’index.jpg’;
echo $content=$_REQUEST['content'];
echo $status=$_REQUEST['status'];
echo $submit=$_REQUEST['submit'];
$rajh = Mage::getModel(‘nag/nag’)->nagVish($title,$nagin_title,$filename,$content,$status);
}
$nag_id = $this->getRequest()->getParam(‘id’);
if($nag_id != null && $nag_id != ”) {
$nag = Mage::getModel(‘nag/nag’)->load($nag_id)->getData();
} else {
$nag = null;
}
/*
* If no param we load a the last created item
*/
if($nag == null) {
$resource = Mage::getSingleton(‘core/resource’);
$read= $resource->getConnection(‘core_read’);
$nagTable = $resource->getTableName(‘nag’);
$select = $read->select()
->from($nagTable,array(‘nag_id’,'title’,'nagin_title’,'content’,'status’))
->where(‘status = ?’,1)
->order(‘created_time DESC’) ;
$nag = $read->fetchRow($select);
}
Mage::register(‘nag4′, $nag);
$this->loadLayout();
$this->renderLayout();
}
}
11-Short path for site folder
1-media url= pup/media:-
img src=”{{media url=”buying.png”}} http://uni-50.com/pup/media/buying.png
————————
2-store url= pup/index.php/nag
http://uni-50.com/pup/index.php/nag
12:-How to know whether a customer is logged in or not
Answer) the code below will give a boolean value which will tell whether customer is logged in. The advantage of code is it can be used in all files of magento to get whwther a customer is logged in or not
Mage::getSingleton(‘customer/session’)->isLoggedIn();
13)Retrieve Customer’s name which is login
The query below will give you name of customer which is logged in.The advantage of code is it can be used in all files of magento to get whwther a customer is logged in or not
Mage::helper(‘customer’)-> getCustomerName();
14)How to know whether Paypal Module is Enabled or not
The below code tells whether paypal module is enabled or not
$modules =Mage::getConfig()->getNode(‘modules’)->();$modulesArray =(array)$modules;
if(isset($modulesArray['Mage_Paypal')){
echo "Paypal module exists.";}else{
echo"Paypal module doesn't exist.";
}
This code is to be placed inside a block tag in xml whereever appropriate
15)How to get current category object and current product object in magento coding
By below code we can get current category object and then we can get various parameters
Mage::registry('current_category');
By below code we can get current product object and then we can get various parameters
return Mage::registry('current_product')