Skip to main content

Posts

Reviews import in magento using csv file

I have task with reviews import using csv.I have csv of all reviews so i need to import reviews in our site i written code for import reviews programatically. i crearted one file in magento root directory (reviewsimport.php) in that file i written the below code <?php // Invoke the Magento environment require_once 'app/Mage.php'; Mage::app(); $fp = fopen("latestreviews.csv", 'r'); $count = 1; while ($line = fgetcsv($fp)) {     $product_id = Mage::getModel("catalog/product")->getIdBySku($line[2]);     $customer = Mage::getModel("customer/customer");     $customer->setWebsiteId(Mage::app()->getWebsite()->getId());     $customer->loadByEmail($line[3]);     $review = Mage::getModel('review/review');     $review->setEntityPkValue($product_id); //product id      $review->setStatusId(1);     $review->setTitle($line[2]);     $review->setDetail($lin...

Orders Import using csv and update existing orders

Ever wondered how to import bulk orders programatically? I want import orders using .csv i tried so many sites but i unable get anything related to import using csv i got it by creating programatically. So i tried csv bulk import orders because i have 60K orders so order creation is difficult i have orders data csv.So that i prepared csv and i wrote code related to orders import.Below is code  Copy the below code and create one file in your magento root directory(magento/ordersimports.php)paste the code into the file ........ Next prepare accordingly  ordersimports.csv this csv file also you can place root directory (magento/ordersimports.csv)  after that go to your site in browser run file like this  www.magento.com/ ordersimports.php <?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); require_once 'app/Mage.php'; umask(0); Mage::app('default'); $arr = array(); if (($handle = fopen("ordersimports.csv"...
Combine products of 2 categories in to one category I created 4 categories. Category 1, 2 , 3, 4 all have 50 + 50 + 50 + 50 products, I created category 5 and category 6 , I want to add products of "category 1 & 2" to Category 5 I want to add products of "category 3 & 4" to Category 6. below is the solution for this in magento site. $category1Id = 1; $category2Id = 2; $category5Id = 5; //get the category instances $category1 = Mage::getModel('catalog/category')->load($category1Id); $category2 = Mage::getModel('catalog/category')->load($category2Id); $category5 = Mage::getModel('catalog/category')->load($category5Id); //get products from the first 2 categories $category1Products = $category1->getProductsPosition(); $category2Products = $category2->getProductsPosition(); //merge the products into one big array $merged = array_merge($category1Products, $category2Products); //assigned the merged products t...

get Active shipping methods and payment methods

Active Shipping methods $activeCarriers = Mage::getSingleton('shipping/config')->getActiveCarriers();             // $allCarriers = array();             foreach ($activeCarriers as $carrierCode => $carrierModel) {                 $allCarriers[$carrierCode] = array('value' =>  Mage::getStoreConfig('carriers/' . $carrierCode . '/title'), 'label' => Mage::getStoreConfig('carriers/' . $carrierCode . '/title')); Or ( $allCarriers[$carrierCode] = array('value' =>  $carrierCode,  'label' => Mage::getStoreConfig('carriers/' . $carrierCode . '/title'));             }             return $allCarriers; Active Payment methods $payments = Mage::getSingleton('payment/config')->getActiveMethods();             $payMethods = array();         ...

get product group names and attribute set name by loading attbute set id

get product group names and attribute set name by loading attbute set id $product = Mage::getModel('catalog/product')->load(16);        //attribute set model.         $model = Mage::getModel('eav/entity_attribute_set');        // product attribute set id.         $attributeSetId = $product->getAttributeSetId();         $attributeSet = $model->load($attributeSetId);          // This is attribute set name.         $attributeSetName = $attributeSet->getAttributeSetName(); $groups = Mage::getModel('eav/entity_attribute_group') ->getResourceCollection() ->setAttributeSetFilter($attributeSetId) ->setSortOrder() ->load(); foreach ($groups as $group)  echo $groupName          = $group->getAttributeGroupName(); }

order cancel from front end

if you want cancel order from front end create module like this app/etc/modules/<Namespace_Modulename>.xml <config>     <modules>         <Namespace_CustomerOrderCancel>             <active>true</active>             <codePool>community</codePool>             <depends>                 <Mage_Sales />             </depends>         </ Namespace _CustomerOrderCancel>     </modules> </config> app/community/Namespace/Modulename           ------controllers           -------etc           -------Helper if you want cancel button in history page (myorder) need override block file Mage_Sales_Block_Orde...