Please click on below links for detail...
Note: Thanks to Kalpesh for posting such a useful data.
Love to share my practical experience with you! I started this blog for self reference but I am happy to see that this blog helping other as well to groom! Please feel free to provide suggestions.
TRUNCATE TABLE `catalog_category_entity`;TRUNCATE TABLE `catalog_category_entity_datetime`;TRUNCATE TABLE `catalog_category_entity_decimal`;TRUNCATE TABLE `catalog_category_entity_int`;TRUNCATE TABLE `catalog_category_entity_text`;TRUNCATE TABLE `catalog_category_entity_varchar`;TRUNCATE TABLE `catalog_category_product`;TRUNCATE TABLE `catalog_category_product_index`;
insert into `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`position`,`level`,`children_count`) values (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);insert into `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,32,0,2,1),(2,3,32,1,2,1);insert into `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');
Example:
$arg_attribute = 'manufacturer'; $arg_value = 'value to be added'; $attr_model = Mage::getModel('catalog/resource_eav_attribute'); $attr = $attr_model->loadByCode('catalog_product', $arg_attribute); $attr_id = $attr->getAttributeId(); $option['attribute_id'] = $attr_id; $option['value']['any_option_name'][0] = $arg_value; $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $setup->addAttributeOption($option);
Note: This example taken from the webspeaks blog.
For more detail click here webspeaks
class
MyNamespace_MyCustomModule_Model_Resource_
MyCustomModuleModel
extends
Mage_Core_Model_Mysql4_Abstract {
public
function
_construct() {
// Table resource, primary key
$this
->_init(
'mycustommodule/mycustommodulemodel'
,
'mycustommodule_id'
);
// The primary key is not an auto_increment field
$this
->_isPkAutoIncrement = false;
}
}
Here we just set the '
_isPkAutoIncrement ' variable as 'false'.
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
$currentDate = date('Y-m-d', $currentTimestamp);
$collection = $model->getCollection()
->addAttributeToSelect(array('entity_id', 'status'))
->addAttributeToFilter('status', array('eq' => 2)) // 2- Disabled products
->addAttributeToFilter('display_date', array('lteq' => $currentDate));
Note: 'display_date' is a custom attribute.
# Following are the some examples of conditions:
Equals:
$_products->addAttributeToFilter('status', array('eq' => 1));
Not Equals:
$_products->addAttributeToFilter('sku', array('neq' => 'testsku'));
Like:
$_products->addAttributeToFilter('sku', array('like' => 'PG%'));
Not Like:
$_products->addAttributeToFilter('sku', array('nlike' => 'testprod%'));
In:
$_products->addAttributeToFilter('id', array('in' => array(1,3,8)));
Not In:
$_products->addAttributeToFilter('id', array('nin' => array(1,3,8)));
Greater Than:
$_products->addAttributeToFilter('id', array('gt' => 6));
Less Than:
$_products->addAttributeToFilter('id', array('lt' => 6));
Greater Than or Equals To:
$_products->addAttributeToFilter('id', array('gteq' => 6));
Less Than or Equals To:
$_products->addAttributeToFilter('id', array('lteq' => 6));
Note: You will know more about Magento & Download latest version of Magento from http://www.magentocommerce.com/
$currentTimestamp
= Mage::getModel(
'core/date'
)->timestamp(time());
echo
$currentDate
=
date
(
'Y-m-d'
,
$currentTimestamp
);
$Date
=
'2013-05-15'
;
$dateTimestamp
= Mage::getModel(
'core/date'
)->timestamp(
strtotime
(
$Date
));
echo
$currentDate
=
date
(
'd.m.Y'
,
$dateTimestamp
);