Guest User

Untitled

a guest
Jan 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. Fatal error: Call to a member function getId() on boolean in /home/site/public_html/csv/getAllOrders.php on line 28
  2.  
  3. $orders = Mage::getModel('sales/order')->getCollection()
  4. ->addAttributeToSelect('*')
  5. ->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));
  6.  
  7. foreach ($orders as $order) {
  8.  
  9. foreach ($order->getAllItems() as $item) {
  10.  
  11. echo $item->getName() ." - ";
  12. echo $item->getSku();
  13.  
  14. $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$item->getSku());
  15.  
  16. if($product->getId()){
  17. echo implode(",", $product->getCategoryIds());
  18. }
  19. echo "<br>";
  20. }
  21. echo "<br>*********************<br>";
  22.  
  23.  
  24. }
Add Comment
Please, Sign In to add comment