Okay, I provide full codes for my page. Please explain me why it does not save product_id in session?
View:
I sent data by form method post
Code: Select all
<form method="post" action="{{ action_credit }}">
<input type="hidden" name="product_id" id="product_id" value="{{ product_id }}" />
<button class="button btn-cart kredit-type" type="submit" title="{{ kredit_cart }}" ><span>{{ kredit_cart }}</span></button>
</form>
Controller
In "
catalog/controller/product/product.php " added link(because i am testing in product page now)
Code: Select all
$data['action_credit'] = $this->url->link('product/kredit');
Created Controller for page
Code: Select all
class ControllerProductKredit extends Controller {
public function index() {
// error_reporting(0);
if (isset($this->request->post['product_id'])) {
$product_id = $this->request->post['product_id'];
} elseif (isset($this->request->get['product_id'])) {
$product_id = $this->request->get['product_id'];
}
if (!$this->customer->isLogged()) {
if (isset($this->request->post['product_id'])) {
$this->session->data['redirect'] = $this->url->link('product/kredit', 'product_id=' . (int)$this->request->post['product_id'] . '&language=' . $this->config->get('config_language'), true);
} elseif (isset($this->request->get['product_id'])) {
$this->session->data['redirect'] = $this->url->link('product/kredit', 'product_id=' . (int)$this->request->get['product_id'] . '&language=' . $this->config->get('config_language'), true);
}
$this->response->redirect($this->url->link('account/login', '', true));
}
// Optional. This calls for your language file
$this->load->language('product/kredit');
$lccode = (int)$this->config->get('config_language_id');
// Optional. Set the title of your web page
$this->document->setTitle($this->language->get('heading_title'));
// Breadcrumbs for the page
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/static')
);
// Get "heading_title" from language file
$data['heading_title'] = $this->language->get('heading_title');
$data['action_credit_add'] = $this->url->link('product/kredit/add', true);
// All the necessary page elements
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->load->model('kredit/kredit');
$data['product_info'] = $this->model_kredit_kredit->get($product_id, $lccode);
// Load the template file and show output
$this->response->setOutput($this->load->view('product/kredit', $data));
}
}
And
MODEL
Code: Select all
<?php
class ModelKreditKredit extends Model{
public function get($product_id,$lccode){
$query = $this->db->query("select b.name, a.image from " . DB_PREFIX . "product a, " . DB_PREFIX . "product_description b where a.product_id = $product_id and a.product_id = b.product_id and b.language_id = $lccode");
return $query->rows;
}
}