Tuesday, 30 July 2013

magento multi vendor extension free

Give your vendors the freedom to manage their own products, and notify them automatically of their new orders.

Site link ishttp://www.magentocommerce.com/magento-connect/super-simple-multi-vendor-marketplace-free-2295.html

Magento Connecthttp://connect20.magentocommerce.com/community/Junaidbhura_Jbmarketplace

Please copy the above magento connect and install in into your store.


















Magento File System

The File System Magento extension is an indispensable tool for every website administrator. With File System, you can manage your Magento files exactly from the administration panel. Now you don't have to open your FTP client every time you need to make some slight changes in your files.

Forget about these FTP or SSH connections which are too expensive and difficult to use. With the File System Magento extension, you can easily do all the necessary operations. Just install this MagPlesure module and enjoy the simplicity of use!

This a free magento extension.
Link : http://www.magentocommerce.com/magento-connect/file-system.html















Wednesday, 24 July 2013

php difference between echo and print

Echo can accept multiple expressions while print cannot. For performance echo is faster than print since it does not return a value.
Print always returns 1 (integer).
Echo does not return any value.












php difference between session and cookie

The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not.

Cookies will only expire on expiry time or if you explicitly clean cookie / cache of your browser. Cookies will retain into the system even after you open your browser next day. Cookies are stored on client's system so they are less secure.

Session will expire on its expiry time or if the browser has been closed. As session is stored on server so it is more secure.

So for a log-in module, a combination of session and cookie should be used.










php difference between include and require

require will throw a PHP Fatal Error if the file cannot be loaded. (Execution stops)

include produces a Warning if the file cannot be loaded. (Execution continues)
















Thursday, 11 July 2013

Magento Shorten the URL of a Module / Rewrite

Write this below code under the <global> in config.xml(app\etc) file.


       <rewrite>
<fancy_url>
<from><![CDATA[/path_name(.*)/]]></from>
<to><![CDATA[modulename/controllername/function_name/]]></to>
<complete>1</complete>
</fancy_url>

                <!--   This code for passing parameters  -->
<fancy_url>
<from><![CDATA[/path_name\/(.*)/]]></from>
<to><![CDATA[modulename/controllername/function_name/parameters/$1/]]></to>
                 <!--Current url = www.storename.com/deb/index/view/username/demo -->
<complete>1</complete>
</fancy_url>
</rewrite>

Magento Custom Shipping Module

In this blog i have describe how to create custom shipping module in magento.

I have used one method for this module named "My_Ship".

There are 3 primary things required for create this module.
1) system.xml
2) config.xml
3) Shipping Module

Step 1


Create system.xml file in app\code\local\Deb\Ship\etc folder, then use the below code in this file.


<?xml version="1.0"?>
<config>
   <sections>
    <carriers>
        <groups>
           <express translate="label">
    <label>Deb Express Shipping Method</label>
    <frontend_type>text</frontend_type>
    <sort_order>1</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <fields>
        <active translate="label">
            <label>Enabled</label>
            <frontend_type>select</frontend_type>
            <source_model>adminhtml/system_config_source_yesno</source_model>
            <sort_order>1</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </active>
        <name translate="label">
            <label>Method name</label>
            <frontend_type>text</frontend_type>
            <sort_order>3</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
        </name>
        <price translate="label">
            <label>Price</label>
            <frontend_type>text</frontend_type>
            <sort_order>5</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </price>
        <handling_type translate="label">
            <label>Calculate Handling Fee</label>
            <frontend_type>select</frontend_type>
            <source_model>shipping/source_handlingType</source_model>
            <sort_order>7</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </handling_type>
        <handling_fee translate="label">
            <label>Handling Fee</label>
            <frontend_type>text</frontend_type>
            <sort_order>8</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </handling_fee>
        <sort_order translate="label">
            <label>Sort order</label>
            <frontend_type>text</frontend_type>
            </sort_order><sort_order>100</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        <title translate="label">
            <label>Title</label>
            <frontend_type>text</frontend_type>
            <sort_order>2</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
        </title>
        <type translate="label">
            <label>Type</label>
            <frontend_type>select</frontend_type>
            <source_model>adminhtml/system_config_source_shipping_flatrate</source_model>
            <sort_order>4</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </type>
        <sallowspecific translate="label">
            <label>Ship to applicable countries</label>
            <frontend_type>select</frontend_type>
            <sort_order>90</sort_order>
            <frontend_class>shipping-applicable-country</frontend_class>
            <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </sallowspecific>
        <specificcountry translate="label">
            <label>Ship to Specific countries</label>
            <frontend_type>multiselect</frontend_type>
            <sort_order>91</sort_order>
            <source_model>adminhtml/system_config_source_country</source_model>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </specificcountry>
        <showmethod translate="label">
            <label>Show method if not applicable</label>
            <frontend_type>select</frontend_type>
            <sort_order>92</sort_order>
            <source_model>adminhtml/system_config_source_yesno</source_model>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
        </showmethod>
        <specificerrmsg translate="label">
            <label>Displayed Error Message</label>
            <frontend_type>textarea</frontend_type>
            <sort_order>80</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
        </specificerrmsg>
    </fields>
