Sanjoy Roy

[MCM, MCP, SCJP] – Senior Programmer, Sites n Stores Pty Ltd.

Magento – Display 3 records per row in advance search result page


File Path: /public_html/app/design/frontend/default/f001/template/catalog/product/list.phtml
Change:

$_columnCount = 3;//$this->getColumnCount();

Magento – Search Results Grid Different From Product Grid Listing


From what I can see, it doesn’t look like the Result.php block loads the short description in the _getProductCollection function. The getShortDescription will work, but you just need to tell the block to load that info so that you can call it. Open up app->core->Mage->CatalogSearch->Block->Result.php. You should see the following function:

protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $this->_productCollection = $this->_getQuery()->getResultCollection()
                ->addAttributeToSelect('url_key')
                ->addAttributeToSelect('name')
                ->addAttributeToSelect('price')
                ->addAttributeToSelect('special_price')
                ->addAttributeToSelect('special_from_date')
                ->addAttributeToSelect('special_to_date')
                ->addAttributeToSelect('description')
                ->addAttributeToSelect('image')
                ->addAttributeToSelect('small_image')
                ->addAttributeToSelect('tax_class_id');

            Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_productCollection);
            Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($this->_productCollection);
        }

        return $this->_productCollection;
    } 
    

As you can see, the short_description is not part of the select query. You can change ->addAttributeToSelect(’description’) to ->addAttributeToSelect(’short_description’), or you can add ->addAttributeTo Select(’short_description’) entirely. Of course, proper conventions would say that you should ammend the function via the local code pool as to preserve the integrity of your changes across future upgrades, but this’ll give you an idea as to how to get the short_description to show up.

Google Map – Add Markers using ExtJS API


Ext.onReady(function(){

    var mapwin;
    var button = Ext.get('show-btn');

    button.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!mapwin){

            mapwin = new Ext.Window({
                layout: 'fit',
                title: 'GMap Window',
                closeAction: 'hide',
				maximizable:true,
				minimizable:true,
                width:1024,
                height:786,
                x: 40,
                y: 60,
                items: {
                    xtype: 'gmappanel',
                    zoomLevel: 14,
                    gmapType: 'map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        geoCodeAddr: '252 Church St, Richmond, Victoria, 3121',
                        marker: {title: 'Sitesnstores Pty Ltd.'}
                    },
                    markers: [{
                        lat: -37.81748164010962,
                        lng: 144.99946296215057,
                        marker: {title: 'Richmond Police Station'},
                        listeners: {
                            click: function(e){
                                Ext.Msg.alert('Richmond', 'Richmond Police Station');
                            }
                        }
                    },{
                        lat: -37.82184477198719,
                        lng: 144.99804139137268,
                        marker: {title: 'Richmond Church'},
						 listeners: {
                            click: function(e){
                                Ext.Msg.alert('Richmond', 'Richmond Church');
                            }
                        }
                    }]
                }
            });
            
        }
        
        mapwin.show();
        
    });
    
 });
 


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>GMap Window Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

<!– GC –>
<!– LIBS –>
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<!– ENDLIBS –>

<script type="text/javascript" src="../../ext-all.js"></script>

<!– GMaps API Key that works for www.extjs.com –>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA2CKu_qQN-JHtlfQ5L7BLlRRadLUjZPtnrRT4mXZqcP4UUH-2OxREmPm3GpN_NHsHuvuHd-QKI4YoRg" type="text/javascript"></script>
<!– GMaps API Key that works for localhost –>
<!–<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAA2CKu_qQN-JHtlfQ5L7BLlRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQl3I3p2yrGARYK4f4bkjp9NHpm5w" type="text/javascript"></script>–>

<script src="../ux/GMapPanel.js"></script>
<script src="gmap.js"></script>

<!– Common Styles for the examples –>
<link rel="stylesheet" type="text/css" href="../shared/examples.css" />

<style type="text/css">
.x-panel-body p {
margin:10px;
font-size:12px;
}
</style>
</head>
<body>
<script type="text/javascript" src="../shared/examples.js"></script><!– EXAMPLES –>

<h1>GMap Window</h1>
<p>This example shows how to create an extension and utilize an external library.</p>
<input type="button" id="show-btn" value="Gimme a Map" /><br /><br />
<p>Note that the js is not minified so it is readable. See <a href="../ux/GMapPanel.js">GMapPanel.js</a> and <a href="gmap.js">gmap.js</a> for the full source code.</p>

