Doctrine validate-schema PDOexception - doctrine-orm

When I do this step on marco pivetta tutorial
Validate-schema
I have this error :
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'username'#'localhost' (using password: YES)
The problem is, on line command i think my doctrine.local.php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'test',
'charset' => 'utf8',
'driverOptions' => array (1002 => 'SET NAMES utf8'),
)
)
)
)
);
is not loaded for this tool. My $params is empty (Doctrine\DBAL\Driver\PDOMySql\Driver) And _constructPdoDsn return standard $dsn, not my configs params.
My Os is windows 7
I'm working with Zend Framework2 on wamp
and I use Console2 with gitBash for command line.
I'm stuck any help please ?

You need to have cli-config.php in your root.
Here is content of mine:
<?php
date_default_timezone_set('Europe/Prague');
use Zend\Loader\AutoloaderFactory;
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\ServiceManager\ServiceManager;
use Zend\Stdlib\ArrayUtils;
chdir(__DIR__);
class Bootstrap
{
protected static $serviceManager;
protected static $config;
protected static $bootstrap;
public static function init()
{
// Load the user-defined test configuration file, if it exists; otherwise, load
if (is_readable(__DIR__ . '/config/application.config.php')) {
$testConfig = include __DIR__ . '/config/application.config.php';
} else {
//$testConfig = include __DIR__ . '/TestConfig.php.dist';
}
$zf2ModulePaths = array();
if (isset($testConfig['module_listener_options']['module_paths'])) {
$modulePaths = $testConfig['module_listener_options']['module_paths'];
foreach ($modulePaths as $modulePath) {
if (($path = static::findParentPath($modulePath)) ) {
$zf2ModulePaths[] = $path;
}
}
}
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
$zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
static::initAutoloader();
// use ModuleManager to load this module and it's dependencies
$baseConfig = array(
'module_listener_options' => array(
'module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths),
),
);
$config = ArrayUtils::merge($baseConfig, $testConfig);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
\Doctrine\ORM\Tools\Console\ConsoleRunner::run(
new \Symfony\Component\Console\Helper\HelperSet(
array(
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($serviceManager->get('Doctrine\ORM\EntityManager'))
)
)
);
static::$serviceManager = $serviceManager;
static::$config = $config;
}
public static function getServiceManager()
{
return static::$serviceManager;
}
public static function getConfig()
{
return static::$config;
}
protected static function initAutoloader()
{
$vendorPath = static::findParentPath('vendor');
if (is_readable($vendorPath . '/autoload.php')) {
$loader = include $vendorPath . '/autoload.php';
} else {
$zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false));
if (!$zf2Path) {
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
}
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
}
AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' => array(
'autoregister_zf' => true,
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__,
),
),
));
}
protected static function findParentPath($path)
{
$dir = __DIR__;
$previousDir = '.';
while (!is_dir($dir . '/' . $path)) {
$dir = dirname($dir);
if ($previousDir === $dir) return false;
$previousDir = $dir;
}
return $dir . '/' . $path;
}
}
Bootstrap::init();

I found solution....
On windows seven, we have to use this line command (or we can also do this command via index.php in public dir since zf2 2.3.0)
vendor/bin/doctrine-module orm:validate-schema
And, if you use gitBash don't forget if you have tested your APPLICATION_ENV variable in application.config.php like this tutorial
Zf2 advances config setup
do in bash_profile file :
export APPLICATION_ENV="development"
Hope this help someone.
You don't need to have cli-config.php in the root directory to do that.

Related

OpenCart order tracking without login

