Bitnami Magento Development

SSH Connection using Putty:

Windows does not come with a bundled SSH client by default. It is recommended that you use the freely available Putty utility, which can be downloaded from:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

You will need to get your SSH key in PPK format

Once you have your key in PPK format, you can connect following these steps:

  • Start Putty ( Start Menu -> Programs -> Putty -> Putty ).
  • Enter your machine IP address or public domain name in the Session section. You can find out the hostname of a server by going to the Servers page, selecting the server and clicking ‘Manage Server’. The hostname will appear next to Public DNS and it will be similar to ‘xyz.bitnamiapp.com. Of course a server needs to be running so you can connect to it.
  • Putty Config
  • Add your private SSH PPK key path.
  • Putty Config
  • Click “Open” to start the SSH session.
  • Click “yes” to accept SSH key.
  • Enter your login: bitnami
  • ssh

You can also simplify the above procedure and add your key to the special SSH agent. This way you will not have to provide your ssh key every time you connect.

  • Start “Pageant” ( Start Menu -> Programs -> Putty -> Pageant ).
  • Click “Add key” and choose the PPK file.
  • Open “Putty” application ( Start Menu -> Programs -> Putty -> Putty ).
  • Go to Connection -> Data using the left menu.
  • Enter “bitnami” as the “Auto-login username”.
  • Go to “Session”.
  • Insert your server Public DNS (ec2-xyz.compute-1.amazonaws.com / xyz.bitnamiapp.com) in the “Host Name” field. You can find this in Server Management for BitNami Cloud Hosting servers or in the instance properties in Amazon console.
  • Click “Open” to start the SSH session.

If you prefer to use putty from the command line you should include ‘-i’ and ‘-l’ options as follows:

> putty -i “C:\Path\To\bitnami-hosting.ppk” -l bitnami example.com

Upload Files ( Using FTP)

You should follow these steps to upload files using FileZilla:

  1. Get your SSH Key in PPK format
  2. Start FileZilla
  3. Go to edit -> preferences
  4. Select SFTP
  5. Click “Add keyfile”
  6. Select the PPK file
  7. Save the settings (click OK in settings window)
  8. In the connection toolbar, enter:
    1. Host: the Public DNS ( xyz.bitnamiapp.com / ec2-xwz.compute-1.amazonaws.com)
    2. User: ‘bitnami’
    3. Password: leave it blank
    4. Port: 22
  9. Click “Quickconnect”
  10. If you get a message “The server’s host key is unknown”, click “ok” button
ftp

Connect Database Using Phpmyadmin

By default phpMyAdmin and phpPgAdmin are not accessible from the outside for security reasons. In order to access them, you can create an SSH tunnel to Apache, sending your requests to your webserver from 127.0.0.1 (localhost).

You should follow these steps to create the tunnel:

  1. Get your SSH private key if you don’t have it already.
  2. Create the tunnel (Use Putty).
    • Follow the steps described SSH Connection using Putty above
    • Before opening the connection. Go to Connection -> SSH -> Tunnels, enter the values below and click “Add” button:
      • Source port: “8888”
      • Destination: “localhost:80”
    • Click Open
  3. While the tunnel is active you can connect to the web application at http://127.0.0.1:8888/phpmyadmin or http://127.0.0.1:8888/phppgadmin in your browser.
    The default login is:
    • username: root (“administrator” for legacy versions) for MySQL or postgres for PostgreSQL database.
    • password: bitnami (for BitNami AMIs), <application password> (for BitNami Cloud Hosting)

Magento 2

Magento is an ecommerce platform built on open source technology which provides online merchants with a flexible shopping cart system. It offers powerful marketing, search engine optimization and catalogue management tools. Magento is the fastest growing and most powerful ecommerce platform in the world. Since being launched in 2007, Magento has grown to become one of the most powerful ecommerce platforms in the industry.

Why is Magento the most preferred E-Commerce Platform?

  • Magento platform comes packed with loads of user-friendly features.
  • It allows updating ecommerce website automatically, which is not available in other e- commerce platforms.
  • It is simple, quick and versatile, which makes it easy for customers to search and purchase products and services through Magento-powered websites.
  • Magento offers users with highly interactive shopping experience.
  • Besides supporting multiple website, Magento also lends support to online stores in promoting their inventory in diverse domains.
  • Magento being designed to be a configuration based MVC system (along with a range of extensions) helps to make website highly scalable.
  • Magento e-commerce platform features include a powerful SEO, marketing and catalogue management tools so as to fulfill exclusive business requirements of merchants.
  • It can increase the efficiency of operations and widen product reach by integrating Magento store with other outlets.