</body>
</html>

Magento – How to Change multiselect list box to select box?


In magento, by default if a select option has more than 2 values, it automatically make the select box to multiselect box.
if you need to change this to remain always select box, here is how to do:

Steps:
Edit the Form.php:
Location: /public_html/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php
Position: public function getAttributeSelectElement($attribute)
Line no.: 185
What to change: <pre>if (is_array($options) && count($options)>2)</pre>  to <pre>if (is_array($options) && count($options)>100)</pre>

Magento – How to display 3 select boxes in a single row in advance search page (li)?


Steps:
Modify the /public_html/skin/frontend/default/f001/css/custom.css file:
(f001 is your defind template)

At the end add the following: custom.css
————————————————————————–
#rim_diameter_inches_li .multiselect {width:70px;}

#tyre_width_li .multiselect {width:50px;}

#profile_li .input-box .multiselect {width:60px;}

#rim_diameter_inches_li {width: 60px; float: left; }
#tyre_width_li{float: left;background-image: url(../images/search-splitter.gif);
background-repeat: no-repeat;
background-position: right center;}
#tyre_width_li .input-box {width: 70px; }

#profile_li {
width: 70px;
float: left;
}
#profile_li .input-box {width: 50px;  float: left; }
#rim_diameter_inches_li .input-box {float: left; width: 50px;}
———————————————————————–

The form fields are:
Defind in /public_html/app/design/frontend/base/default/template/catalogsearch/advanced/form.phtml file:
<pre>

<ul id=”advanced-search-list”>
<li id=”tyre_width_li”>
<label for=”tyre_width”>Tyre Size</label>
<div>
<select name=”tyre_width” id=”tyre_width” title=”Width (mm)”><option value=”" selected=”selected”>All</option><option value=”54″>175</option><option value=”53″>185</option><option value=”67″>195</option><option value=”80″>205</option><option value=”79″>215</option><option value=”78″>225</option><option value=”77″>235</option><option value=”76″>245</option><option value=”75″>265</option><option value=”74″>275</option><option value=”73″>287</option><option value=”72″>295</option><option value=”71″>314</option><option value=”70″>315</option></select>                        </div>

</li>
<li id=”profile_li”>
<label for=”profile”></label>
<div>
<select name=”profile” id=”profile” title=”Profile”><option value=”" selected=”selected”>All</option><option value=”26″>35</option><option value=”25″>40</option><option value=”24″>45</option><option value=”23″>55</option><option value=”22″>60</option><option value=”21″>65</option><option value=”20″>70</option><option value=”19″>75</option><option value=”18″>80</option><option value=”17″>NA</option></select>                        </div>

</li>
<li id=”rim_diameter_inches_li”>
<label for=”rim_diameter_inches”></label>
<div>
<select name=”rim_diameter_inches” id=”rim_diameter_inches” title=”RIM diameter inches”><option value=”" selected=”selected”>All</option><option value=”36″>14</option><option value=”35″>14C</option><option value=”88″>15</option><option value=”87″>16</option><option value=”86″>16C</option><option value=”85″>17</option><option value=”84″>18</option><option value=”83″>19</option><option value=”82″>20</option><option value=”81″>22.5</option></select>                        </div>

</li>
<div style=”clear: both; padding-left: 170px;”><b>WIDTH</b>&nbsp;(mm)&nbsp;/&nbsp;<b>PROFILE</b>&nbsp;<b>RIM</b> (diameter inches)
</div>                                    <li id=”size_li”>
<label for=”size”>Size</label>
<div>

<input name=”size” id=”size” value=”" title=”Size” type=”text”>
</div>

</li>
<li id=”speed_li”>
<label for=”speed”>Speed</label>
<div>
<input name=”speed” id=”speed” value=”" title=”Speed” type=”text”>
</div>

</li>
<li id=”brand_li”>
<label for=”brand”>Brand</label>
<div>
<input name=”brand” id=”brand” value=”" title=”Brand” type=”text”>
</div>

</li>
<li id=”pattern_li”>

<label for=”pattern”>Pattern</label>
<div>
<input name=”pattern” id=”pattern” value=”" title=”Pattern” type=”text”>
</div>

