20 Magento Interview Questions

. Monday, March 14, 2016
0 comments

Q 1. What is Magento?
Ans. Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magentos intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give merchants the power to create sites that are tailored to their unique business needs. Designed to be completely scalable and backed by Variens support network, Magento offers companies the ultimate eCommerce solution.
Q 2. What is the difference between Mage::getSingletone() andMage::getModel() in Magento
Ans. Mage::getSingletone() always finds for an existing object if not then create that a newobject but Mage::getModel() always creates a new object.
Q 3. Why Magento use EAV database model ?
Ans. In EAV database model, data are stored in different smaller tables rather than storing in asingle table.product name is stored in catalog_product_entity_varchar tableproduct id is stored in catalog_product_entity_int tableproduct price is stored in catalog_product_entity_decimal tableMagento Use EAV database model for easy upgrade and development as this model givesmore flexibility to play with data and attributes.
Q 4. How to upgrade to the latest version using Magento Connect?
Ans. Upgrading Magento to the latest version is a fairly simple task. Copy and Paste this key magento-core/Mage_All_Latest VIA Magento Connect where it states Paste extension key to install:. This will upgrade Magento to the newest version.
Q 5. Explain about the Modules of Magento?
Ans. Magento supports installation of modules through a web-based interface accessible through the administration area of a Magento installation. Modules are hosted on the Magento eCommerce website as a PEAR server. Any community member can upload a module through the website and is made available once confirmed by a member of the Magento team. Modules are installed by entering a module key, available on the module page, into the web based interface.
There are three categories of modules hosted on Magento Connect:
  • Core Modules
  • Community Modules
  • Commercial Modules
Core and Community modules can be installed via the administration area. Commercial module pages provide price information and a link to an external website.
Q 6. What technology used by Magento?
Ans. Magento uses PHP as a web server scripting language and the MySQL Database. The data model is based on the Entity-attribute-value model that stores data objects in tree structures, thus allowing a change to a data structure without changing the database definition.
Q 7. What is MVC structure in Magento?
Ans. The Model-View-Controller (MVC) architecture traces its
origins back to the Smalltalk Programming language and Xerox
Parc. Since then, there have been many systems that describe
their architecture as MVC. Each system is slightly
different, but all have the goal of separating data access,
business logic, and user-interface code from one another.
Q 8. What is benefit of namespace (package) in magento?
Ans. We can have more than one module with same name but they should be placed in different namespaces. All magento core modules are contained in mage namespace.
core/Mage/Catalog
and all custom modules are placed in
local/CustomModule
Q 9. How to include CMS block in template file(.phtml)?
Ans. Access block’s content from .phtml template file by :
echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘static_block_id’)->toHTML();
Q 10. How to add an external javascript/css file to Magento?
Ans.
css/yourstyle.css
or
skin_jsjs/ yourfile.js
skin_csscss/yourstyle. css
Q 11. What are handles in magento (layout)?
Ans. Handles are basically used for controlling the structure of the page like which block will be displayed and where. First level child elements of the node are called layout handles. Every page request can have several unique Handles. The handle is called for every page. handle for products belongs to virtual product type, PRODUCT_TYPE_simple is called for product details page of simple product type and PRODUCT_TYPE_virtual is called for the virtual product detail page and customer_logged_in handle is called only if customer is logged in. The muster_index_index handle is created by combining the frontName (muster), Action Controller (index), and Action Controller Action Method (index) into a single string and this handle will be called only when /zag/index/index url is accessed.
Q 12. What is in magento?
Ans. The routers tag allow us to decide frontname for each module. The tag is defined in config.xml file of module. For Namespace_MyModule frontname is moduleurl so the url will be like :
websiteurl.com/moduleurl/controllername/actionname
standard
Namespace_MyModule
moduleurl
Q 13. Which factors affect performance of magento?
Ans.
1. EAV structure of magento database, even for retrieving single entity the query becomes very complex .
2. Magento’s template system involves a lot of recursive rendering
3. Huge XML trees built up for layout configuration, application configuration settings
Q 14. How to improve magento performance?
Ans.
Enabled magento caching
MySQL Query caching
Enable Gzip Compression
Disable any unused modules
Disable the Magento log
Optimise your images
Combine external CSS/JS into one file
Enable Apache KeepAlives: Make sure your Apache configuration has KeepAlives enabled.
Q 15. How to get the Total Price of items currently in the Cart?
helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTotal()); ?>
Q 16. How to set different themes for logged in users?
if(Mage::getSingleton(‘customer/session’)->isLoggedIn()):
Mage::getDesign()->setPackageName(‘package_name’)->setTheme(‘themename’);
endif;
Q 17. How to create magento custom module?
Ans. Steps to create custom magento module:
Namespace : Zag
Module Name : Mymodule
1. Create directory Mymodule in app/code/local/Zag
2. Create Block, controllers, etc, Module directories. Create controller, block and module file as required.
3. Create module configuration file (app/code/local/Zag/Mymodule/etc/config.xml).
4. Create xml file (app/etc/modules/Zag_ Mymodule.xml)to enable/disable module and tell magento system from which code pool that module will be taken.
Q 18. How to set different themes for each store?
Ans. Go to : System>Designs
Then, add new design change or edit existing. You can select Store and Custom Design.
Q 19. How to make product’s custom attribute searchable in adavance search?
Ans. Go to : Catalog > Attribues > Manage Attribues
Edit the attribute and select “Yes” for Use in Advanced Search.
Q 20. How to fetch 5 bestsellers products programmatically?
Ans.
Mage::getResourceModel(‘reports/product_collection’)
->addOrderedQty()
->addAttributeToSelect(‘*’)
->setPage(1, 5)
->load();

