Search Engine of Open Cart - php

Can anyone Please tell me how the search engine of the Open Cart works. I mean to say where is the code for the search in Open Cart. Which database tables are uses to search any query?

OpenCart Search Form submits to route=product/search i.e. catalog/controller/product/search.php. This file calculates results based on submitted keywords and then loads product/search.tpl template to display search results.
Search results are generated by the controller using catalog/product model's getProducts() function. The same function used for generating ordinary product lists.

OpenCart uses a basic search (just matches any keywords in your search), though there are other search methods available in the extension store. The tables it uses in the default are the product and the product_description tables

Open-cart search in the category levels according your filters join with category_description table and the products titles join the product_description Table all this according the current user Language
you Can find this code in Product Model
\catalog\model\catalog\product.php
public function getProducts($data = array()) {

Related

Prestashop - where is the code to search products by manufacturer name?

I have a shop on Prestashop 1.7 with books. Some of them have two authors. Authors are stored as a manufacturers. I made a plugin to allow user to assign more than one manufacturer to single product, but now I must fix products search to use my custom table of assignments in search process. The problem is that I can't find where is the sql code which is looking for manufacturer name. I already spend whole day for this without results. Any help?
Look into the file classes/Search.php method find. In my case, it is line 331. you need to modify this query to change a search approach
After deep digging: it is not so easy as I thought... Prestashop keeps keywords in table called search_word which is connected by id_word with table search_index where all words are assigned to id_product, so now my job is to assign manufacturer name as a search words to updated product - sounds complicated, but it shouldn't be so hard

search in appropriate Mysql fields based on current App Locale in laravel

In a multilingual website I have these fields for Products table
product_id
title_fa
title_en
title_ar
desc_fa
desc_en
desc_ar
.
.
.
Now I want to search in (for Example) title fields based on Current laravel Locale.
I know that we can use this way :
$products = Product::where('title_'.App::getLocale(),'LIKE' , '%'.$data['search_value'].'%');
But I thinks that is not clean and easy for number of large fields is not suitable.
I'm looking for a way that was and simple as normal search field and then laravel search based on that field in background According to current App Locale like:
$products = Product::where('title','LIKE' , '%'.$data['search_value'].'%');
How Can I do that and what is best way ?
Hi if you want really easy way for search products than use this following laravel multi language package
https://github.com/dimsav/laravel-translatable
in this package you have to create 2 tables one Product and Product_translate, product table will have your basic product info, translate will have language data, in product_translate table you can use search queries, ease is table column name will remain same in where you have use language filter.

Display Dynamic List of Articles in Joomla

In a category list, I'd like to be able to display the list of articles dynamically. The website I'm developing allows a user to "submit" an article once they have read it. When they hit the submit button, the ID of that article is stored in the database in a table called "completed_quests." What I need to do is have Joomla check to see if the article ID exists in both the "content" and the "completed_quests" tables. If the article ID exists in both tables, then the article should not be displayed in the category list as that article or "quest" has already been submitted. If the article ID exists in the "content" table, but NOT in the "completed_quests" table, then the article SHOULD be displayed in the category list as it has note yet been submitted.
I'm wondering if there is a specific core Joomla file I should override to alter the category list output, or if I should develop a custom module to create this dynamic list. Any guidance would be much appreciated. If you have any other thoughts about how to display this dynamic list, I'm all ears.
edit: I've started by developing a custom module within Joomla, at least for testing. The below code is not working as expected. When I take out the following line "WHERE arp2i_completed_quests.id IS NULL" it displays a list of articles that exist in both tables. But what I need it to do is display the rows that exist in the content table but NOT in the completed_quests table. When I add the WHERE , it displays the text "ID:" and "TABLE:" for each row that exists, but the actual id and title from that row is not echo'ed to the screen. Please help.
Working code (see comments).
<?php
$query = "SELECT * FROM arp2i_completed_quests RIGHT JOIN arp2i_content ON arp2i_content.id=arp2i_completed_quests.id WHERE arp2i_completed_quests.id IS NULL LIMIT 0, 30 "; // prepare query
$db = &JFactory::getDBO(); // get database object
$db->setQuery($query); // apply query
$articles = $db->loadObjectList(); // execute query, return result list
foreach($articles as $article){ // loop through articles
echo 'ID:' . $article->id . ' Title: ' . $article->title . '<br />';
}
?>
You could override the com_content's listings view in your template.
You do that by copying default.php from /components/com_content/views/categories/tmpl/ to /templates/yourtemplate/html/com_content/categories/
However, I believe that such template overrides only allow you to update the display files of modules and components (the default.php files), and not the models, which would mean you have to add database queries into this layout file (or into a library), which feels a very hacky approach. It should work, though.
A better solution would be to create a bespoke component with a single view, and a model that queries your database to create the appropriate listings. It may even make sense to just make the whole thing a bespoke component (saving the articles in that component) and not use Joomla's articles manager at all.
If your listings page is not paginated, or if you do not care about an SEO friendly URL on secondary pages, then you also could create a module to display the listings and insert that into an article area. Modules are often simpler to make than components. You enter the database query into the helper file of a module.
You should just develop a content view that does exactly what you want. Should be very simple if you have some programming experience. You needn't change any core files.

Dependent Drop down in Grocery CRUD (CodeIgniter)

I stucked in a Problem When Playing with Drop Downs.I tried to use this
http://www.grocerycrud.com/forums/topic/1087-updated-24112012-dependent-dropdown-library/
But actually my requirement is quite different. I have a table fwld_products in which i am adding all other table's categories, from
fwld_cat_main (main Category's ID),
fwld_cat_sub1 (sub1 Category's id)
fwld_cat_sub2 (sub2 Category's id)
fwld_cat_sub3 (sub3 Category's id)
I want to Display Dropdown in such a way, when user Selects main
Category, the Drop Down Appear (sub1) Having Data related to main
category and when sub1 selected drop down appear (sub2) showing data
related to sub1, and sub2 selected and drop down appear(sub3) to show
data related to Drop down (sub2).
When submitted Finnally data inserted to [fwld_products].
Here I am attaching ERD, and result as well.
Please help
Hold on, it seems that DB structure of your categories table needs to be improved. What I suggest is that you follow footprints from some of the popular CMS like Opencart. It will give you a great sense to accomplish your task. You can easily optimize your DB by using just one "category" table (instead of main, sub1, sub2, and sub3 category tables) like this:
For category names, description, and meta keywords etc you can create this table "category_description":
Finally to assign categories to the products you can simply create another table "product_to_category":
In this way you can easily manage your data in DB and you can now easily tackle your situation using Codeigniter and Grocerycrud.
Try, Chained Selects Plugin for jQuery and Zepto (Github Project | Project Home)
If you use jquery or zepto in your project, this plugin will help you to solve your problem, Specially the remote version. You can create related select boxes easily.
Hope this helps :)

How to display records from SQL through menu, using PHP?

i have made a static drop-down menu for my e-commerce website. i have various categories and then sub categories.
my main tabs are, "CLOTHES", "FOOTWEAR", "ACCESSORIES" etc.
The clothes tab is divided into two parts one is brand wise and one is type(shirts, jeans, etc.)
Now my question is, if i go to the clothes tab and then click on shirts, how can i traverse and retrieve the records from my SQL table.
I have made the connection with the database, my table name is 'products'. The page to display products is list.php.
I am new to PHP and i know a little bit about this language.
have a pages table and categories table
also have cat_parent in the categories table
Then have a php loop to go through each topmost categories and then subcats and ......... and then pages.
watch it in action this is the site i am working a the moment
First you should have categories & sub categories in single 'categories' DB table.
In products table, you will have a category_id column as foreign key.
So based on this category_id column, you can retrieve products from your DB.
Also each product in DB should have assigned a particular category.
You have to use AJAX or a Javascript function to achieve this type of functionality. Here is how:
Use an onChange event in your static drop down menu HTML code.
Make a function in a <script> tag to catch the id of selected item.
Pass this id to the PHP file in the URL.
Give your <div> id name in this Javascript code.
After calling the PHP file catch the id from get method and pass it to the query.
You can get the desired result.

Categories