Top navigation as submenu in magento

If you would like to show your magento store categories like as in picture then you are on right place.
navigation_as_submenu

Replace this code in topmenu.phtml

<?php $_menu = $this->getHtml(‘level-top’) ?>
<?php if($_menu): ?>
<div class=”nav-container”>
<ul id=”nav”>
<?php echo $_menu ?>
</ul>
</div>
<?php endif; ?>

with below

<?php $_menu = $this->getHtml(0,’level-top’) ?>
<?php if($_menu): ?>
<div class=”nav-container”>
<ul id=”nav”>
<li class=”level0 nav-1 first level-top parent” id=”home”>
<a class=”level-top” href=”<?php echo Mage::getBaseUrl();?>”>
<span>Home</span></a>
</li>
<li class=”level0 nav-1 first last level-top parent” id=”products”>
<a class=”level-top”><span>Products</span></a>
<ul class=”level0″>
<?php echo $_menu ?>
</ul>
</li>
<li class=”level0 nav-1 last level-top parent” id=”contact_us”>
<a class=”level-top” href=”<?php echo Mage::getBaseUrl().’contacts’;?>”>
<span>Contact Us</span></a>
</li>
</ul>
<?php endif ?>

Exclude categories in magento top navigation

We can achive this using below code

<?php $cats = Mage::getModel(‘catalog/category’)->load(2)->getChildrenCategories();
?>
<ul>
<?php foreach($cats as $category): ?>
<?php if (!in_array($category->getId(), array(6,7,8,9))) : ?>
<li>
<a href=”getUrl() ?>”><span>getName() ?></span></a>
</li>
<?php endif; ?>
<?php endforeach; ?>

</ul>

Note : 6,7,8,9 are the categories which you want to execlude, you should replace with yours

Remove callouts (sidebar banners) in Magento

Left Callout banner (the dog)

Find in app/design/frontend/*/*/layout/catalog.xml

Right Callout banner (back to school)

Find in app/design/frontend/*/*/layout/catalog.xml

X-cart Database Backup/Restore HTTP 500 Error

If you are getting Database Backup/Restore HTTP 500 Error then check your error logs – /var/log

If you will see following entry
[06-Mar-2013 02:52:09 America/Denver] PHP Fatal error: Call to undefined function func_xpc_check_iframe_methods() in /var/www/vhosts/yoursitefoldername/httpdocs/modules/XPayments_Connector/config.php on line 57

then you can try to activate the x-payment module without configuring and see if all works. It is a bug though

Show more than 5 “New Products” to the home page in magento

We have two methods for doing this. The first one is below

Go to CMS –> Pages –> Home page in admin section and click Design section and then upadte Layout XML code with below

<block type=”catalog/product_new” name=”home.catalog.product.new” alias=”product_new” template=”catalog/product/new.phtml” after=”cms_page”>
<action method=”addPriceBlockType”>
<type>bundle</type>
<block>bundle/catalog_product_price</block>
<template>bundle/catalog/product/price.phtml</template>
</action>
<action method=”setProductsCount”><count>12</count></action>
</block>

This shows a maximum of 10 items.

The second one is change code in the magento files.

This example to show 10 items in 2 rows 5 products each.

You need to change the line in appcodecoreMageCatalogBlockProductNew.php
$products->setOrder(’news_from_date’)->setPageSize(5)->setCurPage(1);
change to
$products->setOrder(’news_from_date’)->setPageSize(10)->setCurPage(1);

And need to change new.phtml

<!–?php if ($i–>5): continue; endif; ?>
change to
<!–?php if ($i==5): echo “ “; endif; ?>
<!–?php if ($i–>9): continue; endif; ?>

How to increase or decrease the maximum execution time of a php script

By default PHP script execution time is set for 30 seconds at php.ini file. This is the time limit set for all the files to finish its execution. If the file takes more than this set time then the execution of the script will be stopped and error message will be displayed like this.

Fatal error: Maximum execution time of 30 seconds exceeded in F:php_filesttest.php on line 14

This maximum execution time limit is set inside the php.ini file like this.

max_execution_time = 30 ; Maximum execution time of each script, in seconds

This value can be increased or decreased as per our requirement at php.ini file but note that in a server environment where many sites are hosted, any change in php.ini will affect all the sites hosted by the server. So this change is not possible unless you own the server and you are the only user. In a shared hosting our host may not like to change any settings of php.ini for our requirement. So there is a option to set the file execution time for the particular file at the individual file end. This adjustment of time limit has no effect if php is running in safe mode. Let us try to learn how this works.

Setting page titles and meta tags in cakephp 2.0

Today I needed to have page titles and meta tags correctly setup for each page in a website i had often used methods like placing variables and setting them to the template in the app controller in a beforeFilter. Then if i needed a different meta tag on another page like contact for example i could go to the contact controller and and overwrite these variables. A great idea but didn’t work too well for the simple pages and the pages controller.

