2017-12-18 38 views
1

PDF 인보이스 용 Magento 1 솔루션을 개발 중입니다. 인보이스가 stock_location으로 정렬 된 제품을 표시하도록하고 싶습니다. 우리 위치는 모두 문자 lige 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

확실한 확신이 있습니다. 데이터가 전송 될 때 동일한 파일에서 데이터가 처리되지 않습니다. Magento에서 일부 기능을 호출 할 수 있습니까? 게시 된 코드 추가 –

+0

아무도 이걸 원했던가요? 주문을 위해 모든 제품을 수집하는 것이 훨씬 쉽습니다. :) –

답변

0

나는 그러나 젠토에 내가 어떻게 당신이 당신이

$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처럼 PHP에서 보는 것이 할 수있는 몇 가지 아이디어를 공유하고 그렇게 할 수있는 방법을 잘 모릅니다 :

$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); 
     }