Create custom option for Product by MySql Query

Create custom option for Product by MySql Query

try { $productId=$product->getEntityId();//Your product id $write = Mage::getSingleton( 'core/resource' )->getConnection( 'core_write' ); $read = Mage::getSingleton( 'core/resource' )->getConnection( 'core_read' ); $query = "UPDATE catalog_product_entity set has_options=1 where entity_id=".$productId; $write->query($query); $optionType = 'field'; $query = 'INSERT INTO catalog_product_option (product_id,type) VALUES ('.$productId.',"'.$optionType.'")'; $write->query($query); $optionTitle = 'Comment'; $optionId = $read->fetchOne("SELECT MAX(`option_id`) as LastID FROM `catalog_product_option`"); $query = 'INSERT INTO catalog_product_option_title (option_id,title) VALUES ('.$optionId.',"'.$optionTitle.'")'; $write->query($query); $priceType = 'fixed'; $query = 'INSERT INTO catalog_product_option_price (option_id,price_type) VALUES ('.$optionId.',"'.$priceType.'")'; $write->query($query); } catch(Exception $e) { echo $e;...
Simple way Reindex all in magento

Simple way Reindex all in magento

Create a php script with the following below mention code. Provide proper path, In my case path is : /var/www/import/web/shell/indexer.php path is change according to server base directory location. <?php exec("php -f /var/www/import/web/shell/indexer.php reindexall");...
Enable Admin Template Hints Magento

Enable Admin Template Hints Magento

Enable Admin Template Hints Magento INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0, 'dev/debug/template_hints', 1),('default', 0,'dev/debug/template_hints_blocks',1); Disable Admin Template Hints Magento UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints'; Re-Enable Admin Template Hints Magento UPDATE core_config_data set value = 1 where scope = 'default' and scope_id = 0 and path...
UPLOAD SIMPLE PRODUCT IN MAGENTO FROM CSV PHP SCRIPT

UPLOAD SIMPLE PRODUCT IN MAGENTO FROM CSV PHP SCRIPT

#!/usr/local/bin/php.cli <?php //complete_notification require_once('app/Mage.php'); Mage::app('default'); set_time_limit(0); $handle = fopen("catalogproduct.csv","r"); $count=1; while(($data=fgetcsv($handle,","))!==FALSE) { $product = Mage::getModel('catalog/product'); $dataarr = array('sku'=>$data[0],'attribute_set'=>$data[2],'type_id'=>$data[3],'name'=>$data[8],'price'=>$data[9],'description'=>$data[7],'short_description'=>$data[10],'weight'=>$data[16],'status'=>$data[12],'visibility'=>$data[15],'qty'=>$data[17]); $product = Mage::getModel('catalog/product'); $sku = $product->getIdBySku($dataarr['sku']); //$storeid = Mage::app()->getWebsite()->getDefaultGroup()->getDefaultStoreId(); //echo '<pre>'; //print_r($data); //echo '</pre>'; if(!$sku) { if($count>1) { $productData=array( 'sku' => $dataarr['sku'], 'name' => $dataarr['name'], 'description' => $dataarr['description'], 'short_description' => $dataarr['short_description'], 'weight' => $dataarr['weight'], // whatever your product weighs 'status' => $dataarr['status'], // 1 => enabled, 0 => disabled some time 2=> disable 'visibility' => '4', // 1 => Not Visible Individually, 2 => Catalog, 3 => Search, 4 => Catalog, Search 'attribute_set_id' => 4, // default 'type_id' => $dataarr['type_id'], 'price' => $dataarr['price'], //'special_price' => 1599, // optional 'tax_class_id' => 0, // None //'page_layout' => 'one_column', ); foreach($productData as $key => $value) { $product->setData($key,$value); } $product->setWebsiteIds(array(1)); //$product->setStoreId($storeId);//Setting default store id $product->setStockData(array( //'manage_stock' => 1, 'is_in_stock' => 1, 'qty' => 10, //'use_config_manage_stock' => 0 )); $categoryIds = array(3); // Use category ids according to your store $product->setCategoryIds($categoryIds); //$mode = array("image"); $img = 'db_file_img_229_160xauto.jpg'; //$product->addImageToMediaGallery($img, $mode, true, true); $mode = array("small_image","thumbnail","image"); try { $product->addImageToMediaGallery($img,$mode,false,false); } catch(Exception $e) { echo 'Image failed'; echo $e->getMessage(); } foreach($product->getStoreIds() as $storeId) { $product->setStoreId($storeId)->setImage(false)->setSmallImage(false)->setThumbnail(false); } try { $product->save(); echo $product->getId(); } catch (Exception $ex) { echo 'Error'; } break; } } $count++; }// end of while loop...
Column type in Magento Admin Grid