Versions of Magento

One of the currently used version in Magento is the Community Edition, which is free, open source platform that is designed for developers to build upon.

Since the first public beta version was released in 2007, the Magento Community Edition has been developed and customized in order to provide a basic ecommerce platform for businesses from all industries. The latest version: 1.9.0.1 was released on 15thMay 2014. And the new upcoming version, Magento 2, is in the development phase.

Magento 2

Magento 2 aims to provide an interesting set of features which includes, performance improvement, efficient development and latest security features. Magento 2 comes with a distinctive set of changed/improved frontend approaches compared to its predecessor Magento 1.X. Magento 2.0 will run on PHP 5.3 and Zend Framework as 1.0. And it will support MSSQL, Oracle and some other database as well. The frontend is now updated with newer technologies such as HTML5, CSS3 and jQuery. Considering the theme workflow, one of the first changes in Magento 2 is certainly the removal of skin directory. Everything is organized directly under the app structure.

Another big change is that every module has its own VIEW directory where all module-specific templates, layouts, js, and css/less files are stored. This is a better approach and certainly it will be beneficial for module developers. All visual content will be stored directly within the module, separating it from previous versions. There are also significant changes/improvements to overall layout manipulation, file structure and a brand new introduction to Magento UI library heavily based on LESS preprocessor with built in compiler. Reason for choosing LESS over other pre-processors is because Magento 2 comes with internal compiler to compile CSS directly from PHP. This will speed up development and allow developers to focus just on file editing/production while the system covers all the hassle with compiling etc. Magento UI Library certainly provides a lot of powerful material and ideas in general, especially for projects that require more of a skinning type approach. Layout files are now divided into smaller parts. For Magento 2.0, the directories structures will be quite similar to the Zend Framework. This is very exciting for theme development as things like Layout Templates, CSS, Images, JavaScript become more modular. You can manage all of them within a module folder. Probably the intention is to simplify the maintenance. Magento 2 introduces the new concept for product/media image resizing actions right from the layout. One of the great changes in Magento 2 is the introduction of a container wrapper, successor to a core/text_list block type which served the role of a structural block in the previous versions of the system, thereby introduces the possibility to pass attributes like htmlTag,htmlClass, htmlId directly from layout files which is really interesting.

Being in the development phase, Magento 2 is a substantially improved system when it comes to frontend development, compared to its predecessor.

It is difficult to setup automated tests for Unit Testing, Integration, Functional and Performance Testing as Magento don’t have such module by default. With Magento 2.0, you can setup automated tests pretty easy compared to the 1.x series. Hence, there is a great deal of focus on the improved standards in code quality. The testing framework integrated with Magento 2 includes the following:

  • Integration Testing(framework)
  • Unit Testing
  • Static Testing
  • Performance Testing
  • JavaScript Testing
  • Legacy and Migration Testing

All these testing techniques enable integrations to achieve a larger success and helps merchants run their business much more effectively.

Magento has increased its focus in making the upgrade easier for both Enterprise and Community Editions. With the availability of tools specific for upgradation, the process to upgrade from Magento 2.0 to 2.x and the upgrade from a Community Edition to an Enterprise Edition will be much easier.

With the 2.0, the performance of Magento will be at least 20% faster than the latest Magento 1.x versions. With all new technologies included, improved architecture and workflow, frontend development now requires a far more professional approach than before.

Generate Magento Admin URL with Parameters and Key

To generate Magento Admin URL with Parameters and Key, use below given codes:
Mage::helper("adminhtml")->getUrl("module_name/controller_name/action_name/",array("param1"=>1,"param2"=>2));
To generate a link for the design Configuration, here is an example:
Mage::helper("adminhtml")->getUrl("adminhtml/system_config/edit", array('section'=>'web'));
The adminhtml helper will automatically create url with keys attached to the URL. If you want to generate keys used in the URL, use below given codes:
Mage::getSingleton('adminhtml/url')->getSecretKey("adminhtml_customcontroller","customaction");

Add “wysiwyg” editor in magento Custom Module

