How to solve Product Flat Data and Category Products (Indexed category/products association) reindex issue

Hello

Getting to this point ultimately lead to the resolution. Below is the process we used to solve the reindexing issue for Product Flat Data:

1) Export all catalog_product_flat _* tables with data and structure with “Disable foreign key checks” enabled.
2) Drop all catalog_product_flat _* tables.
3) Once check in Frontend , that products are categories are visible
4) Login to Magento backend
5) Go to: System -> Index Management
6) Click “Reindex Data” next to “Product Flat Data” index

Below is the process we used to solve the reindexing issue for Category Products (Indexed category/products association):

1) Log into phpMyAdmin
2) Go to `catalog_category_product_index`
3) Click “Export”.
4) Export only structure with “Disable foreign key checks” enabled.
5) Drop the table `catalog_category_product_index`
6) With the SQL that was exported, remove the constraints at the bottom of the export. Be sure to keep the “SET FOREIGN_KEY_CHECKS” statements.
7) Click “SQL”, paste in modified SQL and click “Go”
8) Login to Magento backend
9) Go to: System -> Index Management
10) Click “Reindex Data” next to “Category Products” index

Thanks

for more info visit mage-people

Advertisements

Magento: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘XX-XX’ for key “PRIMARY”

Just Run This code in SQL


<code><code>TRUNCATE `sales_flat_quote`;
 ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
 TRUNCATE `sales_flat_quote_address`;
 ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
 TRUNCATE `sales_flat_quote_address_item`;
 ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
 TRUNCATE `sales_flat_quote_item`;
 ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
 TRUNCATE `sales_flat_quote_item_option`;
 ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
 TRUNCATE `sales_flat_quote_payment`;
 ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;</code></code>

TRUNCATE `log_customer`;
 ALTER TABLE `log_customer` AUTO_INCREMENT=1;
 TRUNCATE `log_quote`;
 ALTER TABLE `log_quote` AUTO_INCREMENT=1;
 TRUNCATE `log_summary`;
<div></div>
ALTER TABLE `log_summary` AUTO_INCREMENT=1;
 TRUNCATE `log_summary_type`;
 ALTER TABLE `log_summary_type` AUTO_INCREMENT=1;
 TRUNCATE `log_url`;
 ALTER TABLE `log_url` AUTO_INCREMENT=1;
 TRUNCATE `log_url_info`;
 ALTER TABLE `log_url_info` AUTO_INCREMENT=1;
 TRUNCATE `log_visitor`;
 ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
 TRUNCATE `log_visitor_info`;
 ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
 TRUNCATE `report_event`;
 ALTER TABLE `report_event` AUTO_INCREMENT=1;

for more info visit mage-people

How to delete all orders in Magento

Unfortunately, magento default does not have option for delete order in Magento by default. there are over hundred orders leave in backend which make our sales confused. In this case, you can execute following SQL statements to delete the ALL orders in MySQL database:

<pre>TRUNCATE TABLE {prefix}sales_flat_order;
TRUNCATE TABLE {prefix}sales_order_tax;
TRUNCATE TABLE {prefix}downloadable_link_purchased;
DELETE FROM {prefix}eav_entity_store WHERE entity_type_id IN (SELECT entity_type_id FROM {prefix}eav_entity_type WHERE entity_type_code IN ('order', 'invoice', 'creditmemo', 'shipment'));</pre>

for more info visit mage-people

Category listing alphabetically in magento

<?php
$cats = Mage::getModel('catalog/category')->load(7)->getChildren();
$catIds = explode(',',$cats);
?>
<ul>
<?php foreach($catIds as $catId): ?>
<li>
<?php
$category = Mage::getModel('catalog/category')->load($catId);
echo '<a href="' . $category->getUrl() . '">';
echo $category->getName() . '</a>';
?>
</li>
<?php endforeach; ?>
</ul>

for more info visit mage-people

Sorting categories in Magento according to the position in admin

<?php    $cats = Mage::getModel('catalog/category')->load(3)->getChildrenCategories();    ?>    <ul>    <?php foreach($cats as $category): ?>        <li>            <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a>        </li>    <?php endforeach; ?>    </ul>

in here 3 is parent category ID

for more info visit mage-people

Searching product in different Category In Magento

Suppose You want to search a product in specific Category This code will help you. for this you just need to go  catalogSearch and paste this code in form.mini.phtml then you will show the result


<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category   design_default
* @package    Mage
* @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*
*
* @version Edmonds Commerce Quick Search with Top Level Categories
*
*/
$category = Mage::getModel('catalog/category');
if(is_object(Mage::registry('current_category'))){
$current_category_path=Mage::registry('current_category')->getPathIds();
}else{
$current_category_path = array();
}
$category->load(Mage::app()->getStore()->getRootCategoryId());
$children_string = $category->getChildren();
$children = explode(',',$children_string);
$extra_options='';
foreach($children as $c){
$selected = (in_array($c, $current_category_path))?'SELECTED':'';
$extra_options.= '<option value="' . $c . '" ' . $selected . '>' . $category->load($c)->getName() . '</option>' . "\n";
}
?>
<form id="search_mini_form" action="<?php echo $this->helper('catalogSearch')->getResultUrl() ?>" method="get">
<fieldset>
<legend><?php echo $this->__('Search Site') ?></legend>
<div>
<input id="search" type="text" name="<?php echo $this->helper('catalogSearch')->getQueryParamName() ?>" value="<?php echo $this->helper('catalogSearch')->getEscapedQueryText() ?>" />
<select name="cat" id="cat">
<option value="">All Departments</option>
<?= $extra_options ?>
</select>
<input type="submit" value="Go" style="border: 1px solid #808080;" alt="<?php echo $this->__('Search') ?>" />
<div id="search_autocomplete"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('search site...') ?>');
searchForm.initAutocomplete('<?php echo $this->helper('catalogSearch')->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>
</div>
</fieldset>
</form>

this above code is only for Displaying Current category and if someone want to search in specific category

then you need to change the code like


$exclude_array=array(1,2,3);
foreach($children as $c){
if(in_array($c, $exclude_array)){continue;}
$selected = (in_array($c, $current_category_path))?'SELECTED':'';
$extra_options.= '<option value="' . $c . '" ' . $selected . '>' . $category->load($c)->getName() . '</option>' . "\n";
}

on the otherhand if someone want to get all category and subcategory then


if($this->getSubCategories($c)){
foreach($this->getSubCategories($c) as $sc){
foreach($this->getSubCategories($sc) as $ssc){
...
}
}
}

for more info visit mage-people