Here is Idea how you can add page titles and meta tags easy in your cake pages

1- First we need to set the page tile,place this code within your method on the controller :
$this->set(“title_for_layout”,”your page title goes here”);

2- Second add below code to your respective view page :

echo $this->Html->meta(‘keywords’, ‘your keywords goes here’, array(‘type’ => ‘keywords’, ‘inline’ => false));
echo $this->Html->meta(‘description’, ‘your description goes here’, array(‘type’ => ‘description’, ‘inline’ => false));

Hope this will help!!!!!!!!!!

Login issue with admin, user and unable to register in oscommerce

Recently we have an issue with oscommerce. We were developing an oscommerce site and everything was working fine in our test server. But when we moved to the production server provided by the client it stops working.

The issue was we couldn’t login as admin. Every time we logged in with correct parameters it was showing an error “Error: Invalid administrator login attempt.” We were searching for a solution in the google but nothing helped us. Later we found that we cannot even login as users and cannot register a new user also. So we have done some debugging and atlast what we got the solution.

The issue with the domain name and the one which we gave in the configure.php. The domain name always show with www. ie, when we type http://mysitename.com it will show as http://www.mysitename.com. What we gave in our configure.php file was http://mysitename.com. So issue with generating cookie and also POST information. When we changed the value of configure.php from http://mysitename.com to http://www.mysitename.com, it began to work. Hope it will be helpful for some others also.

How to Increase PHP’s File Upload Limit Using php.ini

The file upload size limit 2M(Approx) is set by shared hosting providers. They have set it low because it save bandwidth, keep the server moving quickly.
But customers really need a large upload limit? So we must increase the file upload size limit. We can do it by 4 way :

1- By adding below code on the page where you have upload function

ini_set(‘memory_limit’, ‘256M’); //needs to be in {x}M format
ini_set(‘upload_max_filesize’, ’50M’); //needs to be in {x}M format
ini_set(‘post_max_size’, ’50M’); //needs to be in {x}M format

2- Using below code in php.ini file

memory_limit = 256M
upload_max_filesize = 50M
post_max_size = 50M

Make php.ini file and upload it on the root folder

3- Using .htaccess file (Add below code in this file)

php_value memory_limit 256M
php_value upload_max_filesize 50M
php_value post_max_size 50M

4- Finally if above 3 tricks not work, then you need to contact to your hosting provider.

Quick Setup Guide To Run CakePHP 2.0 On Windows 7

In this tutorial, I will show you, how to set and run the CakePHP 2.0 framework on Windows 7. For those who have not heard of CakePHP before, it is an open source web application framework for producing web applications. It is written in PHP, modeled after the concepts of Ruby on Rails, and distributed under the MIT License. CakePHP is licensed under the MIT license which makes it perfect for use in commercial applications and comes with built-in tools for input validation, CSRF protection, Form tampering protection, SQL injection prevention, and XSS prevention, helping you keep your application safe & secure.

You can get more information on cakephp official site cakephp.org

Below proceeding you must know about cakephp system requirements:

HTTP Server. (Recommended Xampp Or Wamp)
For example: Apache. mod_rewrite is preferred, but by no means required.
PHP 5.2.8 or greater.
Technically a database engine isn’t required, but we imagine that most applications will utilize one. CakePHP supports a variety of database storage engines:

MySQL (4 or greater)
PostgreSQL
Microsoft SQL Server
SQLite

Downloading CakePHP

To download the latest major release of CakePHP. Visit the main website http://www.cakephp.org and follow the “Download Now” link.

All current releases of CakePHP are hosted on Github. Github houses both CakePHP itself as well as many other plugins for CakePHP. The CakePHP releases are available at Github downloads.

Now below are the steps you need to follow :

1-Once the download completed, extract the files and copy the files into the web server www root. You should place the folder as the same name. The folder’s name can be changed as you wished and doesn’t required to be named as cake in order to run it. Do not start the server yet , there are some configuration needed to be done on the Apache core files before running the CakePHP framework.

2- You must enable rewrite module on the apache. If it is already enabled then no need to take this step. Here is the steps how you can enable rewrite module :

Find the code below in the httpd.conf file and uncomment it. This is to enable the rewrite module on the apache. By default it is turned off in some web servers. If it is already uncommented you can continue to the next step.

Locate this code and remove the ‘#’ which is located in front of the line.
#LoadModule rewrite_module modules/mod_rewrite.so
The modified code should look like this. Save and close the file, upon completing the modification
LoadModule rewrite_module modules/mod_rewrite.so

3-Now, start your server and visit the location of the folder via your preferred Internet Browser. Eg. http://localhost/cake/.

That’s all!!