Monday, April 21, 2014

System/Default Catalog Attributes

In magento,Product attributes & Attribute sets are important concepts to understand.

In simple words, an attribute represents a characteristic of a product. An attribute give you the facility to add new product properties without having to write a single line code or to add a new column in your database.The data entry fields that is completed when adding a new product to the catalog are attributes. Attributes provide product information and are used as search criteria and to present a selection of options.

Assigning attributes to the products enables your customer and search engines to find them easily.

Attribute also decides what product should be displayed when a customer search for a keyword.

For example, if the product is a shirt then Fabric,Sleeves,Neck,Fit,Style,size and color will be its properties means its attributes.

Another example is, if the product is shape then Sole Material,Heel shape,Heel height,Color,SIZE,Upper Material,Inner Lining,Ankle Height can be its attributes.
Attribute sets:
Now, It is very obvious that I don't want to use shoes attributes for shirt. This is where the attribute sets come in. An attribute set is a combination of various attributes, setting all the fields we will need for a certain type of product. When creating a product, I will select the attributeset it belongs to. By doing so, all the desired fields will be available for particular type.
System Attributes:

First,we will see meaning of system attributes which are required by store to function properly. Later on we will see its properties.
General Attributes
Attribute Code Description Data Type Required
name It is the name of the product which is used by customer to identify the product and it is display on product description page and wherever the product is listed. Text Yes
description It is the description of the product which gives more details of product to the customer. String Yes
short_description It is brief description of the product. The use of this attribute varies by theme. Text Yes
sku SKU stands for Stock-Keeping Unit which is unique product identification number that is used to track inventory items. Alphanumeric (AZ, 0-9) Yes
news_from_date From this date,product will be considered as new and will be featured in new product listings. Date/Time No
news_to_date Till this date,product will be considered as new and will be featured in new product listings. Date/Time No
status It decides whether the product is available for sale or not.if it is not available then it will not listed in catalog.

Its value can be:
enabled (1)
disabled (2)
Binary (1, 2) Yes
url_key It is part of the URL that identifies the product. Text No
visibility It specifies whether this product is visible from the catalog, search, both, or neither.

It has following values:
0 (Not Visible Individually) 
1 (Catalog) 
2 (Search) 
3 (Catalog, Search)
Text No
gift_message_available It specifies if a message can be included with this product purchase.

Its values  can be:
Yes
No
Use Config
Text No
is_imported It specifies if the product can be included in product RSS feeds.

It's values can be:
0 (Yes)
1 (No)
Yes/No (0,1) No
Image Attribute
image It is URL address of the base image, or the main image of the product that is displayed when customer clicks the product image. URL No
thumbnail It is URL address of the thumbnail image used in product listings. URL No
small_image It is URL address of the small image used in product listings. URL No
Design Attributes
custom_design It is used to specify a custom theme for the product detail page. Yes/No (0,1) No
custom_design_from It is date to begin using the custom theme for the product detail page. Date/Time No
custom_design_to It is date to stop using the custom theme for the product detail page. Date/Time No
custom_layout_update Using this you can apply custom XML to modify the product detail page layout. XML No
page_layout It decides the column layout of the product detail page. following are the options included:
No layout updates
Empty
1 column 
2 columns with left bar
2 columns with right bar 
3 columns
Text No
options_container It decides the type of container used to display product options. Following are the options included:
Product Info Column
Block After Info Column
Text No
Gift Card Attributes
allow_open_amount It decides whether the dollar value of the gift card can be specified by the customer. Text Yes
open_amount_main It is the minimum amount if the gift card allows open amounts. Numeric No
open_amount_max It is maximum gift card amount if the gift card allows open amounts. Numeric No


Pre loaded Attributes
color It specify the color of the product. Text No
cost It is the cost of the product which generally used for internal purposes only. Numeric No
manufacturer It is the  name of the manufacturer of the product Text No


All these are system attributes. Now, We will see what are the attribute set and attribute Group in next post and how to create them.

Monday, March 31, 2014

Catalog default configurations for frontend

Before going to create any product for your store, you must go through magento's following settings for catalog:

1) Catalog defaults
2) Product categories
3) Product attributes
4) Attribute sets
5) Product catalog

In this post,we will see Catalog defaults settings which are the settings in Magento that affect the default behavior of your products.

Go to Admin menu -> System -> Configuration.


In the top-left corner you can see that it is possible to select a different Website or

