2017-12-18 22 views
1

PDFインフォメーションのMagento 1のソリューションを開発中です。請求書には、在庫のある場所でソートされた商品が表示されます。私たちの所在地は全て、A、B、Cなどの文字で始まります。Magento - ロケーション別にPDF請求書の製品を並べ替えます。

アルファベット順に商品を表示したいので、AからZまでの商品を見つけたら上から下へと分かります。私はちょうどこれを解決する方法を理解できませんか?

foreach ($invoice->getAllItems() as $item){ 
    if ($item->getOrderItem()->getParentItem()) { 
     continue; 
    } 
    /* Draw item */ 
    $this->_drawItem($item, $page, $order); 
    $page = end($pdf->pages); 
} 

他の誰もこれを望んでいた可能性があります。 :)

  • お時間をいただきありがとうございます。
+0

配列内のすべての場所をアルファベット順に並べ替えることができます – Cezary

+0

私はその可能性を確信しています。データは、データが送信されるのと同じファイルで処理されません。私は知らないマゼンタでいくつかの関数を呼び出すことは可能ですか?投稿するコードを追加 –

+0

他に誰もこれを望んでいない?注文のためにすべての製品を集めるほうが簡単です。 :) –

答えて

0

私は、Magentoのではなく、私はPHPで、それはあなたのための解決策を見つけた

$response[] = array(
         'product_id' => $stock->product_id, 
         'product_name' => $stock->product_name, 
         'stock_id' => $stock->stock_id, 
         'stock_location' => $stock->stock_location, 

         ); 
        } 

       foreach ($response as $rec) { 
        $stock_location[] = $rec['stock_location']; 
        $title[] = strtolower($rec['product_name']); 
       } 
       //print_r($stock_location); 

       array_multisort($stock_location, SORT_ASC, SORT_NUMERIC, $title, SORT_ASC, SORT_STRING, $response); 

       print_r($response); 
0

を助けるこの.hopeよう試みることをあなたはどのように行うことができますいくつかのアイデアを共有していますことを行うことができます方法を知ってはいけません:

$items = $invoice->getAllItems(); 
     $sortedItems = array(); 

     foreach ($items as $item) { 
      $prod = Mage::getModel('catalog/product')->load($item->getProductId()); 
      $sortedItems[$prod->getStockLocation()] = $item; 
     } 

     ksort($sortedItems); 

     foreach ($sortedItems as $item){ 
      if ($item->getOrderItem()->getParentItem()) { 
       continue; 
      } 
      /* Draw item */ 
      $this->_drawItem($item, $page, $order); 
      $page = end($pdf->pages); 
     } 
関連する問題