20 PHP Questions to Ask During an Interview

.
0 comments

What is Object Oriented Programming?

likelihood high
This is usually a pretty open ended question. You should understand classes (objects are instantiated classes), abstract classes, interfaces, methods, properties,inheritance, multiple inheritance as well as why OOP is helpful as compared to procedural programming.
likelihood high
Interfaces do not contain business logic, only method signatures that define a template that any classes implementing the interface must contain. Lets take an auto mobile for example. If we were to create and interface for a car we would want to define a few methods like drive, stop, turn left , turn right. This mean that any vehicle that is a car (aka implements the interface car) must have methods for these things, If they do not PHP will throw an error. So if your car is an BMW , Honda or Ford it must be able to stop. How it stops is up to each car (or PHP class) but it must be able to stop. Technically we can decide not to use an interface for cars, but then some types of cars are not forced to have a "stop" method.

What is MVC?
likelihood high
Most programmers know this, but interviewers will likely look for a deep understanding of MVC, and some explanation or examples on how/why/ when you used it.

MVC- Model, View, Controller - is simply a way of organizing your code into 3 separate layers each with there own job.

Model - Usually contains data access code and all of you business logic code.
View - Contains markup/design code, generally html,xml, json.
Controller - Usually contains very little code, just whatever is needed to call the Model code and render the View code.

Explain how a PHP session works?

likelihood high
A PHP session cookie is set in the clients browser, on every request the client sends that cookie to the server. PHP then uses that cookie to select the corresponding session information. By default PHP session_start() will store session data in files, you can also store sessions in a database.

What are some of the big changes PHP has gone through in the past few years?

likelihood high
There are a number, but the big ones people are looking for are:
a. PHP 5.0 realised the object model (AKA OOP).
b. 5.1 added PDO - for accessing databases.
c. 5.3 - added namespace support and late static bindings.

What is the difference between $_GET and $_POST

likelihood high
This is a great question because an interviewer can tell how deeply you understand HTTP and the request/response. If you don't have good understanding of HTTP protocol, google around and get a grasp on it.
Good answer 
Explain the HTTP protocol and how every request contains a method, generally(GET,POST,PUT,DELETE) and what each method signifies.
Bad answer 
$_GET stores variables passed in url as query strings. $_POST stores variables past from using method = $_POST 

In a PHP class what are the three visibility keywords of a property or method?

likelihood medium
public, private and protected. The default is public.
Public -> Any class may instantiate the class and call the method or property.
Protected -> Only the class itself or inherited (children) classes may call a method or property.
Private -> Only the class itself may call a method or property.

What is Polymorphism?

likelihood medium
Don't get scared by the big word. It's simply the idea that one object can can take on many forms. So in PHP OOP one class "cars" may have two classes that extend it, for example a "Honda" class and a "BMW" class.

