Wednesday, August 14, 2013
PHP Extensions "0" must be loaded.
It appears that one of the configuration XML files, namely magento/app/code/core/Mage/Install/etc/config.xml isn't parsed correctly by PHP 5.4
To fix this error, open above file and replace
<extensions>
<pdo_mysql/>
</extensions>
with
<extensions>
<pdo_mysql>1</pdo_mysql>
</extensions>
Now, you will be able to proceed the installation.
To fix this error, open above file and replace
<extensions>
<pdo_mysql/>
</extensions>
with
<extensions>
<pdo_mysql>1</pdo_mysql>
</extensions>
Now, you will be able to proceed the installation.
Session management in Magento
To set the value of Magento session variable:
$theValue = 'Bhavana';
Mage::getSingleton('core/session')->setMySessionvariable($theValue);
You can retrieve the value of session variable as following:
Mage::getSingleton('core/session')->getMySessionvariable();
To unset the value of session variable:
Mage::getSingleton('core/session')->unsMySessionvariable();
$theValue = 'Bhavana';
Mage::getSingleton('core/session')->setMySessionvariable($theValue);
You can retrieve the value of session variable as following:
Mage::getSingleton('core/session')->getMySessionvariable();
To unset the value of session variable:
Mage::getSingleton('core/session')->unsMySessionvariable();
Tuesday, April 24, 2012
can not login into magento admin Panel
I have installed magento 1.6.2.After installing fresh magento,I could not login in to admin panel of magento.It is even not throwing any exception message.Although Password and username are correct,I am not able to login in magento admin panel.After providing correct username and password,it only generates a new URL ,something like:
http://localhost/magento/index.php/admin/index/index/key/f1585bj4de664ab83db50940e058a/
Solution:
\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
change line no 84 to 87
from:
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
to:
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
Reason:
Magento do not store cookies.We run it on localhost which is actually not a true real domain But to store cookies we generally need a domain.Becasue of that we can not login and even not getting any exception or error message.
http://localhost/magento/index.php/admin/index/index/key/f1585bj4de664ab83db50940e058a/
Solution:
\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
change line no 84 to 87
from:
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
to:
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
Reason:
Magento do not store cookies.We run it on localhost which is actually not a true real domain But to store cookies we generally need a domain.Becasue of that we can not login and even not getting any exception or error message.
Friday, April 20, 2012
Add Address fields in customer registration
To show all address fields in create account page for customer,you have to comment following lines in:
\magento\app\design\frontend\base\default\template\customer\form\register.phtml
replace line no:77
from:
<?php if($this->getShowAddressFields()): ?>
to
<?php / /if($this->getShowAddressFields()): ?>
replace line no:149
from:
<?php endif; ?>
to
<?php // endif; ?>
As well,to get the list of states,you need to comment same line in java script too.
\magento\app\design\frontend\base\default\template\customer\form\register.phtml
replace line no:178
from:
<?php if($this->getShowAddressFields()): ?>
to
<?php / /if($this->getShowAddressFields()): ?>
replace line no:180
from:
<?php endif; ?>
to
<?php // endif; ?>
Now,You can see address fields in,create account form.
If you are still not able to see the address fields in create account form,means you have activate persistent cart.In that case you need to comment the same lines in
\magento\app\design\frontend\base\default\template\persistent\customer\form\register.phtml
\magento\app\design\frontend\base\default\template\customer\form\register.phtml
replace line no:77
from:
<?php if($this->getShowAddressFields()): ?>
to
<?php / /if($this->getShowAddressFields()): ?>
replace line no:149
from:
<?php endif; ?>
to
<?php // endif; ?>
As well,to get the list of states,you need to comment same line in java script too.
\magento\app\design\frontend\base\default\template\customer\form\register.phtml
replace line no:178
from:
<?php if($this->getShowAddressFields()): ?>
to
<?php / /if($this->getShowAddressFields()): ?>
replace line no:180
from:
<?php endif; ?>
to
<?php // endif; ?>
Now,You can see address fields in,create account form.
If you are still not able to see the address fields in create account form,means you have activate persistent cart.In that case you need to comment the same lines in
\magento\app\design\frontend\base\default\template\persistent\customer\form\register.phtml
Template/Block Hints in Admin Panel
Magento’s admin panel uses the exact same design pattern as the front end ( blocks/layouts/templates).If you have done any modification at admin side and you need to turn on template/block hints for the admin panel,you need to do following steps as there is not built in support from magento.
step 1:
Go to Magento Database
step 2: Turn on
INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);
Now,you can check at admin panel for template/block hints.
step 3: Turn off
To turn off hints,delete above record from the table or if you are thinking to turn on it again then simply update its value field from 1 to 0.
Logic behind this is:
/app/code/core/Mage/Core/Block/Template.php
public function getShowTemplateHints()
{
if (is_null(self::$_showTemplateHints)) {
self::$_showTemplateHints = Mage::getStoreConfig('dev/debug/template_hints')
&& Mage::helper('core')->isDevAllowed();
self::$_showTemplateHintsBlocks = Mage::getStoreConfig('dev/debug/template_hints_blocks')
&& Mage::helper('core')->isDevAllowed();
}
return self::$_showTemplateHints;
}
The “Mage::getStoreConfig” method checks for config values that are set in the current scope (ie, default, website, store, store view). In the admin panel, only values set in the “Default Scope” are loaded.
Magento only allows you to turn on hints when you’re in the configuration scope of a Website or Store View. This means that when the code above tries to load the configuration, it returns “null” because that config value isn’t set in the “Default Config” scope. Running the MySQL query above adds the hint config values to the “Default Config” scope. Here is a screenshot showing the settings for turning on the hints – notice that the “Main Website” configuration scope is selected.
The “Mage::getStoreConfig” method checks for config values that are set in the current scope (ie, default, website, store, store view). In the admin panel, only values set in the “Default Scope” are loaded.
Magento only allows you to turn on hints when you’re in the configuration scope of a Website or Store View. This means that when the code above tries to load the configuration, it returns “null” because that config value isn’t set in the “Default Config” scope. Running the MySQL query above adds the hint config values to the “Default Config” scope. Here is a screenshot showing the settings for turning on the hints – notice that the “Main Website” configuration scope is selected.
Get child categories in Magento
to get all the child categories of the required category id
<?php
$category_model = Mage::getModel('catalog/category'); //get category model
$_category = $category_model->load($categoryid); //$categoryid for which the child categories to be found
$all_child_categories = $category_model->getResource()->getAllChildren($_category); //array consisting of all child categories id
?>
<?php
$category_model = Mage::getModel('catalog/category'); //get category model
$_category = $category_model->load($categoryid); //$categoryid for which the child categories to be found
$all_child_categories = $category_model->getResource()->getAllChildren($_category); //array consisting of all child categories id
?>
Call Custom Model method/function
For example,I have created a custom module UserProfile .
i.e
magento\app\code\local\CustomerProfile\Userprofile
and my model in Userprofile is
magento\app\code\local\CustomerProfile\Userprofile\Model\Customersettings.php
Customersettings.php is as following:
class CustomerProfile_Userprofile_Model_Customersettings extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init("userprofile/customersettings");
}
function getmessage()
{
echo "Hello From Custom model method:";
}
}
I can call the method of custom model anywhere as following:
Mage::getModel('modulename/modelname')->modelmethod();
i.e.
Mage::getModel('userprofile/customersettings')->getmessage();
i.e
magento\app\code\local\CustomerProfile\Userprofile
and my model in Userprofile is
magento\app\code\local\CustomerProfile\Userprofile\Model\Customersettings.php
Customersettings.php is as following:
class CustomerProfile_Userprofile_Model_Customersettings extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init("userprofile/customersettings");
}
function getmessage()
{
echo "Hello From Custom model method:";
}
}
I can call the method of custom model anywhere as following:
Mage::getModel('modulename/modelname')->modelmethod();
i.e.
Mage::getModel('userprofile/customersettings')->getmessage();
Thursday, April 19, 2012
Birth date issue while creating new customer account
when i try to create a new customer account and i enter birth date as 09/30/1987(mm/dd/yyyy) format.it shows me an error message as:"Please enter a valid full date".
To Resolve this error:
I changed line 437 in /js/varien/js.js
from:
var error = false, day = parseInt(this.day.value) || 0, month = parseInt(this.month.value) || 0, year = parseInt(this.year.value) || 0;
to:
var error = false, day = parseInt(this.day.value, 10) || 0, month = parseInt(this.month.value, 10) || 0, year = parseInt(this.year.value, 10) || 0;
Now,Customer account created successfully.
To Resolve this error:
I changed line 437 in /js/varien/js.js
from:
var error = false, day = parseInt(this.day.value) || 0, month = parseInt(this.month.value) || 0, year = parseInt(this.year.value) || 0;
to:
var error = false, day = parseInt(this.day.value, 10) || 0, month = parseInt(this.month.value, 10) || 0, year = parseInt(this.year.value, 10) || 0;
Now,Customer account created successfully.
Sunday, March 18, 2012
Add a new custom link to top header links
You can add a new link in header along with my account,my cart,login.To add a new custom link along with this you have to do as following:
Step 1:
Create CMS Page that you want to open from the header link.
For example,i want to open About us page,then go to Magento Admin.
Magento Admin>CMS >Pages>Add New Page>("Fill the info related to Page.i.e.about us")>Save Page.
Step 2:
Go to:
\app\design\frontend\base\default\layout\customer.xml
add a new default reference in <!-- Default layout, loads most of the pages --> section.
for example,i want to add a new page as about us
<default>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer">
<label>About us</label>
<url>about-us</url>
<title>About us</title>
<prepare>true</prepare>
<urlParams />
<position>10</position>
</action>
</reference>
</default>
Thus,you can add a custom link in top header links and open new custom page too.
Step 1:
Create CMS Page that you want to open from the header link.
For example,i want to open About us page,then go to Magento Admin.
Magento Admin>CMS >Pages>Add New Page>("Fill the info related to Page.i.e.about us")>Save Page.
Step 2:
Go to:
\app\design\frontend\base\default\layout\customer.xml
add a new default reference in <!-- Default layout, loads most of the pages --> section.
for example,i want to add a new page as about us
<default>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer">
<label>About us</label>
<url>about-us</url>
<title>About us</title>
<prepare>true</prepare>
<urlParams />
<position>10</position>
</action>
</reference>
</default>
Thus,you can add a custom link in top header links and open new custom page too.
Subscribe to:
Posts (Atom)
Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method... magento 2
Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining met...
-
Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining met...
-
<?php $pageid=1; echo Mage::helper('cms/page')->getPageUrl($pageid); ?> Or In controller or .phtml file: <?php ec...






