Matteus Posted October 30, 2013 Report Share Posted October 30, 2013 Получилось. Меняется только в первом случае. Quote Link to post Share on other sites
pavnik Posted November 2, 2013 Report Share Posted November 2, 2013 Сделал по руководству beagler, все работает, спасибо за решение. А как теперь артикул вывести в корзину, подскажите если кто реализовывал или просто знающие Quote Link to post Share on other sites
Rash Posted November 2, 2013 Report Share Posted November 2, 2013 Сделал по руководству beagler, все работает, спасибо за решение. А как теперь артикул вывести в корзину, подскажите если кто реализовывал или просто знающие {$purchase->variant->sku|escape} Quote Link to post Share on other sites
pikasso Posted November 27, 2013 Report Share Posted November 27, 2013 Встречал ранее другое решение меняем запрос на - if(!empty($filter['keyword'])) { $keywords = explode(' ', $filter['keyword']); foreach($keywords as $keyword) $keyword_filter .= $this->db->placehold('AND (p.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") '); } Больше ничего нигде не трогаем. Работает и админке, и по сайту (проверял на 2.1)Подскажите как правельней сделать и куда прописать...а то я запутался и нифига не получилось...Пробовал различные способы... - пытался найти по артиклю...нифига не находит...почитстил все назад Quote Link to post Share on other sites
oep3464 Posted December 10, 2013 Report Share Posted December 10, 2013 на 2.2.4 не работает, жаль...может кто поможет...а то я уже запарился, не могу понять где может быть ошибка Quote Link to post Share on other sites
Foх Posted January 2, 2014 Report Share Posted January 2, 2014 поддерживаю)на 2.2.4 почему то не работает. Quote Link to post Share on other sites
frazer Posted January 23, 2014 Report Share Posted January 23, 2014 А как дополнить поиск по названию категории?В myAdmin данный код все отображает, но в api/Products.php никак не удается модифицировать запрос. SELECT p . * FROM s_products p, s_categories c, s_products_categories pc WHERE p.id = pc.product_id AND c.id = pc.category_id AND c.name = '%keyword%' LIMIT 0 , 30действительно, а как сделать поиск по категориям, и почему в стандарте этого нет(( Quote Link to post Share on other sites
shurikello Posted February 5, 2014 Report Share Posted February 5, 2014 В 2.1.5 работает, только постоянно выдает ошибку: Unknown column 'v.product_id' in 'where clause' [SELECT count(distinct p.id) as count\n\t\t\t\tFROM s_products AS p\n\t\t\t\t\n\t\t\t\tWHERE 1\n\t\t\t\t\t\n\t\t\t\t\tAND v.product_id=p.id AND (v.sku LIKE..... В чем может быть дело? Quote Link to post Share on other sites
Kasha Posted February 5, 2014 Report Share Posted February 5, 2014 В том что вы делаете запрос к таблицам s_products и s_variants а джойна нет ( после from s_products as p должно еще быть JOIN s_variants ON... в общем неправильный запрос...матчасть Quote Link to post Share on other sites
XAHTEP26 Posted March 2, 2014 Report Share Posted March 2, 2014 Недавно заметил, что обычный поиск по ключевым словам криво стал работать (после вышеизложеных изменений) - а именно при поиске должен найти не менее 150 товаров, на странице результата показывает всего 3!!! товара, и немеряно страниц для листания, и когда листаешь, то показывает всегда по три товара.Проверял всю последовательность изменений - данный баг появляется сразу после:""Это только у Меня?Плиз хелп!!!Замени $keywords_table = ', s_variants v '; $keywords_field = ', v.sku '; на $keywords_table .= ', s_variants v '; $keywords_field .= ', v.sku '; Quote Link to post Share on other sites
seplay Posted March 22, 2014 Report Share Posted March 22, 2014 А если подойти к вопросу по другому. В Симпле есть авто заполнение, когда забиваешь название товара, бренд и т.д. это через запятую прописывается в "ключевые слова". А что если привязать автозаполнение и к артикулу? Чтобы он так-же, как и бренд прописывался в ключевые слова. Quote Link to post Share on other sites
oks Posted April 12, 2014 Report Share Posted April 12, 2014 А можно сделать поиск по артикулу сразу с десяток товаров одновременно, чтобы сделать быстрый заказ необходимых товаров с одной страницы без листания каталога? Для оптового магазина. Quote Link to post Share on other sites
Marketologov Posted June 11, 2014 Report Share Posted June 11, 2014 Поиск - в api/Products.phpпосле $keywords = explode(' ', $filter['keyword']);пишем $keywords_table = ', s_variants v ';$keywords_field = ', v.sku ';вместо $keyword_filter .= $this->db->placehold('AND (p.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") ');пишем $keyword_filter .= $this->db->placehold(' AND p.id=v.product_id AND (v.sku LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") ');дальше в запросе после LEFT JOIN __brands b ON p.brand_id = b.idпишем $keywords_tableтеперь live поиск - открываем ajax/search_products.phpи меняем запрос на $simpla->db->query('SELECT p.id, p.name, i.filename as image FROM __products pLEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1), __variantsWHERE p.id=__variants.product_id AND (p.name LIKE "%'.mysql_real_escape_string($keyword).'%" OR __variants.sku LIKE "%'.mysql_real_escape_string($keyword).'%") AND visible=1 ORDER BY p.name LIMIT ?', $limit);проверял, работает. Помогите плиз по поиску по артиклу. Можно платно.Вывод легко насроил, но вот с поиском проблема.Все сделал как описано. Не работает.Ошибки: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'cygank__navitop_ru__pl'@'localhost' (using password: NO) in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 179 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 179 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'cygank__navitop_ru__pl'@'localhost' (using password: NO) in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 179 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 179 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'cygank__navitop_ru__pl'@'localhost' (using password: NO) in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 179 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 179 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'cygank__navitop_ru__pl'@'localhost' (using password: NO) in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 100 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 100 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'cygank__navitop_ru__pl'@'localhost' (using password: NO) in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 100 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 100 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'cygank__navitop_ru__pl'@'localhost' (using password: NO) in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 100 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/c/cygank/navitop.ru/public_html/api/Products.php on line 100 Warning: Cannot modify header information - headers already sent by (output started at /home/c/cygank/navitop.ru/public_html/api/Products.php:179) in /home/c/cygank/navitop.ru/public_html/index.php on line 33 Quote Link to post Share on other sites
lexter Posted June 14, 2014 Report Share Posted June 14, 2014 Ну по ошибке можно предположить что нет доступа к базе ... Quote Link to post Share on other sites
GMan1990 Posted June 18, 2014 Report Share Posted June 18, 2014 Поиск - в api/Products.phpпосле $keywords = explode(' ', $filter['keyword']); пишем $keywords_table = ', s_variants v ';$keywords_field = ', v.sku '; вместо $keyword_filter .= $this->db->placehold('AND (p.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") '); пишем $keyword_filter .= $this->db->placehold(' AND p.id=v.product_id AND (v.sku LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") '); дальше в запросе после LEFT JOIN __brands b ON p.brand_id = b.id пишем $keywords_table теперь live поиск - открываем ajax/search_products.phpи меняем запрос на $simpla->db->query('SELECT p.id, p.name, i.filename as image FROM __products pLEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1), __variantsWHERE p.id=__variants.product_id AND (p.name LIKE "%'.mysql_real_escape_string($keyword).'%" OR __variants.sku LIKE "%'.mysql_real_escape_string($keyword).'%") AND visible=1 ORDER BY p.name LIMIT ?', $limit); проверял, работает. Всё работает)) Только в последнем случае нужно запрос подкорректировать: $simpla->db->query('SELECT p.id, p.name, i.filename as image FROM __products p LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1), __variants WHERE p.id=__variants.product_id AND (p.name LIKE "%'.mysql_real_escape_string($keyword).'%" OR __variants.sku LIKE "%'.mysql_real_escape_string($keyword).'%") AND visible=1 ORDER BY p.name LIMIT ?', $limit); Quote Link to post Share on other sites
Deni Posted September 14, 2014 Report Share Posted September 14, 2014 Как писали в другом топике ошибки решает замена mysql_real_escape_string на $this->db->escape для версий 2.3.6 Quote Link to post Share on other sites
Gyxman Posted October 21, 2014 Report Share Posted October 21, 2014 В админке при поиске пишется: Нет товаров. В чем может быть проблема? Quote Link to post Share on other sites
xilt Posted January 11, 2015 Report Share Posted January 11, 2015 для версии 2.3.6 у меня заработало так 1. в файле api/Products.php в public function get_products меняем этот код if(!empty($filter['keyword'])) { $keywords = explode(' ', $filter['keyword']); foreach($keywords as $keyword) $keyword_filter .= $this->db->placehold('AND (p.name LIKE "%'.$this->db->escape(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.$this->db->escape(trim($keyword)).'%") '); } на этот if(!empty($filter['keyword'])) { $keywords = explode(' ', $filter['keyword']); foreach($keywords as $keyword) $keyword_filter .= $this->db->placehold(' AND (p.name LIKE "%'.$this->db->escape(trim($keyword)).'%" OR v.sku LIKE "%'.$this->db->escape(trim($keyword)).'%" OR p.meta_keywords LIKE "%'.$this->db->escape(trim($keyword)).'%") '); } далее в этой же функции после этого LEFT JOIN __brands b ON p.brand_id = b.id добавляем LEFT JOIN __variants v ON v.product_id = p.id 2. далее идем в файл ajax/search_products.php меняем этот код $simpla->db->query('SELECT p.id, p.name, i.filename as image FROM __products p LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1) WHERE p.name LIKE "%'.$simpla->db->escape($keyword).'%" AND visible=1 ORDER BY p.name LIMIT ?', $limit); на этот $simpla->db->query('SELECT p.id, p.name, i.filename as image, v.sku as sku FROM __products p LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1) LEFT JOIN __variants v ON v.product_id=p.id WHERE (p.name LIKE "%'.$simpla->db->escape($keyword).'%") OR (v.sku LIKE "%'.$simpla->db->escape($keyword).'%") AND visible=1 ORDER BY p.name LIMIT ?', $limit); и вот этот код foreach($products as $product) { $suggestion = new stdClass(); if(!empty($product->image)) $product->image = $simpla->design->resize_modifier($product->image, 56, 56); $suggestion->value = $product->name; $suggestion->data = $product; $suggestions[] = $suggestion; } меняем на этот foreach($products as $product) { $suggestion = new stdClass(); if(!empty($product->image)) $product->image = $simpla->design->resize_modifier($product->image, 56, 56); if(!empty($product->sku)) $suggestion->value = $product->name . ' ('.$product->sku.')'; else $suggestion->value = $product->name; $suggestion->data = $product; $suggestions[] = $suggestion; } P.S. И будет вам счастье... Quote Link to post Share on other sites
Noxter Posted January 11, 2015 Report Share Posted January 11, 2015 xilt, Вы что то путаете... В версии 2.3.6 и так реализован поиск по артикулу как на сайте так и в админке. Quote Link to post Share on other sites
alexandrbt Posted October 8, 2015 Report Share Posted October 8, 2015 У меня заработало так: нужно заменить mysql_real_escape_string на mysql_escape_string Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.