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 ?

  • 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. – Fabian Blechschmidt Mar 6 '13 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. – Thomas Mongan Mar 6 '13 at 12:59
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, privacy policy and cookie policy

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