Wednesday, May 29, 2013

Published 12:06 PM by with 0 comment

Create and map shared folder in VirtualBox


VirtualBox is a great virtualization software from Sun Microsystems. I’ve previously written many articles on how to create a virtual machine in VirtualBox and how to install Windows 7 using VirtualBox.
If you’ve had any experience with virtualization software, you’ve probably also heard of VMWare and Virtual PC. I’ve previously used Virtual PC from Microsoft for all my needs and one feature that I really liked was the ability to easily share files and folders between the guest and host operating system.
In Virtual PC, all you had to do in order to share files from the host OS to the guest OS was drag and drop onto the desktop. Super easy. When I switched over to VirtualBox, I realized that sharing folders in VirtualBox is not as simple as dragging and dropping.
virtualbox share folders
This was really annoying to me at first and it took me a little while to figure out exactly how to do it! In this article, I will walk you through the steps for sharing folders between guest and host OS in VirtualBox.
First, you have to install VirtualBox Guest Additions in the guest OS. You can do this by going to Devices and clicking onInstall Guest Editions.
share folders between guest and host
Once installed and your guest OS rebooted, you need to create a virtual shared folder. You can do this by going to Devicesagain and clicking on Shared Folders.
shared folders
Now click on the Add New Shared Folder button on the right.
share files virtualbox
In the Folder Path box, click the down arrow and then click Other. Browse to the folder on the host OS that you would like to share with the guest OS. In the Folder Name box, give your share a name. You can choose to make it read-only and to make the shared folder permanent.
add a shared folder
Click OK and the new shared folder will show up under Machine Folders if you chose to make it Permanent, otherwise it will show under Transient Folders.
share folders virtualbox
Now click OK to close the Shared Folders dialog. You have to do one more thing in order to be able to actually access the folder on the host OS. Depending on whether the Guest OS is running Windows or Linux (Ubuntu, etc), the method is different.

Windows Guest

In this case, you can either browse to the shared folder by going to My Network Places – Entire Network – VirtualBox Shared Folders or you can map a drive letter to that shared folder. I prefer the second method to make it easily accessible.
net use x: \\vboxsvr\sharename
To do this, open an command prompt and type in the above command. Simply replace sharename with the Folder Name you used when adding a share. Note that you do NOT need to change vboxsvr.

Linux Guest

To mount a shared folder in a Linux Guest OS such as Ubuntu, type in the following command:
mount -t vboxsf [-o OPTIONS] sharename mountpoint
Replace sharename with the name of the share and mountpoint with the path where you want the share to be mounted (i.e. /mnt/share).
That’s it! You should get a message like “The command completed successfully” like shown below:
virtualbox shared folders
Now when you go to Explorer or My Computer, you’ll see the new drive mounted and ready for access!
mapped network drive
Not too hard eh? Of course, if you didn’t know you had to do all this, it could get quite frustrating! Now when you need to share files or folders in VirtualBox, you’ll be able to do it easily. Enjoy!
Read More
    email this       edit
Published 10:41 AM by with 0 comment

Creating a Virtual Machine using VirtualBox


 Creating a Virtual Machine ( For Guest OS)

Open Application -> System Tools -> VirtualBox ( Command name is “virtualbox” )
Click Machine -> New. This will launch a “Create New Virtual Machine” wizard. Click Next.
Enter the name of the Guest machine as you desire and choose the Operating system and Version that you are planning to install as follows, and click “Next”.
Enter the RAM size that you want to provide to your Guest machine as follows.
Now it will ask you to choose your “Virtual Hard Disk” for installing the guest OS as follows.
Since this is the first time we are installing, click “Create New Hard disk”.
Create “New Virtual Disk” wizard will open. Click Next
Now we need to choose, whether the disk has to be “Dynamically expanding disk” or “Fixed-size storage”.
Remember, for a guest machine, it sees a file residing in the host machine as the “Hard Disk”. Whenever a guest machine does any write to disk, it will be written into the file which resides on the host machine
If we select “Fixed storage” and if we choose the size as 10GB then, in host machine ( by default under .VirtualBox/Guest-Machine/Guest-Machine.vdi ) a file will be created with 10GB of size
If we select “Dynamic storage” then, .VirtualBox/Guest-Machine/Guest-Machine.vdi will initially be a small size file, but it will grow whenever the guest machine writes data to the disk.
Choose “Dynamic storage” and click Next.
Enter the maximum size that you want to allocate for the guest machine.
Click Finish. Now a file named “Guest-Machine.vdi” will be created under “.VirtualBox/Guest-Machine/”
Click “Finish” to complete the creation of Virtual Machine.
Now a new “Virtual Machine” is created and it will be in “power off” state.

3. Installing OS in a Virtual machine

We can install any OS ( personally tested windows and linux ) on a virtual machine. We can install the OS in virtual machine by 2 methods
  • Through OS-DVD
  • Through ISO image of the OS