</li>
<li id=”price_li”>
<label for=”price”>Price</label>
<div>

<input name=”price[from]” value=”" id=”price” title=”Price” type=”text”>
<span>-</span>
<input name=”price[to]” value=”" id=”price_to” title=”Price” type=”text”>
<small>(AUD)</small>
</div>
</li>
</ul>

</pre>

BrowserLab – Preview web pages across multiple browsers and operating systems


Accurately pinpoint compatibility issues and compare web pages at a glance to easily identify differences and potential problems. Preview full screenshots with multiple view options and customizable test settings.

With the integration of Dreamweaver CS5 or Firebug, you can also give BrowserLab permission to preview web pages that are behind a firewall.

Magento – How to order the fields in catalog advance search page.


Steps:
1. Alter the table:`eav_attribute`, use the following command:
ALTER TABLE `eav_attribute` ADD `sort_by` INT( 4 ) NOT NULL DEFAULT ’500′
2. Edit the /public_html/app/code/core/Mage/CatalogSearch/Model/Advanced.php file:
Function Name: public function getAttributes()
Line no. #98
Change: ->setOrder(‘main_table.attribute_id’, ‘asc’) by ->setOrder(‘main_table.sort_by’, ‘asc’)
3. Done. Reload the ..index.php/catalogsearch/advanced/ page.

Magento Quick Links


Change Logo:
skin/frontend/default/default/images/
01. logo.gif
02. logo_email.gif

Main Templates:
/public_html/app/design/frontend/base/default/template/page

Side boxes:
/public_html/app/design/frontend/base/default/template/callouts

Majento Product Details Page:
/public_html/app/design/frontend/base/default/template/catalog/product/view.phtml

header:
/public_html/app/design/frontend/base/default/template/page/html/header.phtml
/public_html/app/design/frontend/default/f001/template/page/html

Search box:
/public_html/app/design/frontend/base/default/template/catalogsearch

Footer:
/public_html/app/design/frontend/base/default/template/page/html/header.phtml
in static blocks

remove footer links
/public_html/app/design/frontend/base/default/layout/catalog.xml
/public_html/app/design/frontend/base/default/layout/contacts.xml
/public_html/app/design/frontend/base/default/layout/catalogsearch.xml

Featured:
/public_html/app/design/frontend/default/default/template/inchoo

Compare Products:
/public_html/app/design/frontend/base/default/template/catalog/product/compare

Newsletter Box:
/public_html/app/design/frontend/base/default/template/newsletter

Installed Modules:
/public_html/app/design/frontend/default/default/template

Free themes:

http://www.patternhead.com/found-freebies/21-free-magento-themes-for-your-e-commerce-store

MODULES: /public_html/app/design/frontend/default/default/template

Slider : Simple Banners
magento-community/Banners

http://www.magentocommerce.com/magento-connect/Free+Magento+Extensions/extension/3382/banners

{{block type=”banners/banners” name=”banners” template=”banners/banners.phtml”}}

app\design\frontend\default\default\template\banners
app\design\frontend\default\default\layout\banners.xml

Side Blocks:
magento-community/AsiaConnect_FreeCMS

sidebar-right-top
sidebar-right-bottom
sidebar-left-top
sidebar-left-bottom
content-top
menu-top
menu-bottom
page-bottom

Featured:
magento-community/Inchoo_FeaturedProducts

index.php/featured-products/ (store link)

{{block type=”featuredproducts/listing” template=”inchoo/block_featured_products.phtml”}}

NEW Products:
{{block type=”catalog/product_new” name=”home.catalog.product.new” alias=”product_homepage” template=”catalog/product/new.phtml”}}

/public_html/app/design/frontend/default/f001/template/catalog/product
/public_html/app/design/frontend/base/default/template/catalog/product
/public_html/app/code/core/Mage/Catalog/Block/Product/new.php

Best Seller:
magento-community/Luxe_Bestsellers

{{block type=”bestsellers/list” name=”home.bestsellers.list” alias=”product_homepage” template=”catalog/product/list.phtml”}}

Default: {{block type=”bestsellers/list” name=”home.bestsellers.list” alias=”product_homepage” template=”catalog/product/list.phtml”"}}
Path: /public_html/app/design/frontend/base/default/template/catalog/product/list.phtml

Popular:
magento-community/Luxe_MostViewed”}}

