Pages
▼
Wednesday, 29 August 2012
Magento: How to solve indexing problem?
Magento: How to solve indexing problem?
open your phpmyadmin.and run below given Query in sql tab.
DROP TABLE IF EXISTS `index_process_event`;
DROP TABLE IF EXISTS `index_event`;
DROP TABLE IF EXISTS `index_process`;
DROP TABLE IF EXISTS `index_event`;
DROP TABLE IF EXISTS `index_process`;
CREATE TABLE `index_event` (
`event_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`type` VARCHAR(64) NOT NULL,
`entity` VARCHAR(64) NOT NULL,
`entity_pk` BIGINT(20) DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`old_data` MEDIUMTEXT,
`new_data` MEDIUMTEXT,
PRIMARY KEY (`event_id`),
UNIQUE KEY `IDX_UNIQUE_EVENT` (`type`,`entity`,`entity_pk`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `index_process` (
`process_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`indexer_code` VARCHAR(32) NOT NULL,
`status` ENUM('pending','working','require_reindex') NOT NULL DEFAULT 'pending',
`started_at` DATETIME DEFAULT NULL,
`ended_at` DATETIME DEFAULT NULL,
`mode` ENUM('real_time','manual') NOT NULL DEFAULT 'real_time',
PRIMARY KEY (`process_id`),
UNIQUE KEY `IDX_CODE` (`indexer_code`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
INSERT INTO `index_process`(`process_id`,`indexer_code`,`status`,`started_at`,`ended_at`,`mode`) VALUES (1,'catalog_product_attribute','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(2,'catalog_product_price','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(3,'catalog_url','pending','2010-02-13 19:12:15','2010-02-13 19:12:15','real_time'),(4,'catalog_product_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(5,'catalog_category_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(6,'catalog_category_product','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(7,'catalogsearch_fulltext','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(8,'cataloginventory_stock','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time');
CREATE TABLE `index_process_event` (
`process_id` INT(10) UNSIGNED NOT NULL,
`event_id` BIGINT(20) UNSIGNED NOT NULL,
`status` ENUM('new','working','done','error') NOT NULL DEFAULT 'new',
PRIMARY KEY (`process_id`,`event_id`),
KEY `FK_INDEX_EVNT_PROCESS` (`event_id`),
CONSTRAINT `FK_INDEX_EVNT_PROCESS` FOREIGN KEY (`event_id`) REFERENCES `index_event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_INDEX_PROCESS_EVENT` FOREIGN KEY (`process_id`) REFERENCES `index_process` (`process_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8;
`event_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`type` VARCHAR(64) NOT NULL,
`entity` VARCHAR(64) NOT NULL,
`entity_pk` BIGINT(20) DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`old_data` MEDIUMTEXT,
`new_data` MEDIUMTEXT,
PRIMARY KEY (`event_id`),
UNIQUE KEY `IDX_UNIQUE_EVENT` (`type`,`entity`,`entity_pk`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `index_process` (
`process_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`indexer_code` VARCHAR(32) NOT NULL,
`status` ENUM('pending','working','require_reindex') NOT NULL DEFAULT 'pending',
`started_at` DATETIME DEFAULT NULL,
`ended_at` DATETIME DEFAULT NULL,
`mode` ENUM('real_time','manual') NOT NULL DEFAULT 'real_time',
PRIMARY KEY (`process_id`),
UNIQUE KEY `IDX_CODE` (`indexer_code`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
INSERT INTO `index_process`(`process_id`,`indexer_code`,`status`,`started_at`,`ended_at`,`mode`) VALUES (1,'catalog_product_attribute','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(2,'catalog_product_price','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(3,'catalog_url','pending','2010-02-13 19:12:15','2010-02-13 19:12:15','real_time'),(4,'catalog_product_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(5,'catalog_category_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(6,'catalog_category_product','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(7,'catalogsearch_fulltext','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(8,'cataloginventory_stock','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time');
CREATE TABLE `index_process_event` (
`process_id` INT(10) UNSIGNED NOT NULL,
`event_id` BIGINT(20) UNSIGNED NOT NULL,
`status` ENUM('new','working','done','error') NOT NULL DEFAULT 'new',
PRIMARY KEY (`process_id`,`event_id`),
KEY `FK_INDEX_EVNT_PROCESS` (`event_id`),
CONSTRAINT `FK_INDEX_EVNT_PROCESS` FOREIGN KEY (`event_id`) REFERENCES `index_event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_INDEX_PROCESS_EVENT` FOREIGN KEY (`process_id`) REFERENCES `index_process` (`process_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8;
Friday, 17 August 2012
How to Add Custom Field in the One Page Checkout in Magento
Step: – 1
Add Custom Field into Billing Address tab of the Onepage Checkout in Frontend.
app\design\frontend\[Package_name]\[Theme_name]\template\checkout\onepage\billing.phtml
Add Custom Field into Shipping Address tab of the Onepage Checkout in Frontend.
app\design\frontend\[Package_name]\[Theme_name]\template\checkout\onepage\shipping.phtml
Add Custom Field into Customer Address Edit tab in Frontend.
app\design\frontend\[Package_name]\[Theme_name]\template\customer\address\edit.phtml
System->Configuration->Customers->Customer Configurations->Address Templates
Add following code in the “Text” Textarea.
System->Configuration->Customers->Customer Configurations->Address Templates
Add following code in the “HTML” Textarea.
System->Configuration->Customers->Customer Configurations->Address Templates
Add following code in the “PDF” Textarea.
Step: – 7
app\etc\modules\Tdg_All.xml
First of all create file with above given name and put following code into that file.
app\code\local\Tdg\Check\etc\ config.xml
app\code\local\Tdg\Check\sql\check_setup\ mysql4-install-1.0.0.php
Add Custom Field into Billing Address tab of the Onepage Checkout in Frontend.
app\design\frontend\[Package_name]\[Theme_name]\template\checkout\onepage\billing.phtml
<li class="wide"> <label for="billing:jobtitle"><?php echo $this->__('Job Title') ?></label> <div class="input-box"> <input type="text" id="billing:jobtitle" name="billing[jobtitle]"
value="<?php echo $this->htmlEscape($this->getAddress()->getJobtitle()) ?>"
title="<?php echo $this->__('Job Title') ?>" class="input-text" /> </div> </li>
Step: – 2
Add Custom Field into Shipping Address tab of the Onepage Checkout in Frontend.
app\design\frontend\[Package_name]\[Theme_name]\template\checkout\onepage\shipping.phtml
<li class="wide"> <label for="shipping:jobtitle"><?php echo $this->__('Job Title') ?></label> <div class="input-box"> <input type="text" id="shipping:jobtitle" name="shipping[jobtitle]"
value="<?php echo $this->htmlEscape($this->getAddress()->getJobtitle()) ?>"
title="<?php echo $this->__('Job Title') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" /> </div> </li>
Step: – 3
Add Custom Field into Customer Address Edit tab in Frontend.
app\design\frontend\[Package_name]\[Theme_name]\template\customer\address\edit.phtml
<li class="wide"> <label for="jobtitle"><?php echo $this->__('Job Title') ?></label> <div class="input-box"> <input type="text" name="jobtitle" id="jobtitle" title="<?php echo $this->__('Job Title') ?>"
value="<?php echo $this->htmlEscape($this->getAddress()->getJobtitle()) ?>" class="input-text" /> </div> </li>
Step: – 4
System->Configuration->Customers->Customer Configurations->Address Templates
Add following code in the “Text” Textarea.
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}}
{{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}} {{depend company}}{{var company}}{{/depend}} {{depend jobtitle}}{{var jobtitle}}{{/depend}} {{if street1}}{{var street1}} {{/if}} {{depend street2}}{{var street2}}{{/depend}} {{depend street3}}{{var street3}}{{/depend}} {{depend street4}}{{var street4}}{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}},
{{/if}}{{if postcode}}{{var postcode}}{{/if}} {{var country}} T: {{var telephone}} {{depend fax}}F: {{var fax}}{{/depend}}
Step: – 5
System->Configuration->Customers->Customer Configurations->Address Templates
Add following code in the “HTML” Textarea.
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}}
{{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}<br/> {{depend company}}{{var company}}<br />{{/depend}} {{depend jobtitle}}{{var jobtitle}}<br />{{/depend}} {{if street1}}{{var street1}}<br />{{/if}} {{depend street2}}{{var street2}}<br />{{/depend}} {{depend street3}}{{var street3}}<br />{{/depend}} {{depend street4}}{{var street4}}<br />{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}},
{{/if}}{{if postcode}}{{var postcode}}{{/if}}<br/> {{var country}}<br/> {{depend telephone}}T: {{var telephone}}{{/depend}} {{depend fax}}<br/>F: {{var fax}}{{/depend}}
Step: – 6
System->Configuration->Customers->Customer Configurations->Address Templates
Add following code in the “PDF” Textarea.
{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}}
{{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}| {{depend company}}{{var company}}|{{/depend}} {{depend jobtitle}}{{var jobtitle}}|{{/depend}} {{if street1}}{{var street1}} {{/if}} {{depend street2}}{{var street2}}|{{/depend}} {{depend street3}}{{var street3}}|{{/depend}} {{depend street4}}{{var street4}}|{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}},
{{/if}}{{if postcode}}{{var postcode}}{{/if}}| {{var country}}| {{depend telephone}}T: {{var telephone}}{{/depend}}| {{depend fax}}<br />F: {{var fax}}{{/depend}}|
I have created the separate module for adding Custom Field into Billing and Shipping Address in Frontend and Backend of the Magento Store.
Step: – 7
app\etc\modules\Tdg_All.xml
First of all create file with above given name and put following code into that file.
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Tdg_Check> <active>true</active> <codePool>local</codePool> </Tdg_Check> </modules> </config>
Step: – 8
app\code\local\Tdg\Check\etc\ config.xml
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Tdg_Check> <version>1.0.0</version> </Tdg_Check> </modules> <admin> <fieldsets> <customer_dataflow> <jobtitle><billing>1</billing><shipping>1</shipping></jobtitle> </customer_dataflow> </fieldsets> </admin> <global> <models> <check> <class>Tdg_Check_Model</class> </check> </models> <resources> <check_setup> <setup> <module>Tdg_Check</module> </setup> <connection> <use>core_setup</use> </connection> </check_setup> <check_write> <connection> <use>core_write</use> </connection> </check_write> <check_read> <connection> <use>core_read</use> </connection> </check_read> </resources> <fieldsets> <sales_copy_order_billing_address> <jobtitle><to_order>*</to_order></jobtitle> </sales_copy_order_billing_address> <sales_copy_order_shipping_address> <jobtitle><to_order>*</to_order></jobtitle> </sales_copy_order_shipping_address> <sales_convert_quote_address> <jobtitle><to_order_address>*</to_order_address><to_customer_address>*</to_customer_address></jobtitle> </sales_convert_quote_address> <sales_convert_order_address> <jobtitle><to_quote_address>*</to_quote_address></jobtitle> </sales_convert_order_address> <customer_address> <jobtitle><to_quote_address>*</to_quote_address></jobtitle> </customer_address> <checkout_onepage_billing> <jobtitle><to_customer>*</to_customer></jobtitle> </checkout_onepage_billing> </fieldsets> </global> </config>
Step: – 9
app\code\local\Tdg\Check\sql\check_setup\ mysql4-install-1.0.0.php
<?php /* @var $installer Mage_Customer_Model_Entity_Setup */ $installer = $this; $installer->startSetup(); /* @var $addressHelper Mage_Customer_Helper_Address */ $addressHelper = Mage::helper('customer/address'); $store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID); /* @var $eavConfig Mage_Eav_Model_Config */ $eavConfig = Mage::getSingleton('eav/config'); // update customer address user defined attributes data $attributes = array( 'jobtitle' => array( 'label' => 'Job Title', 'backend_type' => 'varchar', 'frontend_input' => 'text', 'is_user_defined' => 1, 'is_system' => 0, 'is_visible' => 1, 'sort_order' => 140, 'is_required' => 1, 'multiline_count' => 0, 'validate_rules' => array( 'max_text_length' => 255, 'min_text_length' => 1 ), ), ); foreach ($attributes as $attributeCode => $data) { $attribute = $eavConfig->getAttribute('customer_address', $attributeCode); $attribute->setWebsite($store->getWebsite()); $attribute->addData($data); $usedInForms = array( 'adminhtml_customer_address', 'customer_address_edit', 'customer_register_address' ); $attribute->setData('used_in_forms', $usedInForms); $attribute->save(); } $installer->run(" ALTER TABLE {$this->getTable('sales_flat_quote_address')}
ADD COLUMN `jobtitle` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`; ALTER TABLE {$this->getTable('sales_flat_order_address')}
ADD COLUMN `jobtitle` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`; "); $installer->endSetup(); ?>
Thursday, 16 August 2012
Truncate all categories and and Reset Categoryt id’s in Magento
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');
Friday, 10 August 2012
How do I increase the number of upsell products?
app/design/frontend/default/THEME/layout/catalog.xml:
However when I increase both setColumnCount and setItemLimit to 5 only 4 upsell products are displayed.
block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml">
<action method="setColumnCount"><columns>4</columns></action>
<action method="setItemLimit"><type>upsell</type><limit>4</limit></action>
</block>
However when I increase both setColumnCount and setItemLimit to 5 only 4 upsell products are displayed.
Restrict Product Reviews to Registered Users in Magento
First go ->app\design\frontend\base\default\template\review\helper\Summary.phtml
<a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Add Your Review') ?></a>
Repace this line under code
<?php
$loggedIn = $this->helper("customer")->isLoggedIn();
if($loggedIn == 1)
{ ?>
<a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Add Your Review') ?></a>
<?php }
else
{ ?>
<a href="<?php echo $this->getUrl() ?>customer/account/login/"><?php echo $this->__('Add Your Review') ?></a>
<?php } ?>
<a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Add Your Review') ?></a>
Repace this line under code
<?php
$loggedIn = $this->helper("customer")->isLoggedIn();
if($loggedIn == 1)
{ ?>
<a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Add Your Review') ?></a>
<?php }
else
{ ?>
<a href="<?php echo $this->getUrl() ?>customer/account/login/"><?php echo $this->__('Add Your Review') ?></a>
<?php } ?>
Wednesday, 8 August 2012
Magento- Adding Short Description to the View Cart page
Magento’s default view cart page includes a product thumbnail and the product name, as shown below.
What if you wanted to add the short description to the view cart page, to help give customers a better idea of the product they have added to their cart? How would you do that?
The view cart page is controlled by default.phtml, which is located in app/design/frontend/blank/default/template/checkout/cart/item/default.html. Of course, you will want to place the default.phtml file in your theme folder– app/design/frontend/default/your-theme/template/checkout/cart/item/default.html.
So let’s take a look at the code.
At line 34, Magento begins building the product name, which is displayed in the view cart page,
<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
We want to place the short description right after the product name, so we’ll add the following piece of code right after the closing </h2> tag:
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>
***********************************************************************
Any other information, including custom attributes could also be added, for example if you had a custom attribute called dimension, and you wanted to add it before the short description, the code would look like this (from line 34)–
<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getdimensions();
?>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>
Any attribute you wanted to display on the view cart page could be handled in this manner, so take a look at your View Cart Page, and make it more user-friendly.
What if you wanted to add the short description to the view cart page, to help give customers a better idea of the product they have added to their cart? How would you do that?
The view cart page is controlled by default.phtml, which is located in app/design/frontend/blank/default/template/checkout/cart/item/default.html. Of course, you will want to place the default.phtml file in your theme folder– app/design/frontend/default/your-theme/template/checkout/cart/item/default.html.
So let’s take a look at the code.
At line 34, Magento begins building the product name, which is displayed in the view cart page,
<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
We want to place the short description right after the product name, so we’ll add the following piece of code right after the closing </h2> tag:
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>
***********************************************************************
Any other information, including custom attributes could also be added, for example if you had a custom attribute called dimension, and you wanted to add it before the short description, the code would look like this (from line 34)–
<h2>
<?php if ($this->hasProductUrl()):?>
<a href=”<?php echo $this->getProductUrl() ?>”><?php echo $this->htmlEscape($this->getProductName()) ?></a>
<?php else: ?>
<?php echo $this->htmlEscape($this->getProductName()) ?>
<?php endif; ?>
</h2>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getdimensions();
?>
<?php
$custom = Mage::getModel(‘catalog/product’)->load($_item->getProductId());
echo $custom->getShortDescription();
?>
Any attribute you wanted to display on the view cart page could be handled in this manner, so take a look at your View Cart Page, and make it more user-friendly.