09-10-2012, 03:06 PM
Herkese iyi günler ajax aramada fiyatı gösterdim fakat birimi ve basamak göstermede sıkıntı yaşıyorum normal fiyat düzenleme kısmını da ekleyince hata veriyor nasıl çözebilirim
Kod Aşağıdaki gibidir.
Kod Aşağıdaki gibidir.
PHP Kod:
<modification>
<id>Very simple AJAX live search</id>
<version>1.0.0</version>
<vqmver>1.2.3</vqmver>
<author>n[oO]ne</author>
<file name="catalog/view/theme/default/template/common/footer.tpl">
<operation>
<search position="before">
<![CDATA[</body>]]>
</search>
<add>
<![CDATA[<script type="text/javascript" src="catalog/view/javascript/livesearch.js"></script>]]>
</add>
</operation>
</file>
<file name="catalog/view/theme/default/template/common/header.tpl">
<operation>
<search position="before">
<![CDATA[<?php echo $google_analytics; ?>]]>
</search>
<add>
<![CDATA[<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/livesearch.css" />]]>
</add>
</operation>
</file>
<file name="catalog/controller/product/search.php">
<operation>
<search position="bottom" offset="2">
<![CDATA[]]>
</search>
<add>
<![CDATA[
public function ajax()
{
// Contains results
$data = array();
if( isset($this->request->get['keyword']) ) {
// Parse all keywords to lowercase
$keywords = strtolower( $this->request->get['keyword'] );
// Perform search only if we have some keywords
if( strlen($keywords) >= 3 ) {
$parts = explode( ' ', $keywords );
$add = '';
// Generating search
foreach( $parts as $part ) {
$add .= ' AND (LOWER(pd.name) LIKE "%' . $this->db->escape($part) . '%"';
$add .= ' OR LOWER(p.price) LIKE "%' . $this->db->escape($part) . '%")';
}
$add = substr( $add, 4 );
$sql = 'SELECT pd.product_id, pd.name, p.price FROM ' . DB_PREFIX . 'product_description AS pd ';
$sql .= 'LEFT JOIN ' . DB_PREFIX . 'product AS p ON p.product_id = pd.product_id ';
$sql .= 'LEFT JOIN ' . DB_PREFIX . 'product_to_store AS p2s ON p2s.product_id = pd.product_id ';
$sql .= 'WHERE ' . $add . ' AND p.status = 1 ';
$sql .= 'AND pd.language_id = ' . (int)$this->config->get('config_language_id');
$sql .= ' AND p2s.store_id = ' . (int)$this->config->get('config_store_id');
$sql .= ' ORDER BY p.sort_order ASC, LOWER(pd.name) ASC, LOWER(p.price) ASC';
$sql .= ' LIMIT 15';
$res = $this->db->query( $sql );
if( $res ) {
$data = ( isset($res->rows) ) ? $res->rows : $res->row;
$this->data['pd.price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
// For the seo url stuff
$basehref = 'product/product&keyword=' . $this->request->get['keyword'] . '&product_id=';
foreach( $data as $key => $values ) {
$data[$key] = array(
'name' => htmlspecialchars_decode($values['name'] . ' (' . $values['price'] . ')', ENT_QUOTES),
'href' => $this->url->link($basehref . $values['product_id'])
);
}
}
}
}
echo json_encode( $data );
}
]]>
</add>
</operation>
</file>
</modification>