{{block type=”mostviewed/list” name=”home.mostviewed.list” alias=”product_homepage” template=”catalog/product/list.phtml”}}

Include static block:

{{block type=”cms/block” block_id=”home-page-promo”}}
<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘footer_links’)->toHtml() ?>

IETester – Browser Compatibility Check for Internet Explorer


Browser Compatibility Check for Internet Explorer Versions from 5.5 to 9

IETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE9 preview, IE8, IE7 IE 6 and IE5.5 on Windows 7, Vista and XP, as well as the installed IE in the same process.

Download Links: here

Magento – Turning on the debug mode for filename path of templates and blocks


This is a handy options for the designer and developer of Magento. It can save you hours & hours of your time of finding where you need to make changes.

System->Current Configuration Scope->Main Website->Developer->Debug->Template Path Hints->Yes
System->Current Configuration Scope->Main Website->Developer->Debug->Add Block Names to Hints->Yes

Magento – Minimum Qty Allowed in Shopping Cart


Go to backend and make chanegs to:
Catelog->products->select a product->Inventory->Minimum Qty Allowed in Shopping Cart->set to any value

Easy CMS/Block – Frontend Features


  • Extension key: magento-community/AsiaConnect_FreeCMS

    Label

    Easy CMS allow to put any HTML content to any position on Magento site. You can put text, banner, advertisement, images, flash, music, video, product… After a short time with more than 4000+ download, EasyCMS Frontend Features is available to install via Magento Connect now. Get the extension and have a happy time with your site now. Read more of this post

Magento Fontis ANZ eGate


Provides integration with the ANZ eGate gateway interface. Only payments and refunds are allowed; void or pre-authorisation are not currently included in the extension. For more information, including screenshots, version history and instructions on configuration and usage, please see the Fontis ANZ eGate Magento extension page. To stay up-to-date with the latest releases, follow us on Twitter and subscribe to our blog. If you’d like to link to this extension, please use our extension page rather than this Connect listing. To see the other extensions we have available, visit our Magento extension page for a complete list. The development of this extension is commercially supported by Fontis. We welcome any feedback and suggestions from the community on the ongoing development of the extension. We can also provide customisation and development services upon request.



Magento how to remove minimum quantity allowed for purchase validation error


Just comment the line below: (Lines from #499 to #505)
/public_html/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php

if ($this->getMinSaleQty() && ($qty) getMinSaleQty()) {
            $result->setHasError(true)
                ->setMessage(Mage::helper('cataloginventory')->__('The minimum quantity allowed for purchase is %s.', $this->getMinSaleQty() * 1))
                ->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products cannot be ordered in requested quantity.'))
                ->setQuoteMessageIndex('qty');
            return $result;
        }

Magento how to change default quantity add to cart?


<input name="qty" type="text" class="input-text qty” id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product)== null?1:$this->getMinimalQty($_product) ?>"/>

put this code on \app\design\frontend\default\modern\template\catalog\product\view\type/sipmle.html
and check the there will appear the 1 on text box

Where is Magento’s advanced search link?


It is located in Advanced Search Link

Magento where is database configuration file?


Find the local.xml in local \\\magento\app\etc\local.xml
<pre class="brush:xml">
<config>

<db>
<table_prefix><![CDATA[]]></table_prefix>
</db>
<default_setup>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[bobjaneg_user]]></username>
<password><![CDATA[tES@A$pGtOF&]]></password>
<dbname><![CDATA[bobjaneg_cmsdb]]></dbname>
<active>1</active>
</connection>
</default_setup>

</config>
</pre>

Magento storing in session


$storage = array('a'=>'b');

// store data so we can fetch it in subtotal methods
Mage::getSingleton('core/session')->setRbanhShipping(serialize($storage));

// get data
$rbanhShipping = Mage::getSingleton('core/session')->getRbanhShipping(); 
$rbanhShipping = unserialize($rbanhShipping);

Magento how to get shipping quote per item in cart


