Beispiel #1
0
 /**
  * Returns SQL header data
  */
 public function getHeader()
 {
     $dbConfig = $this->_read->getConfig();
     $versionRow = $this->_read->fetchRow('SHOW VARIABLES LIKE \'version\'');
     $header = "-- Magento DB backup\n" . "--\n" . "-- Host: {$dbConfig['host']}    Database: {$dbConfig['dbname']}\n" . "-- ------------------------------------------------------\n" . "-- Server version: {$versionRow['Value']}\n\n" . "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n" . "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n" . "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n" . "/*!40101 SET NAMES utf8 */;\n" . "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n" . "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n" . "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n" . "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n";
     return $header;
 }
 protected function getLikeExistItem($newItem, $ignoreTitle = true, $attributeSet = NULL)
 {
     $whereSql = '';
     foreach ($newItem as $key => $value) {
         if ($ignoreTitle && $key == 'title') {
             continue;
         }
         if ($whereSql == '') {
             $whereSql .= ' ';
         } else {
             $whereSql .= ' AND ';
         }
         $whereSql .= ' `' . $key . '` ';
         is_null($value) && ($whereSql .= ' IS NULL ');
         is_string($value) && ($whereSql .= ' = ' . $this->mySqlReadConnection->quote($value) . ' ');
         (is_integer($value) || is_float($value)) && ($whereSql .= ' = ' . $value . ' ');
     }
     $dbSelect = $this->mySqlReadConnection->select()->from($this->tableNameNew, '*');
     $whereSql != '' && $dbSelect->where($whereSql);
     $row = $this->mySqlReadConnection->fetchRow($dbSelect);
     if ($row === false) {
         return NULL;
     }
     if (!is_null($attributeSet)) {
         $templateId = (int) $row['id'];
         $templateType = (int) $attributeSet['template_type'];
         $attributeSetId = (int) $attributeSet['attribute_set_id'];
         $tasTable = Mage::getResourceModel('M2ePro/TemplatesAttributeSets')->getMainTable();
         $dbSelect = $this->mySqlReadConnection->select()->from($tasTable, '*')->where('template_type = ?', $templateType)->where('template_id = ?', $templateId);
         $rowsAttributesSets = $this->mySqlReadConnection->fetchAll($dbSelect);
         if ($rowsAttributesSets === false || count($rowsAttributesSets) != 1) {
             return NULL;
         }
         $rowAttributeSet = $rowsAttributesSets[0];
         if ((int) $rowAttributeSet['attribute_set_id'] != $attributeSetId) {
             return NULL;
         }
     }
     return $row;
 }
Beispiel #3
0
 /**
  * Retrieve table status
  *
  * @param string $tableName
  * @return Varien_Object
  */
 public function getTableStatus($tableName)
 {
     $row = $this->_write->showTableStatus($tableName);
     if ($row) {
         $statusObject = new Varien_Object();
         $statusObject->setIdFieldName('name');
         foreach ($row as $field => $value) {
             $statusObject->setData(strtolower($field), $value);
         }
         $cntRow = $this->_write->fetchRow($this->_write->select()->from($tableName, 'COUNT(1) as rows'));
         $statusObject->setRows($cntRow['rows']);
         return $statusObject;
     }
     return false;
 }
Beispiel #4
0
 /**
  * Retrieve row or field from table by id or string and parent id
  *
  * @param string $table
  * @param string $idField
  * @param string|integer $id
  * @param string $field
  * @param string $parentField
  * @param string|integer $parentId
  * @return mixed|boolean
  */
 public function getTableRow($table, $idField, $id, $field = null, $parentField = null, $parentId = 0)
 {
     if (strpos($table, '/') !== false) {
         $table = $this->getTable($table);
     }
     if (empty($this->_setupCache[$table][$parentId][$id])) {
         $sql = "select * from {$table} where {$idField}=?";
         if (!is_null($parentField)) {
             $sql .= $this->_conn->quoteInto(" and {$parentField}=?", $parentId);
         }
         $this->_setupCache[$table][$parentId][$id] = $this->_conn->fetchRow($sql, $id);
     }
     if (is_null($field)) {
         return $this->_setupCache[$table][$parentId][$id];
     }
     return isset($this->_setupCache[$table][$parentId][$id][$field]) ? $this->_setupCache[$table][$parentId][$id][$field] : false;
 }
Beispiel #5
0
 public function refund(Varien_Object $payment, $amount)
 {
     // fetch order and transaction info
     $order = $payment->getOrder();
     $row = $this->_mysqlr->fetchRow('SELECT * FROM `' . $this->_table . '` WHERE `order_id` = ' . intval($order->entity_id), array(), Zend_Db::FETCH_ASSOC);
     $transaction_id = $row['transaction_id'];
     // fetch payment info
     $mollie = $this->_api->_getMollieAPI();
     $mollie_payment = $mollie->payments->get($transaction_id);
     // attempt a refund
     try {
         $mollie->payments->refund($mollie_payment, $amount);
     } catch (Exception $e) {
         Mage::throwException('Impossible to create a refund for this transaction. Details: ' . $e->getMessage() . '<br />');
     }
     return $this;
 }