Showing posts with label Opensource. Show all posts
Showing posts with label Opensource. Show all posts

Friday, September 14, 2012

Magento :How Activate Demo store notice via Magento Admin, Demo Store text enabled in Magento

In the opensource world, Magento is one of the top most wanted E-commerce solution. Here we explained about Demo store message in the magento. We displayed Demo store text in the top of the page when are in the development. 

Find the following step to enable demo store,

1) Go to Magento admin 

2) Then go to System  -> Configuration

2) In the left side of the configuration -> General -> Web

3) HTML Head -> Tab have the select options named as "Display Demo Store Notice", choose "Yes" to activate demo store.

By PHP with 1 comment

Sunday, August 5, 2012

PHP Tutorial Online, Beginners Tutor Online, PHP eBooks

Learn About PHP online Materials, Download PHP E books Online, Online PHP tutorials, PHP Materials online.



Soure From: http://www.slideshare.net/. We are not copyrighted for this materials. we are placed embedded code from slideshare website

By PHP with No comments

Saturday, August 4, 2012

eSELECTplus Moneris Payment Gateway Integration - osCommerce

It’s a canada based Payment gateway solution provider. Moneris payment gateway provide various kit based on the opensource languages. Here we provide integration steps for osCommerce opensource.

eSELECTplus Moneris Payment Gateway Integration Steps

1.     Download the osCommerce Payment kit from eSELECTplus Moneris website which is already registered.
2.     Extract payment folder.
3.     Now we open phpmyadmin database for our oscommerce via cPanel/any other access
4.     Downloaded folder have Moneris.sql file, run this into osCommerce database
5.     Rename the "module.payment.moneriscampg.php” into "moneriscampg.php" and move to the \catalog\includes\modules\payment" folder on your web server.
6.     Rename the "language.english.moneriscampg.php" file into "moneriscampg.php” and move to "\catalog\includes\languages\english\modules\payment" folder on your web server.
7.     from the downloaded folder have "CANmpgClassesOsc.php ",  “CANmpiClassesOsc.php” files. Copy and paste into "\catalog\includes\classes\" folder.
8.     Move the file “orders_addon_campg.php” into to “\catalog\admin\” and then insert bolded code in “\catalog\admin\orders.php” as displayed below. (Approximately at line 204):

<?php


if (tep_not_null($order->info['cc_type']) || tep_not_null($order->info['cc_owner']) ||


tep_not_null($order->info['cc_number'])) {


?>


<tr>


<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>


</tr>


<tr>


<td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td>


<td class="main"><?php echo $order->info['cc_type']; ?></td>


</tr>


<tr>


<td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td>


<td class="main"><?php echo $order->info['cc_owner']; ?></td>


</tr>


<tr>


<td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td>


<td class="main"><?php echo $order->info['cc_number']; ?></td>


</tr>


<tr>


<td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td>


<td class="main"><?php echo $order->info['cc_expires']; ?></td>


</tr>


<?php


}


?>


</table></td>


</tr>


<?php include ("orders_addon_campg.php"); ?>


<tr>


<td><?php echo tep_draw_separator(‘pixel_trans.gif’, ‘1’, ‘10’); ?></td>


</tr>


<tr>


<td><table border=”0” width=”100%” cellspacing=”0” cellpadding=”2”>


<tr class=”dataTableHeadingRow”>


<td class=”dataTableHeadingContent” colspan=”2”><?php echo TABLE_HEADING_PRODUCTS; ?></td>


<td class=”dataTableHeadingContent”><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>


<td class=”dataTableHeadingContent” align=”right”><?php echo TABLE_HEADING_TAX; ?></td>


<td class=”dataTableHeadingContent” align=”right”><?php echo


TABLE_HEADING_PRICE_EXCLUDING_TAX; ?></td>


<td class=”dataTableHeadingContent” align=”right”><?php echo


TABLE_HEADING_PRICE_INCLUDING_TAX; ?></td>


<td class=”dataTableHeadingContent” align=”right”><?php echo


TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>


eSELECTplus CAN - osCommerce Shopping Cart July 19, 2011


Page 6 of 17


<td class=”dataTableHeadingContent” align=”right”><?php echo


TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>


</tr>

