Advertisement
rivasalmir

Untitled

Oct 9th, 2019
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.60 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Ysa\Core\Block;
  4.  
  5. use Magento\Framework\View\Element\Template as Template;
  6. use Ysa\Core\Model\Api as RequestApi;
  7. use Magento\Framework\View\Element\Template\Context;
  8. use Ysa\Core\Model\ModelRentacarFinal;
  9.  
  10. class RentacarFinal extends Template
  11. {
  12.     protected $requestApi;
  13.     protected $modelRentacarFinal;
  14.     protected $_rentacarLocationContentFactory;
  15.  
  16.     public function __construct(
  17.         RequestApi $requestApi,
  18.         Context $context,
  19.         ModelRentacarFinal $modelRentacarFinal,
  20.         \Ysa\Core\Model\ResourceModel\RentacarLocationContent\CollectionFactory $rentacarLocationContentFactory,
  21.         array $data = []
  22.     )
  23.     {
  24.         $this->requestApi   = $requestApi;
  25.         $this->modelRentacarFinal = $modelRentacarFinal;
  26.         parent::__construct($context,$data);
  27.         $this->_rentacarLocationContentFactory = $rentacarLocationContentFactory;
  28.     }
  29.  
  30.     public function getRentaCarFinal()
  31.     {
  32.         $planCode    = $this->getRequest()->getParam('planCode');
  33.         $firstname   = $this->getRequest()->getParam('first_name_driver');
  34.         $lastname    = $this->getRequest()->getParam('last_name_driver');
  35.         $telefone    = $this->getRequest()->getParam('telefone');
  36.         $dob         = $this->getRequest()->getParam('nascimentoMotorista');
  37.         $document    = $this->getRequest()->getParam('docMotorista');
  38.         $email       = $this->getRequest()->getParam('email');
  39.         $pais        = $this->getRequest()->getParam('pais');
  40.         $city        = $this->getRequest()->getParam('city');
  41.         $cep         = $this->getRequest()->getParam('cep');
  42.  
  43.         $responseXml = simplexml_load_string($this->modelRentacarFinal->getBookingTransaction($planCode, $firstname, $lastname, $telefone, $dob, $document, $email, $pais, $city, $cep));
  44.         $response = $responseXml->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children();
  45.  
  46.         if($response->count())
  47.         {
  48.             $this->modelRentacarFinal->createProductAndAddCart($response);
  49.             return $response;
  50.         } else {
  51.             return false;
  52.         }
  53.  
  54.     }
  55.  
  56.  
  57.     public function getRentacarLocationByCode($rentacarLocationCode){
  58.  
  59.         $rentacarLocationContentCollection = $this->_rentacarLocationContentFactory->create();
  60.         $rentacarLocationContentCollection->addFieldToFilter('code', ['eq' => $rentacarLocationCode]);
  61.         $rentacarLocationContentCollection->setPageSize(10);
  62.         $rentacarLocationContentCollection->getSelect()->__toString();
  63.  
  64.         return $rentacarLocationContentCollection->toArray();
  65.     }    
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement