Ejemplo n.º 1
0
 /**
  * Saving information about quote
  *
  * @param   \Magento\Log\Model\Visitor $visitor
  * @return  \Magento\Log\Model\Resource\Visitor
  */
 protected function _saveQuoteInfo($visitor)
 {
     $adapter = $this->_getWriteAdapter();
     if ($visitor->getDoQuoteCreate()) {
         $data = new \Magento\Framework\Object(array('quote_id' => (int) $visitor->getQuoteId(), 'visitor_id' => (int) $visitor->getId(), 'created_at' => $this->_date->gmtDate()));
         $bind = $this->_prepareDataForTable($data, $this->getTable('log_quote'));
         $adapter->insert($this->getTable('log_quote'), $bind);
         $visitor->setDoQuoteCreate(false);
     }
     if ($visitor->getDoQuoteDestroy()) {
         /**
          * We have delete quote from log because if original quote was
          * deleted and Mysql restarted we will get key duplication error
          */
         $condition = array('quote_id = ?' => (int) $visitor->getQuoteId());
         $adapter->delete($this->getTable('log_quote'), $condition);
         $visitor->setDoQuoteDestroy(false);
         $visitor->setQuoteId(null);
     }
     return $this;
 }