Just another WordPress.com weblog

Posts tagged ‘Magento’

How to change ‘product ‘ directory name from media path in magento 1.4*

Hello All,

I found the way to rename product image folder from ‘product’ to ‘products’ or any name you wants.

1) First of all you have to rename folder name to the physical path of your project (i.e ‘project/media/catalog/product’ to ‘project/media/catalog/products’)

2) You need to change in 5 files under PATH = project/app/Mage/Catalog/Model:
You need to change from all media path ‘product’ to ‘products’ to below listed files.


file_exists(Mage::getBaseDir('media').DS.'catalog'.DS.'product'.DS.$size.DS.$image)

TO

file_exists(Mage::getBaseDir('media').DS.'catalog'.DS.'products'.DS.$size.DS.$image)

REPLACE below code

'catalog/product/'

TO
'catalog/products/'

File1: PATH / Product/Attribute/Frontend/Image.php

File2: PATH / Product/Attribute/Media/Image.php

File3: PATH / Product/Image.php

File4: PATH / Product/Media/Config.php

File5: PATH / Entity/Product/Attribute/Frontend/Image.php

I hope you will find this post helpful.. If you have any question add your comment.

Thanks,
Bijal Bhavsar 🙂

Magento :: Catalog Price Rules are not working.

Hello,

If you have problem with Catalog Price Rules…
When we apply catalog price rules then rules are reflect to product listing and product detail
but when we add product in cart its taking original product price …

I think its magento core problem.

Any-way , lets solve it ….

open Mage/Catalogrule/Model/Observer.php
around 101st line

you have this segment …

if ($observer->hasCustomerGroupId()) {
$gId = $observer->getEvent()->getCustomerGroupId();
} elseif ($product->hasCustomerGroupId()) {
$gId = $product->hasCustomerGroupId();
} else {
$gId = Mage::getSingleton('customer/session')->getCustomerGroupId();
}

Now in 4th line we have code like
$gId = $product->hasCustomerGroupId();
… simply change this to
$gId = $product->getCustomerGroupId();

Thanks…

-Vishal Surani

Set title for Block :: Magento

$this->getLayout()->getBlock(‘head’)->setTitle(‘Your Title’);

—- Vishal Surani ……

Join any table with collection in admin

Hello,

We can easily display different table values as a column in grid in adminend of magento.

For eg:
I have to add one field for displaying ‘rule_id’, ‘status’, ‘send_date’ field as a columns in customer grid.
//Customer grid collection
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id');
$this->setCollection($collection);

/***From here we can left join with ‘giftcard’ table, join criteria is ‘gf.customer_id = e.entity_id’ and in array we can specifie the ‘rule_id’ as index in column and its values are from table giftcard. i.e ‘gf.rule_id’ and i have grouped with customer primary key i.e ‘e.entity_id’ ***/

$collection->getSelect()->joinLeft(array('gf'=>'giftcard'),
'gf.customer_id = e.entity_id',
array(
'rule_id'=> 'gf.rule_id',
'status' => 'IF(gf.status IS NULL,"Unsend","Send")',
'send_date' => 'gf.created_time'
))
->group('e.entity_id');

//To add column
Add below

$this->addColumn('created_time', array(
'header' => Mage::helper('giftcard')->__('Coupon Send Date'),
'align' => 'left',
'index' => 'send_date',
'type' => 'datetime',
'gmtoffset' => true
));

I hope this will help you..
If this post is help you than please do reply,..

Thanks,
Bijal Bhavsar 🙂

Magento Table Structure

Magento Table Structure

When you first look at Magento database, it can be overwhelming because of its complexity. The Magento database is heavily dependent on EAV (Entity Attribute Value) model. While the EAV model makes it easier to expand the database, i.e. adding your own entities or attributes specific for your store, SQL codes can be very difficult to write.

Before you customize Magento database, make sure you read through EAV model and you understand Magento table structure thoroughly.

EAV Core Tables
All EAV tables are prefixed with “eav_”.

* eav_entity_type: table of all entitiesIt contains information about entity codes, entity models, entity tables and more.
Example entities: customer, order, catalog_category, catalog_product, invoice, shipment, and so on.
Each entity has a corresponding data table prefixed with “_entity”, i.e. customer_entity, sales_order_entity, catalog_category_entity, and so on.
* eav_attribute: table of all attributes
It defines all necessary attributes for each entity. For example, a customer has first name, last name, email address and so on. Customer is defined as an entity in the eav_entity_type table and customer’s attributes such as first name, last name or email are defined in the eav_attribute table. Hundreds of attributes are defined by default with Magento installation.
* eav_attribute_option, eav_attribute_option_value
These two tables are used to define options for each attribute. For example, the manufacturer attribute can have “Toshiba”, “Dell”, or “HP” for its options. These option values are stored in the eav_attribute_option_value table and the relationship of each option and the attribute is stored in the eav_attribute_option table. An option can also have multiple option values when it’s used for multiple stores.
* eav_attribute_set
This table is used to define different attribute sets for an entity. For example, a cell phone has different options from a camera. Both cell phone and camera are products (entities) that have different option sets (attribute sets).

Table Sets (Table collections)
In Magento database, an entity can have several tables that share the same prefix. For example, the product entity has the catalog_product_entity table for its main data and several other tables prefixed with “catalog_product_” such as catalog_product_entity_int, catalog_product_entity_media_gallery, catalog_product_entity_text and so on.

To store the data more efficiently, product details are stored separately depending on their data types. When the value of the data is an integer type, it’s saved in the catalog_product_entity_int table, and when its type is an image, it’s saved in the catalog_product_entity_media_gallery table. The whole point is not saving big image data with small integer data in the same table.

Tables to Define Relationships
The catalog_category_product table, catalog_product_website or downloadable_link_purchased are examples of the tables that show relationships. The catalog_category_product table show which category includes which products and the downloadable_link_purchased table shows which order has which downloadable links.

Thanks,
– Bijal Bhavsar 🙂