Skip to main content

Posts

Magento :: How to update products' attributes correctly without affecting tier prices

I use following code to update magento products without effecting tier prices. Because my earlier code cleared all tier prices after run code. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);     $id = Mage::getModel('catalog/product')->getIdBySku($prod_sku);     $product = Mage::getModel('catalog/product')->load($id);     if ($product) {       $product->setBarcode($bar_code);       if(! $product->save()){                 $productId = $product->getId();                 echo "product_Id :: ".$productId." - Product sku :: ".$product->getSku()."<br />";             }else{                 echo "not saved";             }      }

Magento :: Inline Translations - How to edit text field using in line translations

To enable inline translations, go to System -> Configurations Go to Advanced section Enable inline translation for front end Refresh page and see dashed boxes to change text as follows Click on the highlighted icon in above images. Following window will appear. Change and submit.

Magento : Password encryption for customer data import

I had to transfer k-ecommerce customer data to magento. I created csv file according to magento customer data upload csv that I got from data profile -> export customer profile. But there was a problem to encrypt password to match with magento. I googled and found this. I will share with others for their reference. Thanks Edward // Change the paths according to your environment require_once 'app/Mage.php'; umask(0); $app = Mage::app('default'); // Instantiate the core encryption model $obj = Mage::getModel('core/encryption'); // Instantiate the core helper $helper = Mage::helper('core'); //Set the encryptions helper $obj->setHelper($helper); // Get the password's hash $enc_pwd = $obj->getHash($pwd, 2); // To validate password, use this. It will return 1 if it is correct echo $obj->validateHash($pwd, $enc_pwd);

Magento - Dataflow - Profiles : How to check failed products in import all product

I have created CSV file and run profile. Some products failed due to image not found issue. I wanted to find out which products have failed in the process. I googled but not found a solution. Finally I used firebug and found failed row number as follows

Magento - Tier Prices on Cart page

Add following after $_item = $this->getItem() ; in checkout/cart/item/default.phtml $_tierPricing = $this->getLayout()->createBlock('catalog/product_view', 'product.tierprices', array( 'product_id' => $_item->getProductId())); $_tierPricing->setTemplate('catalog/product/view/tierprices.phtml'); To print price info: <?php echo $_tierPricing->getTierPriceHtml();?> OR If you want retrieve tier prices for any other purposes, just for show discounts etc. Use followings. $custom = Mage::getModel('catalog/product')->load($_item->getProductId());  var_dump($custom->getTierPrice());

How to get Multiple counts based on different criteria in MySQL

I wanted to retrieve multiple counts in same table on different criteria. The sum of 1's works same as count where our expression is true. :-) SELECT sum(approved = 1) as visible_prop_count, sum(approved = 2) as private_prop_count, sum(approved = 3) as pending_app_prop_count, sum(featured_property=1) as featured_prop_count, sum(approved = 0) as draft FROM `jos_mypod_property` WHERE 1 visible_prop_count private_prop_count pending_app_prop_count featured_prop_count draft 4 0 0 4 1

Install MySQL as a service

Install the server as a service using this command: C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install Install the server as a service using this command: C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --remove Start Mysql from command prompt using net command: NET START MySQL Stop Mysql from command prompt using net command: NET STOP MySQL -- Thanks & Regards, Chamath Gunasekara