Go to the file {your magento root folder}/Block/Adminhtml/{module name}/Edit/Tab/Form.php add following code in top of the file
$fieldset->addField('followupemail_text', 'editor', array( 
'name'=>'followupemail_text',
'label' => Mage::helper('followupemail')->__('Content'),
'title' => Mage::helper('followupemail')->__('Content'),
'required' => true,
'style' => 'height:24em;',
'config' => $wysiwygConfig, ));
go to the file {your magento root folder}/Block/Adminhtml/{module name}/Edit.php add the following line in this file
 
protected function _prepareLayout()
{
// Load Wysiwyg on demand and Prepare layout
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head')))
{
$block->setCanLoadTinyMce(true);
}
parent::_prepareLayout();
}
Note : Never use “content” as field name.

Adding custom product attribute to quote and order items in Magento

If you are developer, adding custom product attribute to quote and order items in Magento is pretty common task. And if you face with the same issue we will be very glad when you find this article helpful. Start with creating new module. In config.xml we need to define resources section which allows us to use install and upgrade scripts. This way all necessary changes will be made in the database – so, let’s do it:
<resources>
    <custom_attributes_setup>
        <setup>
            <module>Atwix_CustomAttribute</module>
            <class>Mage_Catalog_Model_Resource_Setup</class>
        </setup>
    </custom_attributes_setup>
</resources>
Note, that module installation process will be divided in several steps. Using Magento setup classes (in our case Mage_Catalog_Model_Resource_Setup) we add new custom product attribute. This is our first step and here is how install script looks like (install-1.0.1.php):
$installer = $this;
 
$installer->addAttribute('catalog_product', 'custom_attribute', array(
    'group'             => 'General',
    'type'              => Varien_Db_Ddl_Table::TYPE_VARCHAR,
    'backend'           => '',
    'frontend'          => '',
    'label'             => 'Custom Attribute',
    'input'             => 'text',
    'class'             => '',
    'source'            => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'default'           => '',
    'searchable'        => true,
    'filterable'        => true,
    'comparable'        => true,
    'visible_on_front'  => true,
    'unique'            => false,
    'apply_to'          => 'simple,configurable,virtual',
    'is_configurable'   => false
));
After launching installer script we can see our custom attribute at the backend: Next installation step is to add our custom attribute to the entities. In other words: to add neccessary fields to the tables, so we will be able to store our attribute. File upgrade-1.0.1-1.0.2.php:
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
/**
 * Add 'custom_attribute' attribute for entities
 */
$entities = array(
    'quote',
    'quote_address',
    'quote_item',
    'quote_address_item',
    'order',
    'order_item'
);
$options = array(
    'type'     => Varien_Db_Ddl_Table::TYPE_VARCHAR,
    'visible'  => true,
    'required' => false
);
foreach ($entities as $entity) {
    $installer->addAttribute($entity, 'custom_attribute', $options);
}
$installer->endSetup();
Note. Exclude entities that you don’t need. So, the database tables are ready. Furthermore, we need to implement the mechanism for converting (copying) our custom product attribute to quote item and order item. Fortunately, it is pretty easy with Magento. At first, you should add custom attribute to sales->quote->item->product_attributes node:
<sales>
    <quote>
        <item>
            <product_attributes>
                <custom_attribute />
            </product_attributes>
        </item>
    </quote>
</sales>
This makes attribute accessible when we will be copying it from the product to quote item – which is our next step. For this task the observer is used, and the event will be called sales_quote_item_set_product:
<sales_quote_item_set_product>
    <observers>
        <atwix_customattribute>
            <class>atwix_customattribute/observer</class>
            <method>salesQuoteItemSetCustomAttribute</method>
        </atwix_customattribute>
    </observers>
</sales_quote_item_set_product>
Obsever:
public function salesQuoteItemSetCustomAttribute($observer)
{
    $quoteItem = $observer->getQuoteItem();
    $product = $observer->getProduct();
    $quoteItem->setCustomAttribute($product->getCustomAttribute());
}
The last thing we need to carry about – it is converting attribute from quote item to order item. And this can be done with xml:
<fieldsets>
    <sales_convert_quote_item>
        <custom_attribute>
            <to_order_item>*</to_order_item>
        </custom_attribute>
    </sales_convert_quote_item>
    <sales_convert_order_item>
        <custom_attribute>
            <to_quote_item>*</to_quote_item>
        </custom_attribute>
    </sales_convert_order_item>
</fieldsets>
That’s it. Make a test order and check sales_flat_order_item table. If you see your custom attribute there that means – everything works. For more details andsource code please click here