2016-04-01 29 views
0

Tamamlanmış sipariş bilgilerini bir CSV dosyasına dışa aktarmayı sağlayan bir uzantı yapıyorum. İhracat için sipariş ve ürün bilgilerine başarılı bir şekilde erişebiliyorum, ancak tanıtım verilerine erişirken sorun yaşıyorum.Magento: Katalog ve cart kural verilerine erişme

İhracatta bu siparişe uygulanan tanıtım verilerini (katalog ve sepet kuralları) dahil etmeyi düşünüyorum. Özellikle, belirli siparişlerin bir listesi için kural kimliğine, adlara, açıklamalara, kodlara ve uygulanan dolar miktarına erişmeye çalışıyorum.

Uzantımdaki tanıtım verilerine nasıl erişebilirim? Şu anda (tarih kare eleme) Uzantımı sipariş/öğe verileri erişiyorum nasıl

burada, yardımcı ise: Eğer sağlayabilir herhangi bir yardım için şimdiden

$rows = array(); // array to hold data that will be exported to CSV 
$read = Mage::getSingleton('core/resource')->getConnection('core_read'); 
$orders = $read->query("SELECT entity_id FROM sales_flat_order WHERE created_at >= '$from' AND created_at < '$today'"); 
while ($row = $orders->fetch()) { 
    $order = Mage::getModel('sales/order')->load($row['entity_id']); 
    $order_items = $read->query("SELECT item_id FROM sales_flat_order_item WHERE order_id={$order->getId()}"); 
    while ($item_row = $order_items->fetch()) { 
     $item = Mage::getModel('sales/order_item')->load($item_row['item_id']); 
     $rows[] = array(
     $order->getRealOrderId(), 
     $order->getCreatedAt(), 
     $item->getSky(), 
     $item->getQtyOrdered(), 
     .....); 
    ); // end item loop 
); // end order loop  

sayesinde

-Mark

cevap

0

Bu sorunun geçmişte başka bir soruda yanıtlandığını düşünüyorum. Sen .. asıl soruya bağlantıyı bulmak ve burada olsa o cevap itibaren Magento - get price rules from order

cevap verebilir

//The order I want to check 
$order_id = 859; 

//Get the list of items for your order 
$items = Mage::getModel('sales/order_item') 
->getCollection() 
->addFilter('order_id',array('eq'=>$order_id)); 

//loop through each item 
foreach($items as $item){ 

    //if the item has not had a rule applied to it skip it 
    if($item->getAppliedRuleIds() == '')continue; 

    /* 
    * I cant remember in the database they might be comma separated or space if multiple rules were applied 
    * the getAppliedRuleIds() function is the one you want 
    */ 
    foreach(explode(",",$item->getAppliedRuleIds()) as $ruleID){   

     //Load the rule object 
     $rule = Mage::getModel('catalogrule/rule')->load($ruleID); 

     // Throw out some information like the rule name what product it was applied to 

     echo "<p>".$item->getSku()." had rule ".$rule->getName()."(".$item->getAppliedRuleIds().") applied </p>"; 
    } 

}