foreach ($session->getQuote()->getAllItems() as $item) 
{
    $output .= "

"; $output .= $item->getWeight(); $output .= "
"; $output .= $item->getName() . "
"; $output .= "QTY:" . $item->getQty() . " | $" . number_format($item->getPrice(), 2); $output .= "

"; $temp_product = Mage::getModel('catalog/product') ->setCurrentStore(1) ->load($item->getProduct()->getId()); $quote2 = Mage::getModel('sales/quote'); //$quote2->setDestPostcode($session->getQuote()->getShippingAddress() ->getPostcode()); //$quote2->getShippingAddress()->setCountryId('US'); $quote2->setShippingAddress($session->getQuote() ->getShippingAddress()); $temp_product->getStockItem()->setUseConfigManageStock(false); $temp_product->getStockItem()->setManageStock(false); $quote2->addProduct($temp_product); $quote2->setPackageWeight($item->getWeight()); $quote2->getShippingAddress()->setCollectShippingRates(true); $quote2->getShippingAddress()->collectTotals(); $rates = $quote2->getShippingAddress()->getShippingRatesCollection(); //$rates = $quote2->getShippingAddress()->getAllShippingRates(); //var_export($rates); foreach ($rates as $rate) { $output .= " rbanh = ".$rate->getPrice()." " . $rate->getCode() . " END
"; } }

Magento auto add product custom options


// *Special note: make sure you check your sql table name, 
//  and change the option title from what i have below.

// rbanh special methods
private function rbanh_get_custom_option_id($product_id)
{
    $sql = "
        select 
            o.option_id 
        from 
            catalog_product_option o
        inner join
            catalog_product_option_title t on t.option_id = o.option_id
        where
            t.title = 'Shipping Description'
            and o.product_id = '".$product_id."'
        limit 1
            ";
    $data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchAll($sql);
    if (count($data) > 0)
    {
        return current($data[0]);
    }
    return false;
}

// rbanh special methods
private function rbanh_add_custom_option($product_id)
{
    // make the option active
    //$write = Mage::getSingleton('core/resource')->getConnection('core_write');
    //$write->query("update catalog_product_entity set has_options = 1 where entity_id='$product_id'"); 
    $write = Mage::getSingleton('core/resource')->getConnection('core_write');
    $sql  = "update catalog_product_entity set has_options = 1 where entity_id=?";
    $write->query($sql, $product_id); 
    
    $product = Mage::getModel('catalog/product');
    $product->load($product_id);
    $opt = Mage::getModel('catalog/product_option');
    $opt->setProduct($product);
    $option = array(
        'is_delete' => 0,
        'is_require' => false,
        'previous_group' => 'text',
        'title' => 'Shipping Description',
        'type' => 'field',
        'price_type' => 'fixed',
        'price' => '0.0000'
    );
    $opt->addOption($option);
    $opt->saveOptions();
    
    return $this->rbanh_get_custom_option_id($product_id);
}

Magento How to add new products



require_once 'app/Mage.php';
Mage::app();
 
// instatiate Product
$product = Mage::getModel('catalog/product');
 
$product->setWebsiteIds(array(1));
$product->setSku('rand-sku-' . rand());
$product->setPrice(rand(100,2000));
$product->setAttributeSetId(4); 
$product->setCategoryIds(array(3));
$product->setType('Simple Product');
$product->setName('Product Name'.rand(1,200000));
$product->setDescription('The Product Description');
$product->setShortDescription('Brief Description');
$product->setStatus(1);	
$product->setTaxClassId('2');
$product->setWeight(0);				
$product->setCreatedAt(strtotime('now'));
 
/* ADDITIONAL OPTIONS 
 
   $product->setCost();
   $product->setInDepth();
   $product->setKeywords();
 
*/
 
$product->save();
 
// "Stock Item" still required regardless of whether inventory
// control is used, or stock item error given at checkout!
 
$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->loadByProduct($product->getId());
$stockItem->setData('is_in_stock', 1);
$stockItem->save();
 
header("Location: /checkout/cart/add/product/".$product->getId()."/); 

Magento observer sales order



/**
 * Register an event trigger after the order has been saved
 *
 * Is triggered by sales_order_save_after event 
 *
 */
public function hookSalesOrderSaveAfter ($observer)
{
    $order = $observer->getEvent()->getOrder(); // returns the Mage_Sales_Model_Order Object
    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // Magento can only save attributes in admin mode
    $order->setVendor('LoremIpsum');
    $order->getResource()->saveAttribute($order, "vendor");
    $order->setCallToAction('ANC');
    $order->getResource()->saveAttribute($order, "call_to_action");
    $order->setKeycode('0x7474');
    $order->getResource()->saveAttribute($order, "keycode");
    return $this;
}

Magento displaying store id


// display store ID
echo "Store ID = " . Mage::app()->getStore()->getStoreId();

Display Magento sub categories


    $currentCat = Mage::registry('current_category');

    if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
    {
        // current category is a toplevel category
        $loadCategory = $currentCat;
    }
    else
    {
        // current category is a sub-(or subsub-, etc...)category of a toplevel category
        // load the parent category of the current category
        $loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
    }
    $subCategories = explode(',', $loadCategory->getChildren());

    foreach ( $subCategories as $subCategoryId )
    {
        $cat = Mage::getModel('catalog/category')->load($subCategoryId);

        if($cat->getIsActive())
        {


            echo 'getURL().'">'.$cat->getName().'
'; echo $cat->getDescription(); echo 'getImage().'">'; } }

Magento cart total + items


getSummaryQty(); ?>
There are  items  in your cart
					getQuote()->getAllItems() as $item) {
    $output .= "

"; $output .= $item->getName() . "
"; $output .= "QTY:" . $item->getQty() . " | $" . number_format($item->getPrice(), 2); $output .= "
"; } print $output;?>

Magento shopping cart total


helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()); ?>

Magento – How to load static block?


setStoreId(Mage::app()->getStore()->getId())->load("static_block_name"); ?>

Modify Magento TAX Calculation


Change the following file: magento\app\code\core\Mage\Tax\Model\Calculation.php

/**
     * Calculate rated tax abount based on price and tax rate.
     * If you are using price including tax $priceIncludeTax should be true.
     *
     * @param   float $price
     * @param   float $taxRate
     * @param   boolean $priceIncludeTax
     * @return  float
     */
    public function calcTaxAmount($price, $taxRate, $priceIncludeTax=false, $round=true)
    {
        $taxRate = 10;
		$taxRate = $taxRate/100;
		$this->insertInLog('taxRate', $taxRate);
		$this->insertInLog('price', $price);
        if ($priceIncludeTax) {
            $amount = $price*(1-1/(1+$taxRate));
        } else {
            $amount = $price*$taxRate;
        }
		$this->insertInLog('Amount', $amount);
        if ($round) {
            return $this->round($amount);
        } else {
            return $amount;
        }
    }


    /**
     * Insert in to Log Table. It helps to trace and stores in table
     *
     * @param   varchar $title
     * @param   varchar $desc
     */

	function insertInLog($title, $desc){		
		mysql_connect("localhost","root","");
		mysql_select_db("magento");
		$sql = "insert into log_tbl values('".$title."', '".$desc."', '".date("Y-m-d h:i:s")."')";
		mysql_query($sql);
	}

Edit PHTML Files in Dreamweaver


By default, Dreamweaver cannot read PHTML files. You can add the file type to the “Open in Code View” section of the preferences if you wish to have fast access, however you cannot view the file in design view if you do that. So if you use Dreamweaver (versions 4, MX, MX2004, 8, or 9, aka CS3,CS4) to design your sites, and you wish to open Magento’s Template files (they have .phtml extensions) in Dreamweaver, you can follow these steps to add support for .phtml and make Dreamweaver render PHP code (with coloring, hinting, et al) as well as allow you to see the design in code view if desired. Below are three steps to follow.*

IMPORTANT NOTES: This guide is for Dreamweaver on Windows (XP or Vista) or Mac OS X. Note: I have excluded version numbers from the file locations shown, and if you are using a version older than Dreamweaver 9 (CS3) replace “Adobe” with “Macromedia” in the file locations shown. Some spaces have also been removed to keep the references on one line.

* Dreamweaver 4 users: if you are using the archaic Dreamweaver 4, you only need to follow step one. However, it’s highly recommended that you just upgrade to version 8, CS3 or newer for superb CSS and Web Standards support.

* Vista may need to edit files by running notepad as Administrator, however this requirement is not common and if encountered, may be avoidable by following these steps after a fresh restart. However, if unavoidable, simply go to Start > All Programs > Accessories, and then right click on Notepad and select “Run as Administrator”. Once notepad is open, use File > Open to browse to the applicable file before making the necessary changes.

Step One: Add .phtml to extension.txt in your Application Data

Open the following extension configuration file in a notepad and change the lines as specified below:

XP: Documents and Settings > [user] > Application Data > Adobe Dreamweaver > Configuration > extensions.txt

NOTE: If you cannot see the Application Data Folder, go to Tools → Folder Options → View and make sure that Show Hidden Files and Folders is checked.

Vista: Users > [user] > AppData > Roaming > Adobe > Dreamweaver 9 > Configuration > Extensions.txt Read more of this post

How to retrieve customer name/firstname in Magento


require_once 'app/Mage.php';
umask(0);
Mage::app('default');
$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
   $customer = $session->getCustomer();
   echo $customer->getName();
   echo $customer->getFirstname();
}

