Get Current Store Details like ID, Code, Name and Status

Get Current Store Details like ID, Code, Name and Status

// Gets the current store's details $store = Mage::app()->getStore(); // Gets the current store's id $storeId = Mage::app()->getStore()->getStoreId(); // Gets the current store's code $storeCode = Mage::app()->getStore()->getCode(); // Gets the current website's id $websiteId = Mage::app()->getStore()->getWebsiteId(); // Gets the current store's group id $storeGroupId = Mage::app()->getStore()->getGroupId(); // Gets the current store's name $storeName = Mage::app()->getStore()->getName(); // Gets the current store's sort order $storeSortOrder = Mage::app()->getStore()->getSortOrder(); // Gets the current store's status $storeIsActive = Mage::app()->getStore()->getIsActive(); // Gets the current store's locale $storeLocaleCode = Mage::app()->getStore()->getLocaleCode(); // Gets the current store's home url $storeHomeUrl =...
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...