There was a problem with reindexing process magento

Magento
When I try to reindex from magento admin I show error "There was a problem with reindexing process". I found many post in google but not get excat fixed. After many hours I fixed that issue and I show you how you can also fix this issue and working good all reindex.   1) Export all catalog_product_flat _1 tables with data and structure with 'Disable foreign key checks' enabled. 2) Truncate all catalog_product_flat _1 tables. 3) Ensure that whether products categories are all visible in Frontend. 4) Login to Magento Admin Panel. 5) Then go to 'System' menu and click on 'Index Management' submenu. 6) At last click "Reindex Data" next to "Product Flat Data" index. To figure out the reindexing issue for Category Products do the following actions: 1)…
Read More

Display product image in invoice + Magento

Magento
Here I show you how to Display product image in magento PDF invoice or Display product image in shipping invoice. The product line display occurs in specific PHP classes within the app/code/core/Mage/sales/Model/order/pdf folder. There is one folder for shipment, one for invoice, and one for credit. The product display occurs in the deault file where the Mage_Sales_Model_Order_Pdf_Items_Abstract is defined. Product object using the id from order / items, and get the image file using the following code in the draw function. [php] /* Display Image Start */ $id = Mage::getModel('catalog/product')->getIdBySku($this->getSku($item)); $product= Mage::getModel('catalog/product')->load($id); $imageUrl = $product->getSmallImageUrl(); $imageFile= str_replace(Mage::getBaseUrl('media'),"media/",$imageUrl); $imageWidth = 100; $imageHeight = 50; $image = Zend_Pdf_Image::imageWithPath($imageFile,$imageWidth,$imageHeight); $y=$pdf->y – $imageHeight /3; $page->drawImage($image, 35,$y, 35+ $imageWidth / 2, $y + $imageHeight/2); // If you want to display custom image then use this…
Read More

Fatal error: Call to a member function getTable() on a non-object in magento

Magento
Sometime you can see on your magento store "Fatal error: Call to a member function getTable() on a non-object in magento" when you try to get Configurable product in frontend or when you try to add Configurable product in backend in magento. Its error occurred because of not found some function or file. When I moved my magnto store from my local server to online and try to add Configurable product from backend I see this error   Error: Fatal error: Call to a member function getTable() on a non-object in /var/www/magento/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php on line 456   Sometime extract zip file or move files from local to online some files change name like Attribute.php0000644. In our case when I trace or after some R & D I found the solution. Please…
Read More

Removed shipping address and shipping method from onepage checkout in magento

Magento
Here I can show you how to remove shipping address from onepage checkout and remove shipping method from onepage checkout in magento. Based on different shop and requirement we need to magento customize onepage checkout method. When site give user only product information or accept only quote request based on product then no need to show shipping address and shipping method tab from onepage checkout in magento. If you are managing logistics for heavy equipment, consider using specialized services for tasks like https://www.shiply.com/de/fahrzeugtransport/traktortransport.php to ensure safe and efficient handling. If you want to removed shipping address and shipping method from onepage checkout in magento then foloe below step. Step 1: GO to /public_html/app/code/core/Mage/Checkout/Block/Onepage/abstract.php Replace this code [php] <?php protected function _getStepCodes() { return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'); } ?>…
Read More

Cannot initialize the indexer process