Magento isRecurring


    /**
     * Whether there are recurring items
     *
     * @return bool
     */
    public function hasRecurringItems()
    {
        foreach ($this->getAllVisibleItems() as $item) {
            if ($item->getProduct() && $item->getProduct()->isRecurring()) {
                return true;
            }
        }
        return false;
    }

Top PHP 5 Projects


icon.png Kumbia PHP Framework php Framawork spanish, mvc, full support, forms generation, AJAX and Web 2,0 focused
latus_logo.gif LATUS LATUS is the Site Management System developed by MoveNext from Leiden, the Netherlands
live_agent_logo.gif Live Agent Chat LiveAgent live chat software is THE live chat solution for your website. This PHP / MySQL / AJAX script is completely web based.
LoveCMS LoveCMS is a simple content managment system for producing websites without learning curve.
logo_s.jpg Magike Magike is a powerful blog software based on PHP5.

Read more of this post

How to create a Password Protected Directory using linux command prompt?


Create a .htaccess file in the folder you want to set.
like:
#root@adu [/home/hostsite/public_html/admin]# vi .htaccess
copy and paste the following lines:
———————————————————-
AuthName “Secure Area”
AuthType Basic
AuthUserFile /home/hostsite/public_html/admin/.htpasswd
require valid-user
———————————————————-
Now set a password:
#htpasswd -c .htpasswd admin
New password: admin321
confirm password: admin321