i'm using opencart 1.5.6.3, i'm trying to display a page with 2 field. 1 field will be use for Email and another field for Order ID. So client can see their order status directly without login.
thanks in advance.
After so much try, I got solution.
Add new file to
catalog> controller> account> guest.php
<?php class ControllerAccountGuest extends Controller {
private $error = array();
public function index() {
$this->language->load('account/guest');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['entry_email'] = $this->language->get('entry_email');
$this->data['entry_ip'] = $this->language->get('entry_ip');
$this->data['entry_order_id'] = $this->language->get('entry_order_id');
$this->data['text_err'] = $this->language->get('text_err');
$this->data['text_ip'] = $this->language->get('text_ip');
$this->data['text_order_id'] = $this->language->get('text_order_id');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('account/guest/info', '', 'SSL');
$this->data['continue'] = $this->url->link('account/guest', '', 'SSL');
if (isset($this->request->get['email'])) {
$this->data['email'] = $this->request->get['email'];
} else {
$this->data['email'] = '';
}
if (isset($this->request->get['ip'])) {
$this->data['ip'] = $this->request->get['ip'];
} else {
$this->data['ip'] = '';
}
if (isset($this->request->get['order_id'])) {
$this->data['order_id'] = $this->request->get['order_id'];
} else {
$this->data['order_id'] = '';
}
// Nacteni chybovych hlaseni
$err = array(
'email' => false,
'ip' => false,
'order_id' => false,
);
if (isset($this->request->get['err'])) {
$err_temp = explode('|', $this->request->get['err']);
foreach ($err_temp as $value) {
$err[$value] = true;
} // foreach
}
$this->data['err'] = $err;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/guest_login.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/guest_login.tpl';
} else {
$this->template = 'default/template/account/guest_login.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
public function info() {
$err = false;
$url = '';
if ( isset($this->request->post['email']) AND strlen($this->request->post['email']) > 4 ) {
$email = $this->request->post['email'];
$url .= '&email=' . $this->request->post['email'];
} else {
$email = '';
$err = ( $err ? $err . '|' . 'email' : 'email' );
}
/*
if (isset($this->request->post['ip'])) {
$ip = $this->request->post['ip'];
$url .= '&ip=' . $this->request->post['ip'];
} else {
$ip = '0';
$err = ( $err ? $err . '|' . 'ip' : 'ip' );
}
*/
if ( isset($this->request->post['order_id']) AND is_numeric($this->request->post['order_id']) ) {
$order_id = $this->request->post['order_id'];
$url .= '&order_id=' . $this->request->post['order_id'];
} else {
$order_id = '0';
$err = ( $err ? $err . '|' . 'order_id' : 'order_id' );
}
if ($err) {
$url .= '&err=' . $err;
$this->redirect($this->url->link('account/guest', 'token=' . $this->session->data['token'] . $url, 'SSL'));
}
$this->language->load('account/guest_history');
$this->load->model('account/guest');
//$order_info = $this->model_account_guest->getOrder($order_id, $email, $ip);
$order_info = $this->model_account_guest->getOrder($order_id, $email);
if ($order_info) {
$this->document->setTitle($this->language->get('text_order'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('text_order');
$this->data['text_order_detail'] = $this->language->get('text_order_detail');
$this->data['text_invoice_no'] = $this->language->get('text_invoice_no');
$this->data['text_order_id'] = $this->language->get('text_order_id');
$this->data['text_date_added'] = $this->language->get('text_date_added');
$this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
$this->data['text_shipping_address'] = $this->language->get('text_shipping_address');
$this->data['text_payment_method'] = $this->language->get('text_payment_method');
$this->data['text_payment_address'] = $this->language->get('text_payment_address');
$this->data['text_history'] = $this->language->get('text_history');
$this->data['text_comment'] = $this->language->get('text_comment');
$this->data['text_action'] = $this->language->get('text_action');
$this->data['text_selected'] = $this->language->get('text_selected');
$this->data['text_reorder'] = $this->language->get('text_reorder');
$this->data['text_return'] = $this->language->get('text_return');
$this->data['column_name'] = $this->language->get('column_name');
$this->data['column_model'] = $this->language->get('column_model');
$this->data['column_quantity'] = $this->language->get('column_quantity');
$this->data['column_price'] = $this->language->get('column_price');
$this->data['column_total'] = $this->language->get('column_total');
$this->data['column_date_added'] = $this->language->get('column_date_added');
$this->data['column_status'] = $this->language->get('column_status');
$this->data['column_comment'] = $this->language->get('column_comment');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('account/order/info', 'order_id=' . $order_id , 'SSL');
if ($order_info['invoice_no']) {
$this->data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
} else {
$this->data['invoice_no'] = '';
}
$this->data['order_id'] = $order_id ;
$this->data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
if ($order_info['shipping_address_format']) {
$format = $order_info['shipping_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
'company' => $order_info['shipping_company'],
'address_1' => $order_info['shipping_address_1'],
'address_2' => $order_info['shipping_address_2'],
'city' => $order_info['shipping_city'],
'postcode' => $order_info['shipping_postcode'],
'zone' => $order_info['shipping_zone'],
'zone_code' => $order_info['shipping_zone_code'],
'country' => $order_info['shipping_country']
);
$this->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$this->data['shipping_method'] = $order_info['shipping_method'];
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['payment_firstname'],
'lastname' => $order_info['payment_lastname'],
'company' => $order_info['payment_company'],
'address_1' => $order_info['payment_address_1'],
'address_2' => $order_info['payment_address_2'],
'city' => $order_info['payment_city'],
'postcode' => $order_info['payment_postcode'],
'zone' => $order_info['payment_zone'],
'zone_code' => $order_info['payment_zone_code'],
'country' => $order_info['payment_country']
);
$this->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
$this->data['payment_method'] = $order_info['payment_method'];
$this->data['products'] = array();
$products = $this->model_account_guest->getOrderProducts($order_id );
foreach ($products as $product) {
$option_data = array();
$options = $this->model_account_guest->getOrderOptions($order_id , $product['order_product_id']);
foreach ($options as $option) {
if ($option['type'] != 'file') {
$option_data[] = array(
'name' => $option['name'],
'value' => (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']),
);
} else {
$filename = substr($option['value'], 0, strrpos($option['value'], '.'));
$option_data[] = array(
'name' => $option['name'],
'value' => (strlen($filename) > 20 ? substr($filename, 0, 20) . '..' : $filename)
);
}
} // foreach
$this->data['products'][] = array(
'order_product_id' => $product['order_product_id'],
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']),
'selected' => isset($this->request->post['selected']) && in_array($result['order_product_id'], $this->request->post['selected'])
);
}
$this->data['totals'] = $this->model_account_guest->getOrderTotals($order_id );
$this->data['comment'] = $order_info['comment'];
$this->data['histories'] = array();
$results = $this->model_account_guest->getOrderHistories($order_id );
foreach ($results as $result) {
$this->data['histories'][] = array(
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'status' => $result['status'],
'comment' => nl2br($result['comment'])
);
} // foreach
$this->data['continue'] = $this->url->link('account/order', '', 'SSL');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/guest_history.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/guest_history.tpl';
} else {
$this->template = 'default/template/account/guest_history.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
} else {
$this->document->setTitle($this->language->get('text_order'));
$this->data['heading_title'] = $this->language->get('text_order');
$this->data['text_error'] = $this->language->get('text_error');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->data['continue'] = $this->url->link('account/order', '', 'SSL');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
$this->template = 'default/template/error/not_found.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}} // info
private function validate() {
if (!isset($this->request->post['selected']) || !isset($this->request->post['action']) || !$this->request->post['action']) {
$this->error['warning'] = $this->language->get('error_warning');
}
if (!$this->error) {
return true;
} else {
return false;
}
} // validate } ?>
Add another new file to catalog> model> account> guest.php
<?php class ModelAccountGuest extends Model { //public function getOrder($order_id, $email, $ip) { public function getOrder($order_id, $email) {
$order_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "order`
WHERE order_id = '" . (int)$order_id . "'
AND email = '" . $this->db->escape($email) . "'
AND order_status_id > '0'
"); // AND ip = '" . $this->db->escape($ip) . "'
if ($order_query->num_rows) {
$country_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "country`
WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'
");
if ($country_query->num_rows) {
$shipping_iso_code_2 = $country_query->row['iso_code_2'];
$shipping_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$shipping_iso_code_2 = '';
$shipping_iso_code_3 = '';
}
$zone_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "zone`
WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'
");
if ($zone_query->num_rows) {
$shipping_zone_code = $zone_query->row['code'];
} else {
$shipping_zone_code = '';
}
$country_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "country`
WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'
");
if ($country_query->num_rows) {
$payment_iso_code_2 = $country_query->row['iso_code_2'];
$payment_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$payment_iso_code_2 = '';
$payment_iso_code_3 = '';
}
$zone_query = $this->db->query("
SELECT *
FROM `" . DB_PREFIX . "zone`
WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'
");
if ($zone_query->num_rows) {
$payment_zone_code = $zone_query->row['code'];
} else {
$payment_zone_code = '';
}
return array(
'order_id' => $order_query->row['order_id'],
'invoice_no' => $order_query->row['invoice_no'],
'invoice_prefix' => $order_query->row['invoice_prefix'],
'store_id' => $order_query->row['store_id'],
'store_name' => $order_query->row['store_name'],
'store_url' => $order_query->row['store_url'],
'customer_id' => $order_query->row['customer_id'],
'firstname' => $order_query->row['firstname'],
'lastname' => $order_query->row['lastname'],
'telephone' => $order_query->row['telephone'],
'fax' => $order_query->row['fax'],
'email' => $order_query->row['email'],
'shipping_firstname' => $order_query->row['shipping_firstname'],
'shipping_lastname' => $order_query->row['shipping_lastname'],
'shipping_company' => $order_query->row['shipping_company'],
'shipping_address_1' => $order_query->row['shipping_address_1'],
'shipping_address_2' => $order_query->row['shipping_address_2'],
'shipping_postcode' => $order_query->row['shipping_postcode'],
'shipping_city' => $order_query->row['shipping_city'],
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
'shipping_zone' => $order_query->row['shipping_zone'],
'shipping_zone_code' => $shipping_zone_code,
'shipping_country_id' => $order_query->row['shipping_country_id'],
'shipping_country' => $order_query->row['shipping_country'],
'shipping_iso_code_2' => $shipping_iso_code_2,
'shipping_iso_code_3' => $shipping_iso_code_3,
'shipping_address_format' => $order_query->row['shipping_address_format'],
'shipping_method' => $order_query->row['shipping_method'],
'payment_firstname' => $order_query->row['payment_firstname'],
'payment_lastname' => $order_query->row['payment_lastname'],
'payment_company' => $order_query->row['payment_company'],
'payment_address_1' => $order_query->row['payment_address_1'],
'payment_address_2' => $order_query->row['payment_address_2'],
'payment_postcode' => $order_query->row['payment_postcode'],
'payment_city' => $order_query->row['payment_city'],
'payment_zone_id' => $order_query->row['payment_zone_id'],
'payment_zone' => $order_query->row['payment_zone'],
'payment_zone_code' => $payment_zone_code,
'payment_country_id' => $order_query->row['payment_country_id'],
'payment_country' => $order_query->row['payment_country'],
'payment_iso_code_2' => $payment_iso_code_2,
'payment_iso_code_3' => $payment_iso_code_3,
'payment_address_format' => $order_query->row['payment_address_format'],
'payment_method' => $order_query->row['payment_method'],
'comment' => $order_query->row['comment'],
'total' => $order_query->row['total'],
'order_status_id' => $order_query->row['order_status_id'],
'language_id' => $order_query->row['language_id'],
'currency_id' => $order_query->row['currency_id'],
'currency_code' => $order_query->row['currency_code'],
'currency_value' => $order_query->row['currency_value'],
'date_modified' => $order_query->row['date_modified'],
'date_added' => $order_query->row['date_added'],
'ip' => $order_query->row['ip']
);
} else {
return false;
}
} // getOrder
public function getOrderProducts($order_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_product
WHERE order_id = '" . (int)$order_id . "'
");
return $query->rows;
} // getOrderProducts
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_option
WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'
");
return $query->rows;
} // getOrderOptions
public function getOrderTotals($order_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_total
WHERE order_id = '" . (int)$order_id . "'
ORDER BY sort_order
");
return $query->rows;
} // getOrderTotals
public function getOrderHistories($order_id) {
$query = $this->db->query("
SELECT date_added, os.name AS status, oh.comment, oh.notify
FROM " . DB_PREFIX . "order_history oh
LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id
WHERE oh.order_id = '" . (int)$order_id . "'
AND os.language_id = '" . (int)$this->config->get('config_language_id') . "'
ORDER BY oh.date_added
"); // AND oh.notify = '1'
return $query->rows;
} // getOrderHistories
public function getOrderDownloads($order_id) {
$query = $this->db->query("
SELECT *
FROM " . DB_PREFIX . "order_download
WHERE order_id = '" . (int)$order_id . "'
ORDER BY name
");
return $query->rows;
} // getOrderDownloads
public function getTotalOrders() {
$query = $this->db->query("
SELECT COUNT(*) AS total
FROM `" . DB_PREFIX . "order`
WHERE customer_id = '" . (int)$this->customer->getId() . "' AND order_status_id > '0'
");
return $query->row['total'];
} // getTotalOrders
public function getTotalOrderProductsByOrderId($order_id) {
$query = $this->db->query("
SELECT COUNT(*) AS total
FROM " . DB_PREFIX . "order_product
WHERE order_id = '" . (int)$order_id . "'
");
return $query->row['total'];
} // getTotalOrderProductsByOrderId } // class ?>
Now add language file to catalog> language> english> account>
<?php // Heading $_['heading_title'] = 'Order Tracking'; // Text $_['text_account'] = 'Account'; // Entry $_['entry_email'] = 'E-Mail Address:'; $_['entry_ip'] = 'IP Address:'; $_['entry_order_id'] = 'Order Number:'; $_['text_err'] = '<span style="color:red;"> <<< </span>'; $_['text_ip'] = 'eg. 123.345.456.678 - Find this on you order email in the \'Order Details\' section:'; $_['text_order_id'] = 'eg. 123 - Find this on you order email in the \'Order Details\' section:'; // Error $_['error_login'] = 'Warning: No match for E-Mail Address and/or Order Number.'; ?>
Now add tlp file to catalog> view> theme> default> template> account> guest_login.tlp with form action and submit button then add this java script:
<script type="text/javascript"><!-- $('#login input').keydown(function(e) {
if (e.keyCode == 13) {
$('#login').submit();
} }); //--></script>
Now add another file to show result. Catalog> view> theme> default> template> account> guest_history.tlp
Checked in OpenCart 1.5.6.3 with custom theme.

Opencart Info Page

OK, I have been searching for quite some time, and this has me baffled.
I'm trying to add an ad that will pull up more info in the main content section.
If you look at http://teachingforapples.com/ , you'll see 2 links below the orange ad on the left. The only difference between those links is the information ID. However, they behave very differently. The one that says 'about' opens inside the main content area, but the one that says 'referral' opens full window.
There's nothing in the document content that would change this behavior.
The links are made exactly the same in the code except for the ID #.
The generated code shows the same kind of link, neither one has a target attrib.
I can't find anything in any of the modules that has logic code that looks at the doc id #.
So, I started looking at the database. I looked at all the information tables, but don't see anything different between the 2 pages.
Can someone point me in the right direction please? I feel that it must be something simple, but I just can't find it.
Thanks
P.S. the Information module is NOT installed.
Here's the information.php file.
<?php
class ControllerInformationInformation extends Controller {
public function index() {
$this->language->load('information/information');
$this->load->model('catalog/information');
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
if (isset($this->request->get['information_id'])) {
$information_id = (int)$this->request->get['information_id'];
} else {
$information_id = 0;
}
$information_info = $this->model_catalog_information->getInformation($information_id);
if ($information_info) {
$this->document->setTitle($information_info['title']);
$this->data['breadcrumbs'][] = array(
'text' => $information_info['title'],
'href' => $this->url->link('information/information', 'information_id=' . $information_id),
'separator' => $this->language->get('text_separator')
);
$this->data['info_id'] = $information_id;
$this->data['heading_title'] = $information_info['title'];
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['description'] = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
$this->data['continue'] = $this->url->link('common/home');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/information.tpl')) {
$this->template = $this->config->get('config_template') . '/template/information/information.tpl';
} else {
$this->template = 'default/template/information/information.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
} else {
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_error'),
'href' => $this->url->link('information/information', 'information_id=' . $information_id),
'separator' => $this->language->get('text_separator')
);
$this->document->setTitle($this->language->get('text_error'));
$this->data['heading_title'] = $this->language->get('text_error');
$this->data['text_error'] = $this->language->get('text_error');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = $this->url->link('common/home');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
$this->template = 'default/template/error/not_found.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
public function info() {
$this->load->model('catalog/information');
if (isset($this->request->get['information_id'])) {
$information_id = (int)$this->request->get['information_id'];
} else {
$information_id = 0;
}
$information_info = $this->model_catalog_information->getInformation($information_id);
if ($information_info) {
$output = '<html dir="ltr" lang="en">' . "\n";
$output .= '<head>' . "\n";
$output .= ' <title>' . $information_info['title'] . '</title>' . "\n";
$output .= ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
$output .= ' <meta name="robots" content="noindex">' . "\n";
$output .= '</head>' . "\n";
$output .= '<body>' . "\n";
$output .= ' <h1>' . $information_info['title'] . '</h1>' . "\n";
$output .= html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8') . "\n";
$output .= ' </body>' . "\n";
$output .= '</html>' . "\n";
$this->response->setOutput($output);
}
}
}
?>

Activation form does not fully work

i hope someone can help with this. At one point i thought i had this working but cannot figure out why it is not.
The script below does everything but include the Zend_Json::encode. It saves the user in the database it emails the person a link, however the link does not have the encryption included with it.
thanks for your help!
public function contribjoinAction()
{
$request = $this->getRequest();
$conn = XXX_Db_Connection::factory()->getMasterConnection();
$userDao = XXX_Model_Dao_Factory::getInstance()->setModule('core')->getUserDao();
$userDao->setDbConnection($conn);
if ($request->isPost()) {
$fullname = $request->getPost('full_name');
$username = $request->getPost('username');
$password = $request->getPost('password');
$password2 = $request->getPost('confirmPassword');
$email = $request->getPost('email');
$islegal = $request->getPost('islegal');
$user = new Core_Models_User(array(
'user_name' => $username,
'password' => $password,
'full_name' => $fullname,
'email' => $email,
'is_active' => 0,
'created_date' => date('Y-m-d H:i:s'),
'logged_in_date' => null,
'is_online' => 0,
'role_id' => 2,
'islegal' => $islegal,
));
$id = $userDao->add($user);
$templateDao = XXX_Model_Dao_Factory::getInstance()->setModule('mail')->getTemplateDao();
$templateDao->setDbConnection($conn);
$template = $templateDao->getByName(Mail_Models_Template::TEMPLATE_ACTIVATE_CONTRIBUTOR);
if ($template == null) {
$message = sprintf($this->view->translator('auth_mail_template_not_found'), Mail_Models_Template::TEMPLATE_ACTIVATE_CONTRIBUTOR);
throw new Exception($message);
}
$search = array(Mail_Models_Mail::MAIL_VARIABLE_EMAIL, Mail_Models_Mail::MAIL_VARIABLE_USERNAME);
$replace = array($user->email, $user->user_name);
$subject = str_replace($search, $replace, $template->subject);
$content = str_replace($search, $replace, $template->body);
/**
* Replace the reset password link
* #TODO: Add security key?
*/
$encodedLink = array(
'email' => $email,
'user_name' => $username,
);
$encodedLink = base64_encode(urlencode(Zend_Json::encode($encodedLink)));
$link = $this->view->serverUrl() . $this->view->url(array('encoded_link' => $encodedLink), 'core_user_emailactivate');
$content = str_replace('%activate_link%', $link, $content);
/**
* Get mail transport instance
*/
$transport = Mail_Services_Mailer::getMailTransport();
$mail = new Zend_Mail();
$mail->setFrom($template->from_mail, $template->from_name)
->addTo($user->email, $user->user_name)
->setSubject($subject)
->setBodyHtml($content)
->send($transport);
if ($id > 0) {
$this->_helper->getHelper('FlashMessenger')
->addMessage($this->view->translator('user_join_success'));
$this->_redirect($this->view->serverUrl() . $this->view->url(array(), 'core_user_contribjoin'));
}
}
}
I have found the error. I somehow did not put the variable encoded_link into the .ini file for that module under routes.

Doctrine findBy 'does not equal'

How do I do
WHERE id != 1
In Doctrine?
I have this so far
$this->getDoctrine()->getRepository('MyBundle:Image')->findById(1);
But how do I do a "do not equals"?
This maybe daft, but I cannot find any reference to this?
Thanks
There is now a an approach to do this, using Doctrine's Criteria.
A full example can be seen in How to use a findBy method with comparative criteria, but a brief answer follows.
use \Doctrine\Common\Collections\Criteria;
// Add a not equals parameter to your criteria
$criteria = new Criteria();
$criteria->where(Criteria::expr()->neq('prize', 200));
// Find all from the repository matching your criteria
$result = $entityRepository->matching($criteria);
There is no built-in method that allows what you intend to do.
You have to add a method to your repository, like this:
public function getWhatYouWant()
{
$qb = $this->createQueryBuilder('u');
$qb->where('u.id != :identifier')
->setParameter('identifier', 1);
return $qb->getQuery()
->getResult();
}
Hope this helps.
To give a little more flexibility I would add the next function to my repository:
public function findByNot($field, $value)
{
$qb = $this->createQueryBuilder('a');
$qb->where($qb->expr()->not($qb->expr()->eq('a.'.$field, '?1')));
$qb->setParameter(1, $value);
return $qb->getQuery()
->getResult();
}
Then, I could call it in my controller like this:
$this->getDoctrine()->getRepository('MyBundle:Image')->findByNot('id', 1);
Based on the answer from Luis, you can do something more like the default findBy method.
First, create a default repository class that is going to be used by all your entities.
/* $config is the entity manager configuration object. */
$config->setDefaultRepositoryClassName( 'MyCompany\Repository' );
Or you can edit this in config.yml
doctrine:
orm:
default_repository_class: MyCompany\Repository
Then:
<?php
namespace MyCompany;
use Doctrine\ORM\EntityRepository;
class Repository extends EntityRepository {
public function findByNot( array $criteria, array $orderBy = null, $limit = null, $offset = null )
{
$qb = $this->getEntityManager()->createQueryBuilder();
$expr = $this->getEntityManager()->getExpressionBuilder();
$qb->select( 'entity' )
->from( $this->getEntityName(), 'entity' );
foreach ( $criteria as $field => $value ) {
// IF INTEGER neq, IF NOT notLike
if($this->getEntityManager()->getClassMetadata($this->getEntityName())->getFieldMapping($field)["type"]=="integer") {
$qb->andWhere( $expr->neq( 'entity.' . $field, $value ) );
} else {
$qb->andWhere( $expr->notLike( 'entity.' . $field, $qb->expr()->literal($value) ) );
}
}
if ( $orderBy ) {
foreach ( $orderBy as $field => $order ) {
$qb->addOrderBy( 'entity.' . $field, $order );
}
}
if ( $limit )
$qb->setMaxResults( $limit );
if ( $offset )
$qb->setFirstResult( $offset );
return $qb->getQuery()
->getResult();
}
}
The usage is the same than the findBy method, example:
$entityManager->getRepository( 'MyRepo' )->findByNot(
array( 'status' => Status::STATUS_DISABLED )
);
I solved this rather easily (without adding a method) so i'll share:
use Doctrine\Common\Collections\Criteria;
$repository->matching( Criteria::create()->where( Criteria::expr()->neq('id', 1) ) );
By the way, i'm using the Doctrine ORM module from within Zend Framework 2 and i'm not sure whether this would be compatible in any other case.
In my case, i was using a form element configuration like this: to show all roles except "guest" in a radio button array.
$this->add([
'type' => 'DoctrineModule\Form\Element\ObjectRadio',
'name' => 'roles',
'options' => [
'label' => _('Roles'),
'object_manager' => $this->getEntityManager(),
'target_class' => 'Application\Entity\Role',
'property' => 'roleId',
'find_method' => [
'name' => 'matching',
'params' => [
'criteria' => Criteria::create()->where(
Criteria::expr()->neq('roleId', 'guest')
)
],
],
],
]);
I used the QueryBuilder to get the data,
$query=$this->dm->createQueryBuilder('AppBundle:DocumentName')
->field('fieldName')->notEqual(null);
$data=$query->getQuery()->execute();

I'm getting 'The request must contain the parameter Signature' although I'm actually supplying it

I'm trying the AWS Product Advertisement API in PhP.
Here is the PhP code that I've copied from net.
function callSOAPFunction($function, $array){
$timeStamp = gmdate("Y-m-d\TH:i:s\Z");
//service is always the same, $function is operation
$string = 'AWSECommerceService'.$function.$timeStamp;
$signature = base64_encode(hash_hmac("sha256", $string, 'MySecretKey', True));
$params = array('Service' => 'AWSECommerceService',
'AssociateTag' => 'Wassup?',
**'Signature' => $signature,**
'AWSAccessKeyId' => 'MyKey'
'Request' => array($array),
'Timestamp' => $timeStamp
);
$client = new
SoapClient("http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl",
array('exceptions' => 0));
return $client->__soapCall($function, array($params));
}
$array = array('Operation' => 'ItemSearchRequest',
'ItemPage' => 3,
'SearchIndex' => 'DVD',
'ResponseGroup' => 'Large',
'Keywords' => 'Karate');
$result = callSOAPFunction("ItemSearch", $array);
Although I'm including the signature parameter, I'm still getting the error.