How do you load classes in PHP?

likelihood medium
They are trying to gauge your understanding of how class auto loading works. Review the "autoload" and "spl_autoload_register" function (note:you should use the later). The autoload function basically triggers a function when a class is instantiated, you can put whatever logic you like in it but generally you want to include the class file based on some sort of naming convention.

What is the value of "$day" in the below code?

likelihood medium
$wed= 1;    
$day = ($wed==1) ? 'today' : 'tommorrow';
// $day is now set to 'today'
Companies often ask about the ternary operator (?). which is simply a shorthand for if else statements.

What is the Scope Resolution Operator?

likelihood medium
"::" double colons is the scope operator it is used to call methods of a class that has not been instantiated. You should also understand static methods and how they differ from regular methods.

What are some PHP Design patterns you have worked with?

likelihood medium
Design patterns are simply commonly used techniques within your code, they often are implemented in different ways so they can be a bit tricky to grasp without writing them yourself. If you are unfamiliar with them I would start by learning the Singleton Pattern and the Strategy Pattern.

What is the difference between single quotes and double quotes?

likelihood medium
Great answer at below link.

What does ob_start do?

likelihood medium
Makes it so PHP does not output anything. Companies ask this because many large frameworks wrap a bunch of code in ob_start() and ob_get_clean(). So understanding how that function works is pretty important.

What does & mean in &$var' ?

likelihood medium
'&' indicates a reference

What is the meaning of a final class and a final method?

likelihood medium
Final keywords indicates that the class or method cannot be extended.

Does PHP support multiple inheritance?

likelihood medium
No. You should understand what multiple inheritance is.

What are some magic methods in PHP, how might you use them?

likelihood medium
Magic methods are basically triggers that occur when particular events happen in your coding. __GET, __SET are magic methods that are called (behind the seen) when you get or set a class property.

Are objects in PHP 5 passed by value or reference?

likelihood medium
This is basically a trick questions. To understand how they are passed you need to understand how objects are instantiated. Study the below link:

What is the difference between $var and $$var?

likelihood medium
$$var sets the value of $var as a variable.
$day='monday';
            $$day='first day of week';
            echo $monday; //outputs 'first day of week'
            

Compile and Run gFortran Program using Textpad

.
0 comments

Programs needed:

  1. MinGW
  2. Textpad

Adding the Compiler

Open Textpad, Configure > Preference > Tools

Click Add > Program > Locate your MinGW installation directory > open gfortran (mine is at C:\MinGW\bin\gfortran.exe)

Parameters: -o $BaseName $File
Initial folder: $FileDir (leave as is)

Regular Expression: ^\(\(\(.[^:]\)\|\([A-Za-z]:\)\)[^:]+\):\­([0-9]+\):

Registers:
File: 1
Line: 4

Click Apply

Adding the Command to Run

In Tools, click Add > DOS Command > type cmd.exe

Parameters: $BaseName
Initial folder: $FileDir (leave as is)

Uncheck "Capture output"

Click Apply / OK

You can now compile and run gFortran programs by going to
Tools > External Tools

Add an Environment Variable

Next, go to Control Panel > System > Advance system settings > Environment Variables
Under System variables, click New

Variable name: GFORTRAN_UNBUFFERED_ALL
Variable value: Y

Reseller Registration Flow Fixing Day

. Friday, March 11, 2016
0 comments

Lotus Breath OnePage checkout extension conflicts with Meabed's Magento Buy X get cheapest Y free extension.
Somehow, the discount is shown at the cart page, but the grand total remains the same.

---

Note to self:
Deleted currencies from database:
BND
GBP
AUD
CNY
CAD

Discovered the "Reseller Program" information page is editable at /ocadmin/extension/information/

WooCommerce or Magento

. Thursday, March 10, 2016
0 comments

This is a question I have been asking myself for a very long time, and even now more so than ever.

What platform should I build my e-Commerce site in?

In this post today, I will be researching the two e-Commerce platforms and detail my findings here, and there will be a lot of copy pasting from multiple sources.

WOOCOMMERCE - WORDPRESS

It is a popular plugin created for WordPress.