Here we will cover the installation using an ISO image, although using DVD is very similar to this.
Make sure that the iso file of your distribution is present in the host machine.
Launch “virtualbox”. Select the newly created virtual machine. Click “Settings”.
Now a new window will open which will list out the settings group on left panel and actual setting on the right side as follows.
Select “System”. On the right panel ensure that the boot order is correct ( Similar to setting the boot order in BIOS ).
Use the “Move Up” or “Move Down” button button to change the boot order, and make sure CD/DVD is selected as the “First boot device” and click “Ok”.
The next step is to map the “ISO file” of your distribution to the virtual CD/DVD device.
Under “Settings” go to “Storage”, the following screen will appear.
Click the “CD icon” and choose the “iso file of the OS”, here I used “Debian-Lenny”.
The following screen will appear once you have choosen the ISO file. Click “Ok”.
Now select the virtual machine, and click “Start”. It will start to boot from the CD/DVD which is mapped to the ISO file.
The OS installation is similar to installing an OS in a physical machine.
Once OS is installed successfully, change the “Boot Order” to boot from HDD, and click “Start”.
Now you can start using the virtual machine as like other machines.
Read More
    email this       edit

Monday, May 20, 2013

Published 2:17 AM by with 0 comment

Unable to fetch all items of an order in Magento?

I used this in my module. it may help you.

Load Magneto Order and Product Collection

$resource_model = Mage::getResourceModel('sales/order_collection');
$product_model = Mage::getModel('catalog/product');

Loop through order collection

$records = 0;
    $productData = array();
    $orderProductArr = array();

    foreach($resource_model as $all_orders)
    { 
        if($all_orders['status']!="canceled" && $all_orders['status']!="fraud")
        {  
            $i = 0;
            $items = $all_orders->getAllVisibleItems();

            foreach($items as $item)
            {
                $_product = $product_model->load($item->getProductId()); // getting product details here to get description

                $taxClassId = $_product->getData("tax_class_id");
                $taxClass = $_product->getData("tax_class_name");

                $taxRate = $order['tax_amount'];

                $orderProductArr[$i]['web_id'] = $item->getProductId();
                $orderProductArr[$i]['quantity'] = $item->getQtyToInvoice();
                $orderProductArr[$i]['price'] = $item->getPrice();
                $orderProductArr[$i]['description'] = $_product->getDescription();
                $orderProductArr[$i]['currency'] = $order['order_currency_code'];
                $orderProductArr[$i]['tax_id'] = $taxClassId;
                $orderProductArr[$i]['tax_amt'] = $taxRate;
                $orderProductArr[$i]['total_amt'] = ($item->getPrice()*$item->getQtyToInvoice())+($taxRate);

                $productData[$i]['title'] = $item->getName();
                $productData[$i]['web_product_id'] = $item->getProductId();
                $productData[$i]['price'] = $item->getPrice();
                $productData[$i]['product_sku'] = $item->getSku();
                $productData[$i]['tax_class'] = $taxClassId;
                $productData[$i]['description'] = $_product->getDescription();

                $tax_arr[$i]['tax_id'] = $taxClassId;
                $tax_arr[$i]['tax_class'] = $taxClassId;
                $tax_arr[$i]['tax_amt'] = $taxRate;

                $i++;
                unset($items);
            }   
            $data[$records]['order_data']['product_details'] = $orderProductArr;
            $data[$records]['order_data']['order_product_details'] = $productData;
            $data[$records]['order_data']['tax_arr'] = $tax_arr;
            unset($orderProductArr);
            unset($productData);
            unset($tax_arr);
            $records++;
        }   
    }
Read More
    email this       edit

Tuesday, May 14, 2013

Published 9:21 PM by with 0 comment

I changed the {{base url}} in the config and I can not revert it back



I have faced a problem changing {{base url}} through the magento admin portal and I can’t change it back. I can’t connect to admin area either. 

I found a solution and it can be change in DB. 





UPDATE core_config_data
SET value = '
correct URL here'
WHERE config_id = 7




Read More
    email this       edit

Monday, May 13, 2013

Published 9:47 PM by with 0 comment

Magento: The requested URL /Index/index.php was not found on this server.










Magento: The requested URL /Index/index.php was not found on this server.


Solution is modifying the .htaccess file.
------
Order deny,allow
Deny from all

RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|php)$ index.php
php_flag magic_quotes_gpc off
php_flag register_globals off
Read More
    email this       edit

Wednesday, May 8, 2013

Published 9:50 PM by with 0 comment

Template Method Pattern



Template Method Pattern

Definition
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

abstract class AbstractClass
    {
        public abstract void PrimitiveOperation1();
        public abstract void PrimitiveOperation2();

        public void TemplateMethod()
        {
            PrimitiveOperation1();
            PrimitiveOperation2();
            Console.WriteLine("Call Template Method");
        }
    }

    //Concrete Class A
    class ConcreteClassA : AbstractClass
    {
        public override void PrimitiveOperation1()
        {
            Console.WriteLine("concreate A primi 1");
        }

        public override void PrimitiveOperation2()
        {
            Console.WriteLine("concreate A primi 2");
        }
    }

    //Concrete Class B
    class ConcreteClassB : AbstractClass
    {
        public override void PrimitiveOperation1()
        {
            Console.WriteLine("concreate B primi 1");
        }

        public override void PrimitiveOperation2()
        {
            Console.WriteLine("concreate B primi 2");
        }
    }

//calling…
            //Template Method
            AbstractClass a = new ConcreteClassA();
            a.TemplateMethod();

            AbstractClass b = new ConcreteClassB();
            b.TemplateMethod();

Read More
    email this       edit