9.     Modify the error message text content display in the shopping cart go to “\catalog\includes\languages\english\modules\payment\moneriseselectplus.php”.
10.  Now we logged into osCommerce Admin panel ->Modules ->Payments
11.  Payment has the payment gateway lists, Click on “Install” to enable the Moneris eSELECTplus payment module and press edit to configure the payment parameters.
12.  Once configure Now go to front end to test product purchase using eSelectplus.
13.  If we have any issues in the test order, we need to check  cURL info settings,
a.     cURL CA Root Certificate File:
b.    The default installation of PHP/cURL does not include the cURL CA root certificate file. In order for the eSelectPlus PHP API to connect to the eSelectPlus gateway during transaction processing, the ‘mpgclasses.php’ file that’s included with the PHP API package needs to be modified to include a path to the CA root certificate file. Follow the instructions below to set this up.
c.     If cURL was not installed separately from your PHP installation, libcurl is included in your PHP installation. You will need to download the ‘cacert.pem’ file from ‘http://curl.haxx.se/docs/caextract.html’ and save it to the necessary directory. Once downloaded, rename the file to ‘curl-ca-bundle.crt’ (e.g. 'C:\path\to\curl-ca-bundle.crt'). If cURL was installed separately from PHP, you may need to determine the path to the cURL CA root certificate bundle on your system (e.g. 'C:\path\to\curl-ca-bundle.crt').
d.    Insert the code below into the "CANmpgClassesOsc.php ",  “CANmpiClassesOsc.php” files as part of the cURL option setting, at approximately line 73 below the line ‘curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);‘
curl_setopt($ch, CURLOPT_CAINFO, getwed().'\curl-ca-bundle.crt');
getwed() – Is the function in the PHP, which is used to get the document root[absolute filepath]

Test Card For Moneris eSELECTplus Payment Gateway
MasterCard: 5454545454545454
Visa:  4242424242424242 or 4005554444444403
Amex:  373599005095005

Test IDs

store_id
api_token
Username
Password
store1
yesguy
DemoUser
password
store2
yesguy
DemoUser
password
store3
yesguy
DemoUser
password
store5*
yesguy
DemoUser
password

For more information please read the document which is included in the payment gateway kit.
Reference from eSelectPlus_OSCommerce_IG_CAN.pdf which is provided by eSelectPlus payment gateway. Please ready document which is provided by the payment gateway before going to proceed. We are not responsible for any issues.


By PHP with 1 comment

Thursday, July 26, 2012

Magento upgrade 1.5 to 1.7 and 1.6 to 1.7, Simplest way to upgrade 1.5 to latest Magento version

Magento version upgrade is not a simple method. Magento developers got an headache when they upgrade older version to latest version. Because, structure of the Magento versions different from one to another. So, it’s not just easy to upgrade Magento. Sometimes whole Magento store cause an error.

Finally I got solution to upgrade Magento store without using SSH access. In this method easily upgrade Magento store from 1.5 or 1.6 to latest version. Follow the below steps to upgrade Magento version easy way.

1. Before start upgradation process, need to download Magento latest version 1.7.X
 2.  Now you can export the current old version store database and import into phpmyadmin with any name you want to place.
 3. Create database connection in latest Magento 1.7.X store into current store database [1.5 version] and then run the frontend in the browser. Please wait until browser process complete.
 4. Now go to the database and find the table named as core_config_data.
 5. Change the base url as live website url. Now your upgraded Magento version is ready.
 6. For this time your upgraded version is ready without theme which you are used already. So, we need to move the theme folder to upgraded latest Magento version.
   Move the template theme as well as skin theme folder into new 1.7.X version
Template folder: app/design/frontend/default/THEMEFOLDER
Skin Folder: skin/frontend/default/THEME FOLDER
  7. Finally move the Extensions and custom modules from Magento old version to upgraded versions if you have installed. Check the modules app/code/local and app/code/community same place in the latest version.


Note: If any of the extensions / Custom module is not working, check with the supporting versions of the extensions. Tell your developer to upgrade the version.

Now we have successfully completed Magento upgradation from 1.5 to latest 1.7.X version. Hopefully this article useful for you. Please feel free to place your comments to help us to grow a level.

Share me, If you like

By PHP with 6 comments

Wednesday, July 25, 2012

Magento: Remove recently viewed lists in left side box, Hide Recently viewed box in left/Right Nav in Magento

In Magento, We researched over the admin panel to remove recently viewed items in left side box of my store. But I couldn't able to find the solutions in backend.

 Finally i got an idea to remove Magento recently viewed box via xml file manually. It’s easy method to remove box.