Store View, if you have any. This is called the Scope Selector. 

If you select Default Config option  then it means that the settings being done will also be saved for any Website or Store View that you may add in the future.


Right now I have single online store, so it is alright to keep this setting as Default Config, but

when you have multiple stores, you need to be more careful for this settings.

The following image shows all needed default settings for catalog.
The following image shows setting for any product on front side means how it will look at front side.

Now, we will see what this settings mean:

1) List Mode: It defines how the products should be displayed .


Grid Only - The products will display in a grid structure and the customers will not have the option to change this. 

List Only - The products will display in a list structure and the customers will not have the option to change this. 
Grid (Default)/List - The products will display in a grid structure by default but the customers will be able to switch to list. 
List (Default)/Grid - The products will display in a list structure by default but the customers will be able to switch to grid


2)
Above settings   decide how many products will be shown in list or gird view on front side.

Products per Page on Grid Allowed Values: It sets the number of products displayed per in Grid View. To provide a selection of options to customer, enter multiple values separated by commas.


Products per Page on Grid Default Value: It sets the number of products displayed per page by default, in Grid View.


Products per Page on List Allowed Values: It sets the number of products displayed per page by default, in List View. To provide a selection of options to customer, enter multiple values separated by commas.


Products per Page on List Default Value: It sets the number of products displayed per page in a List default View.

Grid view gives the possibility to show more products in a smaller area,whereas the List view delivers more details of a product.

Note:
Using setting 1 and 2 , Magento lets you decide how you want to display your items and how many should be visible per page by default.

3) Allow All Products per Page: If it is set to “Yes,” then it will includes the “ALL” option in the Show per Page control. 






4) Product Listing Sort byIt decided the sort order of the search results list. The selection of options is determined by the display settings of the category and the available attributes. The default options are :
  • Best Value
  • Name
  • Price



5) Use Flat Catalog Category: The structure of Magento caused category information

to be stored in various tables. By changing this setting to Yes, Magento will create
one flat catalog table for your categories, which improves performance. It is
recommended to set it to Yes.

Magento follows EAV module structure where it saves data in various tables. So when the product page is requested, a big join query is made to retrieve all the information regarding the product which causing the system slow.

Enabling Use Flat Catalog Category 'YES', will take all the data regarding catalog category spread out in different tables, flattens it in to one single table and ultimately decrease response time and increase the over all performance of magento store.


6)

Wednesday, August 14, 2013

Change default home to any page in magento or create a new landing page for magento

First go to CMS -> pages -> Add New page.

After saving details of new page,
go to system -> configuration -> Web -> Default pages
Save this Configurations as show in screen-shots.And go to your homepage url

e.g. http://localhost/magento



PHP Extensions "0" must be loaded.

It appears that one of the configuration XML files, namely magento/app/code/core/Mage/Install/etc/config.xml isn't parsed correctly by PHP 5.4

To fix this error, open above file  and replace
         <extensions>
            <pdo_mysql/>
        </extensions>
with
        <extensions>
            <pdo_mysql>1</pdo_mysql>
        </extensions>

Now, you will be able to proceed the installation.

Session management in Magento

To set the value of Magento session variable:

$theValue = 'Bhavana';
Mage::getSingleton('core/session')->setMySessionvariable($theValue);

You can retrieve the value of session variable as following:
Mage::getSingleton('core/session')->getMySessionvariable();

To unset the value of session variable:
Mage::getSingleton('core/session')->unsMySessionvariable();

Tuesday, April 24, 2012

can not login into magento admin Panel

I have installed magento 1.6.2.After installing fresh magento,I could not login in to admin panel of magento.It is even not throwing any exception message.Although Password and username are correct,I am not able to login in magento admin panel.After providing correct username and password,it only generates a new URL ,something like:


http://localhost/magento/index.php/admin/index/index/key/f1585bj4de664ab83db50940e058a/


Solution:
\magento\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php


change line no 84 to 87


from:
 // session cookie params
        $cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath(),
            'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            'httponly' => $cookie->getHttponly()
        );
to:
 // session cookie params
        $cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath()
            // 'domain'   => $cookie->getConfigDomain(),
            // 'secure'   => $cookie->isSecure(),
            // 'httponly' => $cookie->getHttponly()
        );
Reason:
Magento do not store cookies.We run it on localhost which is actually not a true real domain But to store cookies we generally need a domain.Becasue of that we can not login  and even not getting any exception or error message.

