Domanda

Sto cercando di scaricare dati di ordine (e-mail Nome +) dal mio negozi. Abbiamo un multi-store.

Il problema che ho è che quando si esegue questo codice su STORE 1 o 2 STORE - sia risultato nella piena raccolta degli ordini. Cosa ho bisogno è gli ordini appartenenti a STORE 1 o 2 etc

Il frammento che segue è parte di un PHP nella radice del mio dominio.

Ho provato tutte e tre le opzioni di seguito indicate ...

Mage::app();

[OPTIONS I TRIED]
// ->addAttributeToFilter('store_id', Mage::app()->getStore()->getId())
//->addStoreFilter(Mage::app()->getStore()->getId())
// ->setStoreId(Mage::app()->getStore()->getId())

$orders = Mage::getModel('sales/order')
->getCollection()
[OPTIONS]

Come si può fare?

È stato utile?

Soluzione

Questo dovrebbe funzionare su versioni 1.4.0.1+

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::app($mageRunCode,$mageRunType);
$orders = Mage::getModel('sales/order')
->getCollection()
->addFieldToFilter('store_id', Mage::app()->getStore()->getId())
->addAttributeToFilter('status', Mage_Sales_Model_Order::STATE_COMPLETE)
->addAttributeToSort('entity_id', 'DESC');

echo "<html><body>";

foreach($orders as $order) {
    echo $order->getCustomerName() . "\t" .
    $order->getCustomerEmail() . "\r\n<br />";
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top