1

I would like to create a CSV with product default data and also tier price.

Is it possible to use DataFlow ?

In alternative I would like to use a custom script with direct query to DB, can you help me create this query ?

2
  • I don't know how it is possible to use DataFlow but with direct PHP it is no problem. You just have to join into the catalog_product_entity_tier_price table and have the customer_group_id and the website_id in the ON statement. Then you get a lot rows for every product with the different prices for the groups/website and the qty. Mar 6, 2013 at 10:49
  • Did you try creating a product using tiered pricing then export that product using Dataflows? I would try that then use it as an template. Mar 6, 2013 at 12:59

1 Answer 1

4

Here is the script I use:

    //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";
}
}

Courtesy of http://developerafroz.blogspot.com/2011/05/magento-export-tier-price.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.