Magento
When I upgrade magento all is work fine but when I try to reindex then it show me error like "Cannot initialize the indexer process". I spend lot time and finally I got the solution for this. I found many solution for fixed this issue but not work for me but when I repair my magento database using database repair tool developed by Magento core then its fixed me. How to repair the magento database: 1. Download repair tool from Magento and unzip the package. 2. Upload magento-db-repair-tool-1.1.php to your server 3. Backup your current database (call it 'magentoDB1'). Export this database and then import it into a new database (let's call it 'magentoDB2'). 4. Install a fresh Magento using 'magentoDB2'. 5. Now open the the URL in browser: http://www.youdomain.com/magento-db-repair-tool-1.0.php.…
Read More

Magento addAttributeToFilter SQL Conditionals

Magento
If you want to customize query or product collection data you can easily to do that with addAttributeToFilter funcation in magento. In short you can easily customize product collection select query based on your requirement in magento development. [php] <?php $collection = Mage::getModel('catalog/product')->getCollection(); ?> [/php] If you want get all fields then use below condition select [php] <?php $collection->addAttributeToSelect('*'); ?> [/php] If you want to get limited fields then use below condition [php] <?php $collection->addAttributeToSelect(array('name', 'product_url', 'small_image')); ?> [/php] [php] <?php $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect(array('name', 'product_url', 'small_image')) ->addAttributeToFilter('sku', array('like' => 'test-product%')) ->load(); ?> [/php] The above code would get a product collection which contain only products that have an SKU starting with "test-product". addAttributeToFilter Conditionals [php] <?php // Is Equal To (eq) $collection->addAttributeToFilter('status', array('eq' => 1)); // Is Not Equal…
Read More

Add Date field with Datepicker in Magento

Magento
Here I want to show you how to add date field with date picker in any of your form like contact, gift message etc in magento frontend design. Magento has a built in library for calendar functionality but its available only on admin so here I show you how to se date field with date picker in magento frontend. Add below css and javascript for calender in your current theme page.xml file. This will include all the calendar library functions frontend on your theme. [sourcecode language="plain"] <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params></params></action> <action method="addItem"><type>js</type><name>calendar/calendar.js</name></action> <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name></action> <block type="core/html_calendar" name="head.calendar" as="calendar" template="page/js/calendar.phtml"></block> [/sourcecode] Now add below code in which form where you want to add date field like contact, gift message etc... [php] <div class="field"> <label for="dob"><?php echo Mage::helper('contacts')->__('DOB') ?></label> <div class="input-box"> <input name="dob" id="_dob"…
Read More

Magento get items in order

Magento
Here, I can show you how you can get information about all items in your magento shopping cart based on order id. How to get product details from order id or sometimes need to get product it, product sku, product name , category id, category name. So its easy to get product from order item based on order number. [php] <?php require 'app/Mage.php'; Mage::app(); $orderNumber = 100004544; $order = Mage::getModel('sales/order')->loadByIncrementId($orderNumber); // get order total value $orderValue = number_format ($order->getGrandTotal(), 2, '.' , $thousands_sep = ''); // get order item collection $orderItems = $order->getItemsCollection(); foreach ($orderItems as $item){ $product_id = $item->product_id; $product_sku = $item->sku; $product_name = $item->getName(); $_product = Mage::getModel('catalog/product')->load($product_id); $cats = $_product->getCategoryIds(); $category_id = $cats[0]; // just grab the first id $category = Mage::getModel('catalog/category')->load($category_id); $category_name = $category->getName(); echo "orderNumber=".$orderNumber."<br/>"; echo…
Read More

Magento category product count

Magento
Many times we need to show product count per category in magento. So here I am showing to how many products (Product count) in that categories. First of all I get all categories based on category position with ascending order and then get product count for that category. It shows like below example: Laptops (4) Hard Drives (4) Root Catalog (5) Monitors (4) Shirts (19) Shoes (46) Get category and product count in magento [php] <?php $categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addAttributeToSelect('my_attribute') ->addAttributeToSelect('position') ->addAttributeToSort('position', 'ASC') ->setLoadProductCount(true) ->addAttributeToFilter('is_active',array('eq'=>true)) ->load(); ?> <?php foreach($categories as $key=>$category): ?> <?php if($category->getName() != ''):?> <?php $prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category); // Magento product collection ?> <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a> (<?php echo $prodCollection->count() ?>)<br/> <?php endif;?> <?php endforeach; ?> [/php] [JWD-Magento-Development]
Read More

Remove all products,categories,customers,orders from magento

Magento
If you want to delete all products, categories, customers and orders or sample data from magento database using phpmyadmin then this is very help to you. Here I show you how you can delete all products from magento database as well as all categories,customers and orders. Delete all products from magento database Below code to delete all product and their related records from magento database. [sourcecode language="plain"] TRUNCATE TABLE `catalog_product_bundle_option`; TRUNCATE TABLE `catalog_product_bundle_option_value`; TRUNCATE TABLE `catalog_product_bundle_selection`; TRUNCATE TABLE `catalog_product_entity_datetime`; TRUNCATE TABLE `catalog_product_entity_decimal`; TRUNCATE TABLE `catalog_product_entity_gallery`; TRUNCATE TABLE `catalog_product_entity_int`; TRUNCATE TABLE `catalog_product_entity_media_gallery`; TRUNCATE TABLE `catalog_product_entity_media_gallery_value`; TRUNCATE TABLE `catalog_product_entity_text`; TRUNCATE TABLE `catalog_product_entity_tier_price`; TRUNCATE TABLE `catalog_product_entity_varchar`; TRUNCATE TABLE `catalog_product_link`; TRUNCATE TABLE `catalog_product_link_attribute`; TRUNCATE TABLE `catalog_product_link_attribute_decimal`; TRUNCATE TABLE `catalog_product_link_attribute_int`; TRUNCATE TABLE `catalog_product_link_attribute_varchar`; TRUNCATE TABLE `catalog_product_link_type`; TRUNCATE TABLE `catalog_product_option`; TRUNCATE TABLE `catalog_product_option_price`; TRUNCATE TABLE `catalog_product_option_title`;…
Read More