</express>

</groups>
        </carriers>
    </sections>
</config>

Step 2


Create one config.xml file in app\code\local\Deb\Ship\etc folder and used the below code.



<?xml version="1.0"?>
<config>
  <modules>
    <Deb_Ship>
      <version>0.1.0</version>
    </Deb_Ship>
  </modules>
  <global>
    <models>
      <ship>
        <class>Deb_Ship_Model</class>
      </ship>
    </models>  
  </global>
  <default>
<carriers>
<express>
            <active>0</active>
            <sallowspecific>0</sallowspecific>
            <model>shipping/carrier_express</model>
            <name>Express</name>
            <price>5.00</price>
            <title>Express</title>
            <type>I</type>
            <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
            <handling_type>F</handling_type>
    </express>

</carriers>
  </default>
</config>

Step 3


Create one Express.php file in app\code\local\Deb\Ship\Model\Carrier  folder and used the below code.




<?php
class Deb_Ship_Model_Carrier_Express
    extends Mage_Shipping_Model_Carrier_Abstract
    implements Mage_Shipping_Model_Carrier_Interface
{
    protected $_code = 'express';
    public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        if (!$this->getConfigFlag('active')) {
            return false;
        }
        $freeBoxes = 0;
        if ($request->getAllItems()) {
            foreach ($request->getAllItems() as $item) {
                if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
                    $freeBoxes+=$item->getQty();
                }
            }
        }
        $this->setFreeBoxes($freeBoxes);
        $result = Mage::getModel('shipping/rate_result');
        if ($this->getConfigData('type') == 'O') { // per order
            $shippingPrice = $this->getConfigData('price');
        } elseif ($this->getConfigData('type') == 'I') { // per item
            $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
        } else {
            $shippingPrice = false;
        }
        $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
        if ($shippingPrice !== false) {
            $method = Mage::getModel('shipping/rate_result_method');
            $method->setCarrier('express');
            $method->setCarrierTitle($this->getConfigData('title'));
            $method->setMethod('express');
            $method->setMethodTitle($this->getConfigData('name'));
            if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
                $shippingPrice = $this->getConfigData('price');
            }
            $method->setPrice($shippingPrice);
            $method->setCost($shippingPrice);
            $result->append($method);
        }
        return $result;
    }
    public function getAllowedMethods()
    {
        return array('express'=>$this->getConfigData('name'));
    }
}

?>




Then create xml file for active this module in magento store.

Create Deb_Ship.xml in app\etc\modules and used the below code.


<?xml version="1.0"?>
<config>
    <modules>
        <Deb_Ship>
            <active>true</active>
            <codePool>local</codePool>
        </Deb_Ship>
    </modules>
</config>

enjoy................