예제 #1
0
파일: Edit.php 프로젝트: aiesh/magento2
 /**
  * Prepare the layout of the address edit block.
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     // Init address object
     if ($addressId = $this->getRequest()->getParam('id')) {
         try {
             $this->_address = $this->_addressService->getAddress($addressId);
         } catch (NoSuchEntityException $e) {
         }
     }
     if (is_null($this->_address) || !$this->_address->getId()) {
         $this->_address = $this->_addressBuilder->setPrefix($this->getCustomer()->getPrefix())->setFirstname($this->getCustomer()->getFirstname())->setMiddlename($this->getCustomer()->getMiddlename())->setLastname($this->getCustomer()->getLastname())->setSuffix($this->getCustomer()->getSuffix())->create();
     }
     if ($headBlock = $this->getLayout()->getBlock('head')) {
         $headBlock->setTitle($this->getTitle());
     }
     if ($postedData = $this->_customerSession->getAddressFormData(true)) {
         if (!empty($postedData['region_id']) || !empty($postedData['region'])) {
             $postedData['region'] = array('region_id' => $postedData['region_id'], 'region' => $postedData['region']);
         }
         $this->_address = $this->_addressBuilder->mergeDataObjectWithArray($this->_address, $postedData);
     }
     return $this;
 }