Google+

Pages

Wednesday, May 30, 2012

Magento: Can not login to Magento Admin after installation

Are you not able to login to admin panel of newly installed magento, even there is no error message.

If the domain is not a true domain, then sometimes this problem occurs. Try this solution:

Go to: [Magento Root Folder]/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

and comment below lines-

'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()

and remember to remove comma(,) from the line above these three.

Cheers :)

Note: Remember that above file is in core Magento folder, so override it using your own package name.

Wednesday, May 23, 2012

Magento: 404 Error on Product Page


If your product pages are all going to 404 Not Found Page in Magento, then thats a headache for you.

But, don't worry, here is the fix :

Go to phpmyadmin and run this command:

-- Dumping data for table `report_event_types`

INSERT INTO `report_event_types` (`event_type_id`, `event_name`, `customer_login`) VALUES
(1, 'catalog_product_view', 1),
(2, 'sendfriend_product', 1),
(3, 'catalog_product_compare_add_product', 1),
(4, 'checkout_cart_add_product', 1),
(5, 'wishlist_add_product', 1),
(6, 'wishlist_share', 1);

Magento: Add to compare not working without login


If Add to Compare is not working in your store without log in, there can be some problem of log cleaning.

Try truncating below tables:

log_url_info
log_url
log_visitor
log_visitor_info


After that, check. In my case, it worked.

Tuesday, May 15, 2012

How to get current product id

Try below code to get currently loaded product id:

$product_id = $this->getProduct()->getId();

When you don’t have access to $this, you can use Magento registry:

$product_id = Mage::registry('current_product')->getId();

Enjoy.. :)

Saturday, May 5, 2012

Magento: Hide Tax from Grand Total in Customer Shopping Cart

If you want to hide tax from checkout/cart page, try the following:

Go to:

\app\design\frontend\[base]\[default]\template\checkout\cart\totals.phtml

Find the line (about 41):
<?php echo $this->renderTotals(); ?>
and replace with this:
<?php
      $rendertot = $this->renderTotals();
      $rendertot_tr = explode('</tr>', $rendertot);
          
      foreach($rendertot_tr as $trkey => $trval) {
         if( strpos($trval, __('Tax')) ) {
             unset($rendertot_tr[$trkey]);
         }
      }
      $rendertot_tr = implode('</tr>', $rendertot_tr);
      echo $rendertot_tr;
?>
It will remove tax row from cart page.
Note: Replace [base] with your current Package name and [default] with your theme name.

Wednesday, May 2, 2012

Magento: Sort products by Created At filter

Many times, we want to sort products by the newest first and the oldest last. But in magento, there are only three sorting filters by default, i.e. Name, Price and Best Value.

So, to make products list sorted by Newest first, we need to override some core code of magento.

To do this, go to:
                  app/code/core/Mage/Catalog/Block/Product
and copy List.php to [local] folder to override it.

Find the code of block:

$this->_productCollection = $layer->getProductCollection()

and replace it with:

$this->_productCollection = $layer->getProductCollection()->addAttributeToSort('created_at','DESC');

That's all.. Enjoy.. :)

Note: This method will work if you don't want to see dropdown of default sort filters, and just want to sort by newest products first.

If you also want to sort by default sort filters of Magento, i.e. Name, Price and Position, as well as add your custom filter to sort dropdown, then try with:


Tuesday, May 1, 2012

Magento Error: Unable to list current working directory.

Sometimes magento refuses to upload tablerates.csv file for shipping methods.


This problem can occur due to following reasons:
1.  Folder permissions to media and var folders. (Solution can be to assign 777 folder permissions to both of them).
2.  There is "no value" assigned for "upload_tmp_dir". (To check this, upload phpinfo.php file to your magento root folder and see it on browser by: [your website's url]/phpinfo.php)



Solution:
a.  Open php.ini file which is located on server's root folder.
b.  Add the following line of code to it:
     upload_tmp_dir = /home2/huntingf/public_html/magento/var/tmp


Note: Here "/home2/huntingf/public_html/magento/var/tmp" will be replaced by your server's folder path, where you want to upload files temporarily.