You are done. test it: www.hostsite.com.au/admin and enter user name as admin and password as admin321

Magento Indexing Problem and solution


Stock Status Index process is working now. Please try run this process later.

I have resolved the indexing problem. Problem was with the permission and ownership  to /public_html/var/locks directory.
#chown -R owner_name:group_name directory
e.g [/home/spsimpo/public_html/var]# chown -R spsimpo:spsimpo locks
N.B MUST BE THE SAME OWNER AND GROUP OF /VAR
Also need to chmod 777 to all files under /public_html/var/locks
[/home/spsimpo/public_html/var]# chmod -R 777 locks

All the files under /public_html/var/locks has to be like below:

-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:05 index_process_1.lock*
-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:05 index_process_2.lock*
-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:05 index_process_3.lock*
-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:17 index_process_4.lock*
-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:09 index_process_5.lock*
-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:07 index_process_7.lock*
-rwxrwxrwx 1 spsimpo spsimpo   31 Jan 24 11:05 index_process_9.lock*

 

Cpanel Webalizer statistics without cpanel login


CPanel offers you the ability to check your website statistics with a program called webalizer. The problem with this system is that you are required to login via cpanel, and click through 2 diferent subsections in order to access them. This tutorial will guide you on the steps needed to make your webalizer statistics available via www.yoursite.com/stats/ .

Login to your hosting account via ssh. If you do not have ssh, ask your host to enable it. if they won’t enable it, ask them to read this tutorial, and run through these directions yourself.

Navigate to your public_html directory by running the following command

cd public_html

Once there, type the following:

vi .htaccess

once that loads, hit your i key, and type the following:

Options +FollowSymLinks

Once that is done, hit your Esc (escape) key, and type the following:

:wq

This will write to the .htaccess file, and quit.

Next, run the following command

ln -s ~/tmp/webalizer stats

you can replace the “stats” part of that command with name you want to use in order to access your website statistics.

After that, run the following commands

chmod 755 ~/tmp
chmod 755 ~/tmp/webalizer

now you can access www.yoursite.com/stats/ to access your webalizer statistics.

Enjoy

Follow

Get every new post delivered to your Inbox.