1. Go to the location: app/design/frontend/default/THEMEFOLDER/layout/
 Find the file names as "reports.xml"
If you can't found go to the base: app/design/frontend/default/base/layout/reports.xml
2. Find the below line in reports.xml file
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
3. Just remove or hide the above line.
4. Go to your store in the browser, refresh the page and you are done.


Hopefully, this article useful for you. Please comment if you find any other way to remove recently viewed products in our Magento store.

Please share me, if you like

By PHP with No comments

Monday, July 23, 2012

Export selected data's in the Magento Customer lists

 Magento easily Export Customer lists in the eCommerce store. Magento  also have the options to export selected data only in the customer profile.

 Magento customer profile have many data fields to store the customer  informations. We need to export particular data in our store profile. For ex. we need  to export only Firstname and Last name of the customer
profile.

Please follow the below steps to export,


  1.  Go to Admin -> System
  2.  Import / Export -> Dataflow profile


  In the data flow profile have the list of defaul export / Import  lists. We need to customize as per our requirment like to export Customer First name and Last name.

  Add new profile -> file the Profile form to update below way,

  - Name
- select customer
- select export
       - Export format xml or csv
- select only mapped data's
- Add Field Mapping
- Select First name
  - Select Last name

Now save profile

Now added new dataflow profile in our dataflow lists. Now click -> Run profile -> Run profile in popup

Now Go to download  all the exported data's stored in Var/Export Location.

Hopefully this article usefule for you. Please comment for your thoughts and be share this if its usefull.

By PHP with No comments

Magento Categorey lists display Order change, Sortby Magento Categories

How we can able to change category lists order in magento? Magento admin control panel having options to manually change the sort order in category lists.

 In Magento eCommerce store Category order changed in the following way,


  Need to logged in into Magento Admin Panel
  Then Go to Catalog on the top navigation
  catalog -> Manage Categories

See the categories,magento category lists on the left navigation.

 Click the category on the left, then drag to change order and drop.

Drag and drop method to sort category lists in magento.

By PHP with No comments

Magento Products Export via Admin control panel

Magento is most used eCommerce Opensource in PHPwe application development. Because its having many features related to eCommerce compare to any other.

  Magento have simple option to export products via admin panel. Magento export have 2 options to get the result which is XML format and CSV formats.

 In the following way to export products in our magento admin Store.

1. Goto Admin controll panel
2. System ->Export/Import 
3. Data Profile

 Default Data Profile have Products lists, customer Lists etc

 When we click into products lists, it will display options which we choose /Modify. Now click into Run profile in the left side tab

Click content area have the button called "Run profile popup"

The below screenshot shows products export completed successfully.


Now we can go to FTP ->Var ->Export then download exported magento product lists.









By PHP with No comments

Sunday, July 15, 2012

Magento: Show all the Products from specific category

Here we display all the products from specific category in Magento. Below code needs category ID and product collection Object needed.  Please use the below code to show all the products using category ID.

<?php
$category_id = 10; // if you know static category then enter number

    $catagory_model = Mage::getModel('catalog/category')->load($category_id); //where $category_id is the id of the category

    $collection = Mage::getResourceModel('catalog/product_collection');

    $collection->addCategoryFilter($catagory_model); //category filter

    $collection->addAttributeToFilter('status',1); //only enabled product

    $collection->addAttributeToSelect(array('name','url','small_image')); //add product attribute to be fetched

    //$collection->getSelect()->order('rand()'); //uncomment to get products in random order    

    $collection->addStoreFilter();          

    if(!empty($collection))

    {

            foreach ($collection as $_product):

            echo $_product->getName();   //get product name        

        endforeach;

    }else

        {

            echo 'No products exists';

    }              

?>


In the above code to display all the product names from specific category. If you want display all the product information, under the foreach loop need to use belo informations

// get Product's name
echo $_product->getName();
//get product's short description
echo $_product->getShortDescription();
//get Product's Long Description
echo $_product->getDescription();
//get Product's Regular Price
echo $_product->getPrice();
//get Product's Special price
echo $_product->getSpecialPrice();
//get Product's Url
echo $_product->getProductUrl();
//get Product's image Url
echo $_product->getImageUrl();


Hope Magento product lists code is useful for you. Kindly update your comments. Thanks for sharing this.

By PHP with 1 comment

Magento: List out the products from Category ID

Here we have to display all the products from single category using category ID. If we know category ID, We display all the product lists. Category ID is 6. We need to display all the products under 6th category, Use the following code to display all the products,