Friday, April 20, 2012

Add Address fields in customer registration

To show all address fields in create account page for customer,you have to comment following lines in:


\magento\app\design\frontend\base\default\template\customer\form\register.phtml


replace line no:77
from:
  <?php if($this->getShowAddressFields()): ?>
to
  <?php / /if($this->getShowAddressFields()): ?>


replace line no:149
from:
  <?php endif; ?>
to
  <?php // endif; ?>


As well,to get the list of states,you need to comment same line in java script too.

\magento\app\design\frontend\base\default\template\customer\form\register.phtml


replace line no:178
from:
  <?php if($this->getShowAddressFields()): ?>
to
  <?php / /if($this->getShowAddressFields()): ?>

replace line no:180
from:
  <?php endif; ?>
to
  <?php // endif; ?>

Now,You can see address fields in,create account form.


If you are still not able to see the address fields in create account form,means you have activate persistent cart.In that case you need to comment the same lines in
\magento\app\design\frontend\base\default\template\persistent\customer\form\register.phtml

Template/Block Hints in Admin Panel

Magento’s admin panel uses the exact same design pattern as the front end ( blocks/layouts/templates).If you have done any modification at admin side and you need to turn on template/block hints for the admin panel,you need to do following steps as there is not built in support from magento.

step 1:
Go to Magento Database

step 2: Turn on

INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);

Now,you can check at admin panel for template/block hints.

step 3: Turn off

To turn off hints,delete above record from the table or if you are thinking to turn on it again then simply update its value field from 1 to 0.

Logic behind this is:
 /app/code/core/Mage/Core/Block/Template.php

public function getShowTemplateHints()
{
    if (is_null(self::$_showTemplateHints)) {
        self::$_showTemplateHints = Mage::getStoreConfig('dev/debug/template_hints')
            && Mage::helper('core')->isDevAllowed();
        self::$_showTemplateHintsBlocks = Mage::getStoreConfig('dev/debug/template_hints_blocks')
            && Mage::helper('core')->isDevAllowed();
    }
    return self::$_showTemplateHints;
}


The “Mage::getStoreConfig” method checks for config values that are set in the current scope (ie, default, website, store, store view). In the admin panel, only values set in the “Default Scope” are loaded.

Magento only allows you to turn on hints when you’re in the configuration scope of a Website or Store View. This means that when the code above tries to load the configuration, it returns “null” because that config value isn’t set in the “Default Config” scope. Running the MySQL query above adds the hint config values to the “Default Config” scope. Here is a screenshot showing the settings for turning on the hints – notice that the “Main Website” configuration scope is selected.




Get child categories in Magento

to get all the child categories of the required category id



<?php    

    $category_model = Mage::getModel('catalog/category'); //get category model

    $_category = $category_model->load($categoryid); //$categoryid for which the child categories to be found        

   $all_child_categories = $category_model->getResource()->getAllChildren($_category); //array consisting of all child categories id

?>

Call Custom Model method/function

For example,I have created a custom module UserProfile .
i.e
magento\app\code\local\CustomerProfile\Userprofile

and my model in Userprofile is
magento\app\code\local\CustomerProfile\Userprofile\Model\Customersettings.php

Customersettings.php is as following:


class CustomerProfile_Userprofile_Model_Customersettings extends Mage_Core_Model_Abstract
{

protected function _construct()
{
$this->_init("userprofile/customersettings");
}

function getmessage()
       {
              echo "Hello From Custom model method:";
       }
}


I can call the method of custom model anywhere as following:

Mage::getModel('modulename/modelname')->modelmethod();

i.e.
Mage::getModel('userprofile/customersettings')->getmessage();

Thursday, April 19, 2012

Birth date issue while creating new customer account

when i try to create a new customer account and i enter birth date as 09/30/1987(mm/dd/yyyy) format.it shows me an error message as:"Please enter a valid full date".
To Resolve this error:



I changed line 437 in /js/varien/js.js


from: 
var error = false, day = parseInt(this.day.value) || 0, month = parseInt(this.month.value) || 0, year = parseInt(this.year.value) || 0;


to: 
var error = false, day = parseInt(this.day.value, 10) || 0, month = parseInt(this.month.value, 10) || 0, year = parseInt(this.year.value, 10) || 0;


Now,Customer account created successfully.

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method... magento 2

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining met...