Example #1
0
 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::getJson()
  */
 public function getJson($extra = array(), $reset = false)
 {
     $array = $extra;
     if (!$this->isJsonLoaded($reset)) {
         $array['customer'] = $this->getCustomer() instanceof Customer ? $this->getCustomer()->getJson() : array();
         $array['totalDue'] = $this->getTotalDue();
         $array['infos'] = array();
         $array['address']['shipping'] = $this->getShippingAddr() instanceof Address ? $this->getShippingAddr()->getJson() : array();
         $array['address']['billing'] = $this->getBillingAddr() instanceof Address ? $this->getBillingAddr()->getJson() : array();
         foreach ($this->getInfos() as $info) {
             if (!$info instanceof OrderInfo) {
                 continue;
             }
             $typeId = $info->getType()->getId();
             if (!isset($array['infos'][$typeId])) {
                 $array['infos'][$typeId] = array();
             }
             $array['infos'][$typeId][] = $info->getJson();
         }
         $array['status'] = $this->getStatus() instanceof OrderStatus ? $this->getStatus()->getJson() : array();
         $array['shippments'] = array();
         foreach ($this->getShippments() as $shippment) {
             if (!$shippment instanceof Shippment) {
                 continue;
             }
             $array['shippments'][] = $shippment->getJson();
         }
     }
     return parent::getJson($array, $reset);
 }
Example #2
0
 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::getJson()
  */
 public function getJson($extra = array(), $reset = false)
 {
     try {
         $array = $extra;
         if (!$this->isJsonLoaded($reset)) {
             $array['prices'] = array_map(create_function('$a', 'return $a->getJson();'), $this->getPrices());
             $array['manufacturer'] = $this->getManufacturer() instanceof Manufacturer ? $this->getManufacturer()->getJson() : null;
             $array['supplierCodes'] = array_map(create_function('$a', 'return $a->getJson();'), SupplierCode::getAllByCriteria('productId = ?', array($this->getId())));
             $array['productCodes'] = array_map(create_function('$a', 'return $a->getJson();'), ProductCode::getAllByCriteria('productId = ?', array($this->getId())));
             $array['images'] = array_map(create_function('$a', 'return $a->getJson();'), $this->getImages());
             $array['categories'] = array_map(create_function('$a', '$json = $a->getJson(); return $json["category"];'), Product_Category::getCategories($this));
             $array['fullDescriptionAsset'] = ($asset = Asset::getAsset($this->getFullDescAssetId())) instanceof Asset ? $asset->getJson() : null;
             $array['locations'] = array_map(create_function('$a', 'return $a->getJson();'), PreferredLocation::getPreferredLocations($this));
             $array['unitCost'] = $this->getUnitCost();
             $array['priceMatchRule'] = ($i = ProductPriceMatchRule::getByProduct($this)) instanceof ProductPriceMatchRule ? $i->getJson() : null;
             $array['attributeSet'] = ($i = $this->getAttributeSet()) instanceof ProductAttributeSet ? $i->getJson() : null;
             $array['status'] = ($i = $this->getStatus()) instanceof ProductStatus ? $i->getJson() : null;
         }
     } catch (Exception $ex) {
         throw new Exception(' ********** getJson exception :' . $ex->getMessage());
     }
     return parent::getJson($array, $reset);
 }
Example #3
0
 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::getJson()
  */
 public function getJson($extra = array(), $reset = false)
 {
     $array = $extra;
     if (!$this->isJsonLoaded($reset)) {
         $array['product'] = $this->getProduct()->getJson();
         $array['productQtyLog'] = $this->getProductQtyLog()->getJson();
         $array['receivingItem'] = ($receivingItem = $this->getReceivingItem()) instanceof ReceivingItem ? $receivingItem->getJson() : '';
         $array['purchaseOrderItem'] = ($purchaseOrderItem = $this->getPurchaseOrderItem()) instanceof PurchaseOrderItem ? $purchaseOrderItem->getJson() : '';
         $array['orderItem'] = ($orderItem = $this->getOrderItem()) instanceof OrderItem ? $orderItem->getJson() : '';
         $array['creditNoteItem'] = ($creditNoteItem = $this->getCreditNoteItem()) instanceof CreditNoteItem ? $creditNoteItem->getJson() : '';
     }
     return parent::getJson($array, $reset);
 }