eav_attribute Table in Magento

Share
Posted on May 19th, 2013 | Posted by admin

It is well known that Magento implements an entity-attribute-value data model. A key table in the implementation is the ‘eav_attribute’ table, who’s exposition is the subject of this blog post.

Magento uses five ‘types’ to store attribute data: datetime, decimal, int, text, and varchar(these are strongly motivated by the corresponding mySQL datatypes). So when a new eav entity type is created in Magento there are actually six tables created; one to store the entity and one for each of these ‘types’ of attribute data. The fact that this type of entity has a certain attribute is recorded in the ‘eav_attribute’ table which has the following schema:

CREATE TABLE 'eav_attribute' (
'attribute_id' smallint(5),
'entity_type_id' smallint(5),
'attribute_code' varchar(255),
'attribute_model' varchar(255),
'backend_model' varchar(255),
'backend_type' varchar(8),

Magento – How to find if you are on homepage – getIsHomePage

Share
Posted on May 18th, 2013 | Posted by admin

Magento – How to find if you are on homepage – getIsHomePage
I needed to exclude hot products and recently viewed products block from homepage, so I needed to find if the current page is homepage. The first block of code worked on header.phtml template but not in main page template, so I ended up using 2nd option.

If you need to check this on header.phtml template then use this code:

1 <?php
2 if($this->getIsHomePage()) {
3 echo 'You are in Homepage!';
4 } else {
5 echo 'You are NOT in Homepage!';
6 }
7 ?>

If you want to check from other pages than do this:

Adding magento attribute with custom input renderer

Share
Posted on May 17th, 2013 | Posted by admin

This is example which will explain you, how to add new attribute with custom input render. You will be able to modify existing functionality, add javascript, some other option or change default input renderer by your wishes.

You probably will ask yourself, what is magento input renderer and I will explain. This is Magento php class which is in charge for “rendering” html form elements. In magento there are different classes for rendering, you can find them in next folder:/lib/Varien/Data/Form/Element. In this folder you will notice next classes for rendering: price, date, image and so on.
Let’s go with our example.
First of all, you should create magento setup file which will add new product attribute with custom frontend input render, example is below:

Magento: How To Add The Target To Grid Url Actions

Share
Posted on May 16th, 2013 | Posted by admin

Magento, on administration side, has the concept of “grid”, a table with ability to filter, order, page a collection of data. For example the product list is a grid.

A grid is usually initialized on block implementation that “prepares columns” and when I needed to change the columns of a grid I overloaded the block implementation with a class of mine extending the original one.

The latest modification I made on Magento was on product list tab present on category detail. I found incredibly stupid in Magento the absence of a category filter on product management panel and an edit action on product list on category detail.

Since the simpler thing was to add an action to that table I overrided the

Adminhtml/Block/Catalog/Category/Tab/Product.php

Magento – Database Queries

Share
Posted on May 11th, 2013 | Posted by admin

Magento is a complete and awesome MVC application. It’s fully moduler and easy to extend its features and functionality. All the CRUD operations are performed using the modules, model classes. But many a time it requires a developer to execute the db query in traditional form.

Here is the list of methods and queries.

In magento to Read or Write any query we need database connection.

<?php
//database read adapter
$read = Mage::getSingleton('core/resource')->getConnection('core_read')
//database write adapter
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
?>

These connections return special instances of the Mage_Core_Model_Resource class, that contains functions used to execute raw Database Queries.

Page 1 of 8712345»102030...Last »