<?php
$catid = 6;
$category = new Mage_Catalog_Model_Category();
$category->load($catid); //My category id is 6
$prodCollection = $category->getProductCollection();
foreach ($prodCollection as $product) {
$prdIds[] = $product->getId(); //Array to store all the product ids
}
?>


In the above code to get all the products ID from category 6. Then we  need to Use following code to get Product information from the $prdIds[] Array.

<?php foreach($prdIds as $product_id); {
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id);
// get Product's name
echo $_product->getName();
//get product's short description
echo $_product->getShortDescription();
//get Product's Long Description
echo $_product->getDescription();
//get Product's Regular Price
echo $_product->getPrice();
//get Product's Special price
echo $_product->getSpecialPrice();
//get Product's Url
echo $_product->getProductUrl();
//get Product's image Url
echo $_product->getImageUrl();
}?>


Please update your comments to improve Next level in Magento Product Display. Thank you.

By PHP with 2 comments

Magento display all the categories in the left Navigation lists

In magento themes have the option to list out category list in the left navigation. But some of the themes are not available.

So, we need to create manually to list out the category lists in left nav bar.

1. We need to create left.phtml file in the following location

app\design\frontend\default\YOUR THEME\template\catalog\Navigation\

Then place the followiing code to list out the left navigation category lists like category and subcategory lists.

<div id="leftnav">
    <?php $helper = $this->helper('catalog/category') ?>
    <?php $categories = $this->getStoreCategories() ?>
    <?php if (count($categories) > 0): ?>
        <ul id="leftnav-tree" class="level0">
            <?php foreach($categories as $category): ?>
                <li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
                    <a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
                    <?php if ($this->isCategoryActive($category)): ?>
                        <?php $subcategories = $category->getChildren() ?>
                        <?php if (count($subcategories) > 0): ?>
                            <ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
                                <?php foreach($subcategories as $subcategory): ?>
                                    <li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
                                        <a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
                                    </li>
                                <?php endforeach; ?>
                            </ul>
                            <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
                        <?php endif; ?>
                    <?php endif; ?>
                </li>
            <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
    <?php endif; ?>
</div>

Please share this tips and also Don't forgot to enter your Ideas to go next level. Thanks for your support.

By PHP with 1 comment

Magento: Display Shopping cart on the header

In magento we have the option to display shopping cart in the header position.

Go to the app\design\frontend\default\YOUR THEME\template\page\html

In this html folder find the header.phtml file

If header.phtml is not available in your theme goto the base in the below url

app\design\frontend\base\default\template\page\html\header.phtml

to place the followinig code under "header-container" div, now we can able to view total number of  items and price in header.

<?php
  $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
  $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
  if($count==0)
  {
    echo $this->__('Items: %s',$count);
  }
  if($count==1)
  {
    echo $this->__(' Item: %s',$count);
  }
  if($count>1)
  {
    echo $this->__(' Items: %s',$count);
  }
  echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>

Please update your comments/feedback to improve in our magento knowledge.

By PHP with No comments

Magento Favicon update via admin control panel

Magento have the possibilities to upload favicon image via admin control panel. Favicon displayed top left browser window.

Login into Magento admin panel and follow the steps

1. Go to System in the Admin top navigation
2. Under the System select Configuration
3. Left General tab -> Design
4. Select HTML Head under the Design
5. Favicon Browse option to upload favicon

Alloweded favicon formats are ICO, PNG, GIF, JPG, JPEG, APNG, SVG. But not all the browsers supported. Better option to upload .ico format

Thankyou . KIndly update your feedback to go with better ideas and solutions.

By PHP with 1 comment

Magento set minimum Qty 1 in product detail page

In magento have the option to set minimum quantity near to the add to cart button in the front end. We Set the 1 as default qty input box via admin control panel.

1. Go to the Admin ->System ->Configuration
2. Select Inventory from Catalog section
3. Product Stock Option -> Minimum Qty Allowed in Shopping Cart
4. Then Add Minimum Qty ->Select All Groups and enter minimum qty as 1.

Magento also have the options to add minimum qty value based on the Customer groups


Thanks for keep reading our website. We are expecting better comments to update our magento knowledge.

By PHP with 1 comment

Tuesday, May 29, 2012

Magento: Display Product List on CMS Page