Out of the box, Woo Commerce isn’t as powerful as Magento but there are plenty of really good plugins available to meet additional requirements, including:

  • Very easy to install and configure
  • Highly customisable
  • Backend management and reporting is very easy and simple to operate, without the knowledge of any coding
  • Products and categories are easy to add and manage
  • It’s one of the most secured eCommerce solutions (and has been approved by Sucuri Security)
  • Search engine friendly

Some of the disadvantages and considerations include:

  • Frequently large updates may cause a significantly lower version to break your site
  • Some extensions come from third parties, and don’t have great support
  • Some extensions are also little pricey

WooCommerce is a perfect system for small to medium-sized online retailers, and of course for any developer or business that is already familiar with the WordPress interface.

If you’re starting out, then WooCommerce is definitely the place to start, as it’s very simple to use, however it does lack functionalities that may be beneficial for an enterprise eCommerce solution.

MAGENTO

Magento is the most popular eCommerce solution for most online shopping stores – mainly because the platform offers a lot of flexibility and customization.  Like WordPress, Magento is open source, which means it allows developers to easily customize the look and functionality as required.

Magento development requires a higher level of coding skills, which means you need some experience with programming in order to setup your website. As a result, development costs can get expensive because of the complexities involved with customization.

There are many themes available to purchase for Magento, but like all websites, we always encourage clients to build a customized design from scratch – to create the ultimate experience for users.

Here are some of the main features and benefits of the Magento platform:

  • Open Source Solution – you can host Magento on your own server, however it’s recommended you try and find a Magento hosting specialist
  • Develop highly-creative and responsive web designs – Magento has great flexibility with all templates and themes
  • A large number of payment gateways and shipping options can be included – including integration with major Australian banks and Australia Post
  • It has a really good product and order management system – there are good bulk uploading features available to help manage catalogs
  • Good marketing and promotional tools – includes related products, coupons, multi-tier pricing and product bundles
  • Search engine friendly – ‘out of the box’ Magento needs a little configuration, however it’s very search engine friendly
  • Manage multiple stores from the same account – this makes multiple websites easier to manage centrally

Larger retailers and international brands choose Magento because it offers a stack of ‘out of the box’ features that can be enhanced with plenty of third-party apps and modules.  It also provides endless possibilities for future growth.

On-page SEO

.
0 comments

What action would you take when your analytics showed a significant drop in visitors?

I've started off today to look into SEO for an e-commerce store which I recently started to be a part of. I started off with improving on-page SEO, which roughly includes the following:

  1. Content
  2. Title, description, and keywords tag
  3. URL
  4. Image ALT
Have you heard of the phrase "content is king" ? Well, it certainly is but successful content marketing is not simply about creating content, but creating content that will benefit readers. You will notice when you start creating good in-depth content you will see a boost in traffic from long-tail searches.

Content that drives traffic are practical, useful and valuable to the reader.
  • is interesting to read
  • is in-depth and well written
  • solves a problem
  • is written with the reader in mind
  • is optimized for high volume keyword
  • is easy to share
Content is the factor that creates a line of communication between you and customers. So effective communication increases customer retention and brand awareness by 90%.

Content that drives traffic makes everyone happy

Do you take meta tags seriously? Although effects of tags on SEO has changed a lot over several years, it is still a good practice to give attention to them.

  1. The titles tag define the title of a web page. They are usually used to display snippets of your web page, especially when people searches on big G. It should be short, clear and descriptive. Ideal length is 50 - 50 characters otherwise it will be clipped by G in search results.
  2. Meta description is another significant tag where many searchers visit a site based on what was written in the tag. It is also used by search engines to tell what topic you are writing about and show it to relevant audiences, so make it descriptive and not more than 160 characters.
Ideally ...
Be hyper-relevant to a specific topic (usually a product or a single object)
  • include subject in the title tag
  • include subject in URL
  • include subject in image alt text
  • specify subject several times throughout text content
Provide unique content
Link back to its category page
Link back to its sub-category page (if applicable)
Link back to its homepage (website logo image link at the top should do it)

In conclusion, the site should be ready before starting to build authority inbound links (backlinks), because the foundation is what matters most when it comes to SEO. Always study Google webmaster tools and analytics, as both will educate us on what our ideal customers truly want from our site.

B2B and B2C marketers are starting to realize the need to implement basic SEO practices.
So here's a reminder for myself and you my readers to commit ourselves to the process, not just to the results we’re after.

me me