Below is the code to Magento export tier price of all product to csv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //Magento export tier price of all product to csv require_once 'app/Mage.php' ; umask(0); Mage::app( 'default' ); header( "Content-type:text/octect-stream" ); header( "Content-Disposition:attachment;filename=data.csv" ); $tableName = Mage::getSingleton( 'core/resource' ) ->getTableName( 'catalog_product_entity_tier_price' ); $storeId = Mage::app()->getStore()->getId(); $product = Mage::getModel( 'catalog/product' ); $products = $product ->getCollection()->addStoreFilter( $storeId )->getAllIds(); $fieldname = array ( "store" , "websites" , "attribute_set" , "type" , "sku" , "name" , "tier_price_website" , "tier_price_customer_group" , "tier_price_qty" , "tier_price_price" ); print stripslashes (implode( ',' , $fieldname )) . "\n" ; foreach ( $products as $productid ) { $existingTierPrice = $product ->load( $productid )->tier_price; $sku = $product ->getSku(); $name = $product ->getName(); foreach ( $existingTierPrice as $key => $value ) { $tierarray = array ( "admin" , "base" , "Default" , "simple" , $sku , $name , "all" , "all" , $value [ 'price_qty' ], $value [ 'price' ]); print stripslashes (implode( ',' , $tierarray )) . "\n" ; } } |
No comments:
Post a Comment