Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

Sunday, 26 July 2015

Steps to Install a Magento Security Patch

This tutorial requires you to have SSH access to your server.

Security patch? Whats that!

Every time there is a major leak discovered in Magento, the company releases a patch that fixes the issue. The patch is a small .sh file that you can upload to your server, and execute with a SSH command, we’ll get to that later. The reason why Magento releases these patches is that they can be applied very quickly. We have upgraded some very big Magento stores and it’s a long process that takes a lot of time. Especially if the Magento store has a lot extensions that might not be compatible with a newer version of the CMS. Patches save time, they only fix whats broken and nothing else.

How to install a Magento patch

Installing a patch is very simple. First, you have to go to the Magento downloads page to download the correct patch for your Magento version. After the download has finished you’ll have a compressed folder. Unzip the folder and you should see a .sh file. Log in to your FTP client and connect to your host. Upload the .sh file in the root folder of your Magento installation.
The second step is also the last step (we told you, patches are a very quick solution ;)). Log in to your server via SSH, and navigate to the root folder where your Magento installation is located. In the root folder, execute the following SSH command:
Thats all there is to it. If you have executed this command correctly, the following message wil be displayed:

Friday, 17 July 2015

Import Customer Group Price for Product using CSV in Magento

Hi,

Please use the below Github link to Download the Extension and install to your Magento site.

Once after installing, you will see the import option System > Import/Export > Import - Custom.

https://github.com/ryaan-anthony/import-group-prices 

Tuesday, 19 May 2015

Create a simple Magento payment module

Here is small example which will explain how to create a simple Magento payment module.
I hope that you know how to create magento module and I will skip this step.
First of all, you have to create in etc folder config.xml file with next content:
< ?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<test_mycheckout>
<version>1.0.0</version>
</test_mycheckout>
</modules>
 
<global>
<models>
<mycheckout>
<class>Test_Mycheckout_Model</class>
</mycheckout>
</models>
<helpers>
<mycheckout>
<class>Test_Mycheckout_Helper</class>
</mycheckout>
 
</helpers>
<blocks>
<mycheckout>
<class>Test_Mycheckout_Block</class>
</mycheckout>
</blocks>
</global>
 
<default>
<payment>
<mycheckout>
<model>mycheckout/standard</model>// very important thing, here you select the model for your payment method
<active>1</active>
<order_status>pending</order_status>
<title>CUSTOM CARD</title>
<payment_action>sale</payment_action>
<submit_url>https://someurl.com</submit_url>
<merchant_id>Insert merchant id</merchant_id>
<allowspecific>0</allowspecific>
<sort_order>1</sort_order>
</mycheckout>
</payment>
</default>
 
<frontend>
<routers>
<mycheckout>
<use>standard</use>
<args>
<module>Test_Mycheckout</module>
<frontname>customcard</frontname>
</args>
</mycheckout>
</routers>
</frontend>
</config>
Next step: you have to create system.xml file also in etc folder with next content:
< ?xml version="1.0"?>
<config>
<sections>
<payment>
<groups>
<mycheckout translate="label comment" module="paypal">
<label>Custom CARD MyCheckOut</label>
<frontend_type>text</frontend_type>
<sort_order>0</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>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</active>
<title translate="label">
<label>Title</label>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
 
</title>
<order_status translate="label">
<label>New Order Status</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_order_status</source_model>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</order_status>
<submit_url>
<label>Gateway URL</label>
<frontend_type>text</frontend_type>
<sort_order>58</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</submit_url>
<merchant_id>
<label>Merchant ID</label>
<frontend_type>text</frontend_type>
<sort_order>59</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</merchant_id>
<allowspecific translate="label">
<label>Payment Applicable From</label>
<frontend_type>select</frontend_type>
<sort_order>60</sort_order>
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</allowspecific>
<specificcountry translate="label">
<label>Countries Payment Applicable From</label>
<frontend_type>multiselect</frontend_type>
<sort_order>70</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>
<depends><allowspecific>1</allowspecific></depends>
</specificcountry>
<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>
 
</fields>
</mycheckout>
</groups>
</payment>
 
</sections>
</config>
In this system.xml file we create options for this payment method. These options you will see in admin section under payment method, also if you need additional options you can add them.
Last step: is creating model in folder model with file-name standard.php. This model is defined in config.xml file. Here is example:
< ?php
 
class Test_Mycheckout_Model_Standard extends Mage_Payment_Model_Method_Abstract
{
 
protected $_code = 'mycheckout';
 
protected $_isInitializeNeeded      = true;
protected $_canUseInternal          = false;
protected $_canUseForMultishipping  = false;
 
/**
* Return Order place redirect url
*
* @return string
*/
public function getOrderPlaceRedirectUrl()
{
//when you click on place order you will be redirected on this url, if you don't want this action remove this method
return Mage::getUrl('customcard/standard/redirect', array('_secure' => true));
}
 
}
If your method redirect when customer click on checkout button place order you have to create (customcard/standard/redirect) standard controller with method redirectAction and etc. This page will create html form which will send POST data to payment gateway. All data which you need for creating this form you can get from Magento model $session = Mage::getSingleton(‘checkout/session’); and etc.
When you finish everything you will get next option in admin section:

Friday, 6 March 2015

How to Delete all products programmatically in Magento

Please try below code,

$products = Mage::getResourceModel('catalog/product_collection')->getAllIds();
foreach ($products as $key => $productId)
{
    try {
        $product = Mage::getSingleton('catalog/product')->load($productId);
        Mage::dispatchEvent('catalog_controller_product_delete', array('product' => $product));
        $product->delete();
    } catch (Exception $e) {
        echo "<br />Cannot delete product ID: $productId";
        }
}

Saturday, 21 February 2015

Create Custom Tab under Sales->order in Magento Admin

Create: app/code/local/Itflex/CustomSalestab/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Itflex_CustomSalestab>
            <version>1.0.1</version>
        </Itflex_CustomSalestab>
    </modules>
    <global>
        <blocks>
            <customsalestab>
                <class>Itflex_CustomSalestab_Block</class>
            </customsalestab>
        </blocks>
    </global>      
    <adminhtml>
       <layout>
            <updates>
                <customsalestab>
                    <file>itflex_customsalestab.xml</file>
                </customsalestab>
            </updates>
        </layout>
    </adminhtml>
</config>


Create: app/code/local/Itflex/CustomSalestab/Block/Adminhtml/Order/View/Tab/Customtab.php

<?php
class Itflex_CustomSalestab_Block_Adminhtml_Order_View_Tab_Customtab
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{   
    public function _constuct()
    {
        parent::_construct();
        $this->setTemplate('itflex/customsalestab/order/view/tab/customtab.phtml');
    }

    public function getTabLabel() {
        return $this->__('Custom Tab');
    }

    public function getTabTitle() {
        return $this->__('Custom Tab');
    }

    public function canShowTab() {
        return true;
    }

    public function isHidden() {
        return false;
    }

    public function getOrder(){
        return Mage::registry('current_order');
    }
}
?>


Create: app/design/adminhtml/default/default/template/itflex/customsalestab/order/view/tab/customtab.phtml

<?php echo 'add your html/php code here'; ?>


Create: app/design/adminhtml/default/default/layout/itflex_customsalestab.xml

<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab">
                <name>order_view_tab_order</name>
                 <block>customsalestab/adminhtml_order_view_tab_customtab</block>
            </action>
        </reference>
</adminhtml_sales_order_view>
</layout>

Create: app/etc/modules/Itflex_CustomSalestab.xml

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