/** * Create Label * * @return string * @throws Zend_Pdf_Exception * @throws InvalidArgumentException */ public function render() { $pdf = new Zend_Pdf(); $pdfBuilder = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder(); $template = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page(Zend_Pdf_Page::SIZE_A4_LANDSCAPE); $pdfBuilder->setPage($template)->addProductName((string) $this->_info->ProductShortName)->addProductContentCode((string) $this->_info->ProductContentCode)->addSenderInfo($this->_info->Shipper)->addOriginInfo((string) $this->_info->OriginServiceArea->ServiceAreaCode)->addReceiveInfo($this->_info->Consignee)->addDestinationFacilityCode((string) $this->_info->Consignee->CountryCode, (string) $this->_info->DestinationServiceArea->ServiceAreaCode, (string) $this->_info->DestinationServiceArea->FacilityCode)->addServiceFeaturesCodes()->addDeliveryDateCode()->addShipmentInformation($this->_request->getOrderShipment())->addDateInfo($this->_info->ShipmentDate)->addWeightInfo((string) $this->_info->ChargeableWeight, (string) $this->_info->WeightUnit)->addWaybillBarcode((string) $this->_info->AirwayBillNumber, (string) $this->_info->Barcodes->AWBBarCode)->addRoutingBarcode((string) $this->_info->DHLRoutingCode, (string) $this->_info->DHLRoutingDataId, (string) $this->_info->Barcodes->DHLRoutingBarCode)->addBorder(); $packages = array_values($this->_request->getPackages()); $i = 0; foreach ($this->_info->Pieces->Piece as $piece) { $page = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page($template); $pdfBuilder->setPage($page)->addPieceNumber((int) $piece->PieceNumber, (int) $this->_info->Piece)->addContentInfo($packages[$i])->addPieceIdBarcode((string) $piece->DataIdentifier, (string) $piece->LicensePlate, (string) $piece->LicensePlateBarCode); array_push($pdf->pages, $page); $i++; } return $pdf->render(); }
/** * @param Mage_Shipping_Model_Shipment_Request $request * @return $this */ public function ship(Mage_Shipping_Model_Shipment_Request $request) { $order = $request->getOrderShipment(); $realOrder = $order->getOrder(); $helper = Mage::helper('swisspost_yellowcube'); $locale = Mage::getStoreConfig('general/locale/code', $request->getStoreId()); $locale = explode('_', $locale); $positionItems = array(); foreach ($order->getAllItems() as $item) { $product = Mage::getModel('catalog/product')->load($item->getProductId()); $positionItems[] = array('article_id' => $item->getProductId(), 'article_number' => $item->getSku(), 'article_ean' => $product->getData('yc_ean_code'), 'article_title' => $item->getName(), 'article_qty' => $item->getQty()); } $this->getQueue()->send(Zend_Json::encode(array('action' => self::SYNC_ORDER_WAB, 'store_id' => $request->getStoreId(), 'plant_id' => $this->getHelper()->getPlantId($request->getStoreId()), 'deposit_number' => $this->getHelper()->getDepositorNumber($request->getStoreId()), 'order_id' => $order->getOrderId(), 'order_increment_id' => $realOrder->getIncrementId(), 'order_date' => date('Ymd'), 'partner_type' => Swisspost_YellowCube_Helper_Data::PARTNER_TYPE, 'partner_number' => $this->getHelper()->getPartnerNumber($request->getStoreId()), 'partner_reference' => $this->getHelper()->getPartnerReference($request->getRecipientContactPersonName(), $request->getRecipientAddressPostalCode()), 'partner_name' => $request->getRecipientContactPersonName(), 'partner_name2' => $request->getRecipientContactCompanyName(), 'partner_street' => $request->getRecipientAddressStreet1(), 'partner_name3' => $request->getRecipientAddressStreet2(), 'partner_country_code' => $request->getRecipientAddressCountryCode(), 'partner_city' => $request->getRecipientAddressCity(), 'partner_zip_code' => $request->getRecipientAddressPostalCode(), 'partner_phone' => $request->getRecipientContactPhoneNumber(), 'partner_email' => $request->getRecipientEmail(), 'partner_language' => $locale[0], 'service_basic_shipping' => $helper->getRealCode($request->getShippingMethod()), 'service_additional_shipping' => $helper->getAdditionalShipping($request->getShippingMethod()), 'items' => $positionItems))); return $this; }