No matter how many Magento websites I build I never seem to be able to remember the following code snippet to add products onto the homepage or CMS page. I thought I would post, simply so I know where I can quickly find the information – I hope others find it useful as well.

The simplest way to do this is to add a widget to the cms page which allows you to specify a category if you need to as well as the template. Being able to change the template is really important as it allows you to create a new way of displaying your products, which you often need to do on the homepage.


// all products (it is still paginated)

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}



// products from one category (it is still paginated)

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}
If you need to customise the way these get displayed, either do this in your CSS, or change the template above and create your own phtml file. I usually copy the existing template and modify it to suit my needs since there are a lot of optional sections to do with pricing etc. that you don;t want to lose.

There are also some other options for displaying specific lists of products that are built-in to Magento, such as new and random products. Watch out for the random products though because the sorting options given to the user won’t work as expected on a random list. You would hope that Magento would keep the same list of products on the first page and sort them, but Magento actually sorts the whole catalogue. While this functionality is correct, it is hardly helpful to the user in most cases. Anyway, here is the code.


// new products (note this uses a different template, you can choose to use the normal list if you prefer)

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}



// random products

{{block type="catalog/product_list_random" name="product_random" template="catalog/product/list.phtml"}}

By PHP with 1 comment

Magento: Random Product Lists


There are two unused product list blocks in Magento which can be very useful if you push a few buttons, edit few layouts ..
1. Promotion
Block located in app\code\core\Mage\Catalog\Block\Product\List\Promotion.php
This is basically built in featured product functionality. It reacts to “promotion” attribute which needs to be created, so let’s click
Catalog->Attributes->Manage Attributes->Create New Attribute
Attribute Code: promotion
Scope: Global
Catalog Input Type for Store Owner: Yes/No
promotion-and-random-1
Label: Promotion (second tab)
Other params can be left alone, but it’s up to you of course. I also labeled it Promotion just for this article.
Now we need to add created attribute to attribute set, so navigate to
Catalog->Attributes->Manage Attribute Sets
select attribute set you’re using and drag promotion to General group for example.
promotion-and-random-2
Now when you’re editing your products, there is new “Promotion” option under General tab.
promotion-and-random-3
Products on which you select Yes will be shown on promotion block which can be displayed through layouts with
<block type="catalog/product_list_promotion" name="product_promotion" template="catalog/product/list.phtml"/>
or as cms content with
{{block type='catalog/product_list_promotion' template='catalog/product/list.phtml'}}
This attribute should really be included in default attribute set or in Magento sample data.
2. Random
Block located in app\code\core\Mage\Catalog\Block\Product\List\Random.php
This block loads random product collection from current store.
The fastest way to display it would also be something like
<block type="catalog/product_list_random" name="product_random" template="catalog/product/list.phtml"/>
since it also extends product_list block, however, since it is random product listing, that toolbar has no purpose here, so create phtml that will suit your shop needs, based on catalog/product/list.phtml. For example, i’m using similar Random block to display random products in sidebar.

Method 2

<?php

//below code to written in file which extends the product block
$collection = Mage::getResourceModel('catalog/product_collection');
        Mage::getModel('catalog/layer')->prepareProductCollection($collection);
        $collection->getSelect()->order('rand()');
        $collection->addStoreFilter();
        $this->setProductCollection($collection);
        return parent::_beforeToHtml();     

?>
  //below code to written in template file

        if (($_products = $this->getProductCollection())):
        echo $_product->getSku();
        endif;
You can extend the script further as per your requirement. This is a basic way of displaying random products in a page from the product catalog.

Method 3
Place the respective codes given below for displaying new/ most viewed/ random products list in Home page or any other CMS pages in Magento.
New Product
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml"}}
Most viewed product
{{block type="mostviewed/list" name="home.mostviewed.list" alias="product_homepage" template="catalog/product/list.phtml"}}
To display products from a particular category. Please replace <Category-ID> with the category id
{{block type="catalog/product_list" category_id="<Category-ID>" template="catalog/product/list.phtml"}}
To display random products
{{block type="catalog/product_list_random" template="catalog/product/list.phtml"}}




Method 4

Today i’ll show you How to create a Random Products in your Magento Home page.

Create the Home Products file

In my theme I created a copy of the list.phtml called home_list.phtml
/app/design/frontend/base/theme156/template/catalog/product

Show the file in the Home Page

