Search by category in Opencart - opencart

I want to load all category names in an array after that check the input search field with array if found then go to that category page . How to get this done?

1) make one function in catalog\model\catalog\product.php,it will return all active category
2) load this function at catalog\controller\product\search.php at line 17
3) use in_array function to get result,searched title is in or not
4) redirection code if searched title is in category array
Thanks

Related

How can I define each case of the choice list in a uitable (GUI) and put IF function for each one?

I made a matlab gui that have two uitables, one of them have choice list format on its cells but I dont know how define each case of choice list and put IF function for each one. In other words I want apply numbers to second uitable from another gui with dependency on cases in the choice list of first uitable.
I assume that you use guide to manage your GUI, and that you already have created a uitable with a column in the format of a choice list, and that you have set the ColumnEditable property to true. Is that the case?
Then, create a CellEditCallback function by right clicking on the uitable in the guide window and select "View Callbacks" -> "CellEditCallback". This will create the callback function if it doesn't exist so far.
The automatically created callback function could look like this:
% --- Executes when entered data in editable cell(s) in uitable1.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
In this case, the tag of the uitable is uitable1. If your uitable has a different tag, the function name will be according to that tag.
Now, write your if block into this callback function. For example, if the choice list that you want to query is in the first row and first column of your uitable, and you want to check if the selected text of the decision box is "blabla", then your code would look like this:
if strcmp(handles.uitable1.Data{1,1}, 'blabla')
% put here the code that you want to execute if the user selects 'blabla'
end
Hope it helps ...

What RegEx code do I need to leave something as-is

I have a list of page names such as below:
Homepage
Product 1
Accounts
Sign In
Product 2
Campaign
Product 3
I want to use a calculated field in Google Data Studio to aggregate all Product pages. How would I write the code so that it still includes the other pages without manually inputting each individually? This is the code I have:
CASE
WHEN REGEXP_Contains ( Page Title, 'Product' ) THEN "Product Page"
ELSE [LEAVE AS IS]
END
What code would I write to leave the page title as-is but still including it? I feel like it's either something so simple or impossible and that's why I've been unable to find any answers. Would really appreciate any help!
I would guess just this:
CASE WHEN REGEXP_Contains ( Page Title , 'Product' ) THEN "Product Page" ELSE Page Title END

django pagination by giving textbox inputs

I'm a new pratikant and when i joined in the company they gave me the task of configuring number of items per page by giving textbox input for example i created a textbox in html and submmit button and now i want to insert some value say 2 then it should show me first 2 records of the items in the same way 3, 4, 5 ,.......now for me the problem is i was unable to make or attch or call my html code into views.py i mean i was able to make he static pagination
eg :
table.paginate(page=request.GET.get("page", 1), per_page = 10)
like this but now what i want is when i give input to the textbox,, PER_PAGE must be changed according to the given input like 2 records or 4 or n records
i donno whether it is easy or tough but im a starter of python programming and learning still i was unable to make it please help me
Fella student
Thanks in advance
Use
table.paginate(page=request.GET.get("page", 1), per_page = request.GET.get("per_page", 10))
That way 10 will be the default value if "per_page" wasn't passed.

Opencart: i need to search any product inside subcategories

I'm trying to create a menu with buttons that can filter products by main categories
This query url finds products inside a category:
/index.php?route=product/category&path=61
i can find only a part of products with a subcategory search.
/index.php?route=product/category&path=61_72_73
I need to NOT LINK products with their category parents, so is there a way to search with a subcategory filter?
I tried something like this:
/index.php?route=product/category&path=61&sub_category=true
But this doesn't work, it works only with textual searches like this one:
/index.php?route=product/search&search=chair&category_id=61&sub_category=true
ModelUse 'Advanced Product search for OpenCart'. You can search sub categories and any filters you add (including custom ones) with it.
http://www.opencart.com/index.php?route=extension/extension/info&token=460e88e8227b9d7e80466e026dbe1f64&extension_id=13605
I use it for a car dealer website with filters like year, make, model (and sub categories of those) etc and it works great for me.
Here's a demo link:
extension demo link
Try
index.php?route=product/search&search=%25&category_id=25&sub_category=true
25 is category id (which is not mandatory)
and search=searchterm is for a sting search in all sub categories
search=%25 means all products
search field name has changed at some of past version try this for 1.5.4.1
index.php?route=product/search&filter_name=%25&filter_category_id=20&filter_sub_category=true
and see here
http://demo.opencart.com/index.php?route=product/search&filter_name=a&filter_category_id=20&filter_sub_category=true

How to create linked (associated) automatically updated form fields in GAE Django

I am new to Django and GAE. I would like to create two input fields, where the first one is a drop-down menu (let name it select), which decides the values in the second one (let name it val).
For example, once 'A' is chosen from 'select', field 'val' will show '1'. similarly, 'B' is associated to '10'. I have written several lines below, but it does not work. Two issues:
The second field ('val') always equals 0.
It seems like my second field ('val') does not 'listen' to the choice made by the first one ('select'), which means those two fields are not linked.
Can anyone give me some suggestions (or recommend books on using Django on GAE)? Thank you!
select_CHOICES=(('A','A'),('B','B'),('Other','Other'))
select = forms.ChoiceField(choices=select_CHOICES, initial='A')
def get_choices(select):
if select=='A':
r= 1
elif select=='B':
r= 10
else:
r= 0
return r
val=forms.FloatField(initial=get_choices(select))
I think you have understood how django works a bit wrong. The code that you input is run before the page is rendered, so no selection is made yet. If you want the input field to dynamically change as user makes the choise on page, you should use Javascript.
Also you are comparing a Field (select) to a string ('A'), which naturally always is unequal.
Read more documentation and tutorials and you'll soon get how it works.