Column type in Magento Admin Grid

In Magento Admin Grid In Magento Admin Grid we can change type of of the columns as per the datatype of the data and some other type of column type also available in Magento. $this->addColumn('name', array( 'header' => Mage::helper('yourmodule')->__('Name'), 'align' =>'right', 'width' => '50px', 'type' => 'date', 'index' => 'name', )); You can change column type of your admin grid by opening Grid.php path : namespace\modulename\Block\Adminhtml\modulename\Grid.php In this file just find function _prepareColumns() and there you define your column like $this->addColumn('name',array('header'=>'Mage::helper('yourmodule')->__('Name'),'type'=> 'date','index' => 'name')); You can just change you column type by changing array element “type”. If you want to change date just change in array ‘type’=>’date’ if you want to change datetime just change in array ‘type’=>’datetime’ There are various column type are available in Magento Admin Grid That are as Follows. date datetime number currency price country concat action options checkbox massaction radio input select text store wrapline...
Default Email Variables In Magento

Default Email Variables In Magento

Default Email Variables In Magento {{var customer}} Will print out all customer information {{var customer.ID}} {{var customer.email}} {{var customer.firstname}} {{var customer.lastname}} {{var customer.name}} {{var customer.password}} {{var customer.created_in}} Store Name {{var customer.dob}} Date of Birth {{var customer.password_hash}} {{var customer.prefix}} {{var customer.middlename}} Initial {{var customer.suffix}} {{var customer.group_id}} {{var customer.taxvat}} {{var customer.store.name}} Name of Store in English {{var customer.store.group.name}} The actual Store’s name (not the Store View’s) //- To subscribe/unsubscribe newsletter: {{var subscriber.getConfirmationLink()}} {{var subscriber.getUnsubscriptionLink()}} {{var subscriber.email}} //- Send to a friend {{var product_image}} {{var name}} Recipient’s Name {{var email}} Recipient’s Email {{var product_name}} Product Name {{var product_url}} Product Url {{var message}} Message Text {{var sender_name}} Sender’s Name {{var sender_email}} Sender’s Email {{var product_image}} Product Image //- Block {{block type='core/template' area='frontend' template='email/order/shipment/track.phtml' shipment=$shipment order=$order}} //- Depend Condition {{depend order.getIsNotVirtual()}} {{/depend}} {{depend salable}} {{/depend}} //- If Condition {{if order.getIsNotVirtual()}} {{else}} {{/if}} For Order Mail {{var order.getShippingAddress().format('html')}} //Items of the shipping address : {{var order.getShippingAddress().getName()}} Get the first and last name {{var order.getShippingAddress().getPrefix()}} {{var order.getShippingAddress().getFirstName()}} {{var order.getShippingAddress().getMiddleName()}} {{var order.getShippingAddress().getLastName()}} {{var order.getShippingAddress().getSuffix()}} {{var order.getShippingAddress().getStreet1()}} {{var order.getShippingAddress().getStreet2()}} {{var order.getShippingAddress().getCity()}} {{var order.getShippingAddress().getRegion()}} {{var order.getShippingAddress().getPostcode()}} {{var order.getShippingAddress().getCountry()}} Get the country’s ID {{var order.getShippingAddress().getCountryModel().getName()}} Get the country’s full name {{var order.getShippingAddress().getRegion()}} {{var order.getShippingAddress().getTelephone()}} //- Other {{var addAllLink}} {{var alertGrid}} {{var billingAddress.format('html')}} {{var checkoutType}} {{var comment}} {{var creditmemo.id}} {{var creditmemo.increment_id}} {{var data.comment}} {{var data.email}} {{var data.name}} {{var data.telephone}} {{var dateAndTime}} {{var invoice.id}} {{var invoice.increment_id}} {{var invoice.created_at}} {{var items}} {{var items_html}} {{var message}} {{var name}} {{var order.customer_email}} {{var order.getBillingAddress().format('html')}} {{var order.getBillingAddress().getName()}} {{var order.getCreatedAtFormated('long')}} {{var order.getCustomerName()}} {{var order.getCustomerFirstname()}} {{var order.getCustomerLastname()}} {{var order.getEmailCustomerNote()}} Currently unknwon how to test this variable for being set/empty {{var order.getShippingDescription()}} {{var order.getStatusLabel()}} {{var order.getStoreGroupName()}} {{var order.id}} {{var order.increment_id}}...