Now we need to show our new file in the Home Page.
Go to your Admin panel -> CMS -> Pages
You should have a page called something like Home. Open it and paste the following code:
{{block type="catalog/product_list" category_id="36" template="catalog/product/home_list.phtml"}}
NOTE: please notice the category_id. It will force to show a certain category. In my case a special one called Home Products.

Shuffle it

The code is quite simple. We need to add the shuffle function after getting all the products.
Look for the getItems() function and past it below.
    <?php $_items = $_productCollection->getItems(); 
        shuffle($_items); ?>

Break on 3

I added a counter to break the foreach. Something like:
// Show 3 items
$max_items = 3;
$personal_count = 1;
And then at the end:
  if($personal_count == $max_items){break;}
  else{$personal_count++;}

Full Code

Here’s my full code of the home_list.phtml. It will depend on your theme but the suffle part should be the same.
<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

?>
<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */

?>
<?php $userIsloggedIn = Mage::getSingleton('customer/session')->isLoggedIn(); ?>
<?php $_productCollection=$this->getLoadedProductCollection() ?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div style="clear:both;">&nbsp;</div>
<div class="category-products" style="border:none !important;">
   
    <div class="page-indent">    
        <?php // List mode ?>
        <?php if($this->getMode()!='grid'): ?>
        <?php $_iterator = 0; ?>
        <ol class="products-list" id="products-list">
        <?php $list_item=1; foreach ($_productCollection as $_product): ?>
            <li class="item<?php if($list_item==1){echo ' first ';} ?><?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
                <?php // Product Image ?>
                <class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
                    <img src="<?php echo $this-/>helper('catalog/image')->init($_product, 'small_image')->resize(205, 181); ?>" width="205" height="181" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>
    
                <?php // Product description ?>
                <div class="product-shop">
                    <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h3>
                    <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product) ?>
                    <?php endif; ?>
                    <?php echo $this->getPriceHtml($_product, true) ?>
                    <?php if($_product->isSaleable()): ?>
                    <p><button class="button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button></p>
                    <?php else: ?>
                    <?php if ($userIsloggedIn) { ?>
                    <div class="out-of-stock"><?php echo $this->__('Availability: Out of stock.') ?></div>
                    <?php } else { ?>
                    <div class="out-of-stock"><a href="/customer/account/login/">Identificate para poder ver el precio</a></div>
                    <?php } ?>

                  <!--  <p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>-->
                    <?php endif; ?>
                    <div class="clear"></div>                    
                </div>
                <div class="clear"></div>
                <div class="desc std">
                    <?php echo nl2br($_product->getShortDescription()) ?>
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->__('Learn More') ?></a>
                </div>
                <ul class="add-to-links">
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                    <?php endif; ?>
                    <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                        <li class="last"><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
                    <?php endif; ?>
                </ul>
            </li>
        <?php $list_item++; endforeach; ?>
        </ol>
        <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
    
        <?php else: ?>
    
        <?php // Grid Mode ?>
    
        <?php $_collectionSize = $_productCollection->count() ?>
        <table class="products-grid" id="products-grid-table">
        <?php $_columnCount = 3/*$this->getColumnCount()*/; ?>
        
         <?php 
            $_items = $_productCollection->getItems(); 
            shuffle($_items); 
        ?>
        
        < ? 
            // Show 3 items
            $max_items = 3;
            $personal_count = 1;
        ?>
        <?php $i=0; foreach ($_items as $_product): ?>
        
            <?php if ($i++%$_columnCount==0): ?>
            <tr>
            <?php endif ?>
                <td>
                    <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
                    <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
                        <img src="<?php echo $this-/>helper('catalog/image')->init($_product, 'small_image')->resize(205, 181); ?>" width="205" height="181" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
                    </a>                    
                    <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                    <?php endif; ?>
                    <?php echo $this->getPriceHtml($_product, true) ?>
                    <?php if($_product->isSaleable()): ?>
                    <button type="button" class="button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
                    <?php else: ?>
                        
                    <?php if ($userIsloggedIn) { ?>
                    <div class="out-of-stock"><?php echo $this->__('Availability: Out of stock.') ?></div>
                    <?php } else { ?>
                    <div class="out-of-stock"><a href="/customer/account/login/">Identificate para poder ver el precio</a></div>
                    <?php } ?>
                  <!--  <p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>-->
                    <?php endif; ?>
                    <div class="clear"></div>
                  
                </td>
            <?php if ($i%$_columnCount==0 && $i!=$_collectionSize): ?>
            </tr>
            <?php endif ?>
            < ? 
               if($personal_count == $max_items){break;}
               else{$personal_count++;}
            ?>
            <?php endforeach ?>
            <?php for($i;$i%$_columnCount!=0;$i++): ?>
                  <td class="empty">&nbsp;</td>
            <?php endfor ?>
            <?php if ($i%$_columnCount==0): ?>
            
            <?php endif ?>
        </table>
        <script type="text/javascript">decorateTable('products-grid-table')</script>
        <?php endif; ?>        
    </div>
  
</div>
<?php endif; ?>


Method 5

To display random products on home page in Magento Theme you need to follow the below give steps:-
Step 1. Create a new file called random.phtml atapp/design/frontend/default/Your_Theme/template/catalog/random.phtml with the following given code:-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php 
$chosen_category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$_productCollection = $this->getLoadedProductCollection();
$number_of_products = $this->getNumProducts();
if (sizeof($_productCollection) < $number_of_products) {
 $number_of_products = sizeof($_productCollection);
}
$displayed_products = array();
foreach ($_productCollection as $_product) {
 $displayed_products[] = $_product;
}
$random_products = array();
if (sizeof($_productCollection) > 1) {
 $random_products = array_rand($displayed_products, $number_of_products);
} else {
 $random_products = array('0');
}
?>
<?php if(!$_productCollection->getSize()):?>
<div class="note-msg">
    <?=$this->__('There are no products matching the selection.')?>
</div>
<?php else:?>
 
<div class="main-binder">
  <div class="cms-box">
  <div class="category-title">
      <h2>Random Products</h2>
  </div> 
  <div class="category-products">
    <table id="products-grid-table" class="products-grid">
 <?php 
 $k=0;
 for ($i=0; $i < $number_of_products; $i++): ?>
 <?php if ($k == 0) { ?>
   <tr class="first odd">
  <?php } if($k==3) { $k=0;  ?> 
   </tr><tr class="first odd even">
  <?php } ?>
         <td id="td_<?php echo ($k+1); ?>" <?php if($k==3){ ?>class="last"<? } ?> >
  <div class="cms-box">
              <div id="cont_<?php echo ($k+1); ?>">
     <div class="product-name-block">                 
      <?php
      $pname=$this->htmlEscape($displayed_products[$random_products[$i]]->getName());
      ?>
      <h3 class="product-name">      
      <a href="<?php echo $displayed_products[$random_products[$i]]->getProductUrl()?>" title="<?php echo $pname; ?>">
                    <?php if(strlen($pname) > 28) {echo substr($pname,0,25)."...";}else {echo $pname;}?>
                    </a></h3>
                </div>
                <div class="image-box">     
    <a class="product-image" href="<?php echo $displayed_products[$random_products[$i]]->getProductUrl()?>"> <img src="<?php echo $this->helper('catalog/image')->init($displayed_products[$random_products[$i]], 'small_image')->resize(140);?>" alt="<?php echo $this->htmlEscape($displayed_products[$random_products[$i]]->getName())?>" title="<?php echo $this->htmlEscape($displayed_products[$random_products[$i]]->getName())?>"/> </a> 
    </div>
 
    <div class="cms-price-box" style=" text-align:center;">
     <span class="regular-price" id="product-price-37">      
      <span class="price" ><?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->
     getCurrentCurrencyCode())->getSymbol().$displayed_products[$random_products[$i]]->getPrice(); ?></span>
     </span>                      
    </div>
    <div class="button-row" style="text-align:center;">
       <button onclick="setLocation('<?php echo $displayed_products[$random_products[$i]]->getProductUrl();?>')" class="button" type="button"><span><span><span>Details</span></span></span></button>                               
     <button onclick="setLocation('<?php echo $this->getUrl('')."/checkout/cart/add?product=".$displayed_products[$random_products[$i]]->getId()."&qty=1"  ?>')" class="button"><span><?php echo $this->__('Add to Cart') ?></span></button>
    </div>
              </div>
        </div></td> 
 
<?php $k++; ?>
<?php endfor;?>
</tr>
      </table>     
    </div>
  </div>
</div>  
<?php endif;?>
Step 2. Now put this line where you want to show the best selling products.
1
2
3
<p>{{block type="catalog/product_list" category_id="3" num_products="8" template="catalog/random.phtml"}}</p>
 
 Note: Category Id will be specific to your Store.


By PHP with 1 comment

    • Popular
    • Categories
    • Archives