Magento Filer the data by attribute before algolia search - search

Am trying to provide the Algolia search option with filter by attribute value. For example from the attached pic, need to filter the data by city attribute and then Algolia shows results results accordingly to selected attribute
Click Here for image

First you need to add the select box with searchable attribute before search input. I assume you use Algolia's Magento extension.
If it's the case you need to put your select box into either autocomplete.phtml file (if you are using default search box selector) or to your theme's template (if you modified search box selector in Algolia settings in Magento administration).
Then if you want to do it on instant search result page you can use searchFunction to restrict searchable attributes:
var search = instantsearch({
[...],
searchFunction: function(helper) {
var searchableAttribute = $('selectbox-selector').val(); // Using jQuery just for example
helper.setQueryParameter('restrictSearchableAttributes', searchableAttribute);
helper.search();
}
}
Initialization of instantsearch you can find in instantsearch.phtml template.
If you want to update results in autocomplete menu, you will have to set the restrictSearchableAttributes parameter to autocomplete data source. The data sources are defined in commonjs.phtml file. More information of autocomplete data sources you can find in autocomplete.js documentation.
Example of updating product's data source:
options.facets = ['categories.level0'];
options.numericFilters = 'visibility_search=1';
options.restrictSearchableAttributes = $('selectbox-selector').val();

Related

Acumatica Mobile Modify the Location fields to be able to scan a barcode

We are currently using the Acumatica Mobile to process Bin Transfers. We are also looking at the Scandit app to be able to scan the from and to bin location labels in the warehouse. So far with testing We can scan the locations, but only in the search window. We would like to be able to scan/enter the locations on the main screen without going to the search window. It seems the selector forces you to go to the search window. Is there a way around this in Acumatica Mobile.
This is a fairly old question with a relatively new solution. I am using 2020R1 where we now can leverage the built-in scanning capability in the Mobile App.
Your field must be defined in the ASPX as a textedit. Then simply add the field to the mobile app screen (if not already there) and decorate it with special = BarCodeScan as shown in the example below.
add screen ZZ301000 {
add container "ScanContainer" {
add field "MyBarcode"
{
special = BarCodeScan
}
add containerAction "Insert" {
icon = "system://Plus"
behavior = Create
}
add recordAction "Save" {
behavior = Save
}
add recordAction "Cancel" {
behavior = Cancel
}
add recordAction "Insert" {
behavior = Create
}
}
}
The result will be similar to the image below:
By clicking on the barcode icon, the built-in barcode reader will open to utilize the camera to scan the barcode.
You can try to set ForceType to "String" for the Location field to replace selector with a text edit. This will allow to type values directly on the form, but you will loose all selector functionality, like searching for records. Another option is to set the PickerType property to Searchable. For more information about the Field tag attributes, please refer to Acumatica Product Documentation

Lightswitch Search screen - choosing what you can search by

I have a search screen which shows results from a 'projects' entity. One of the fields is a link to a 'Clients' entity, which has a client name.
I can use the search box above the data to search by project name, date, etc but I cannot search by client name. i guess because it is actually a reference to a seperate entity.
How can i make it so that I can search for projects, using the search box, by client name?
To try to explain clearer here is the database layout.
Project
------
ProjName
ProjType
ProjComment
Client --------------- Client
-----
Name
Address
I can search by the project fields, but not the client name.
Create a custom query for Project entity and add optional parameters for all the Project and Client properties that you wish to search for. Wire up the custom query filter.
For full control do not wire up the custom query filter, instead filter in code behind, the PreProcess event.
if your using the HTML Client it can be done as follows on a browse screen associated with in your case the Project Table. if you look at the left navigation bar, click on edit query and within here, you can see 3 options, Filter, Sort and Parameters.
Filter should say Client.Name based on your table structure, the second should be changed to "contains", the 3rd should be set as parameter and finally the 4th box is where you create the new parameter you are going to use as a search box...
you can rename the Parameter at the bottom and I always find its best when on this, to set it as optional in the bottom right property box. (This means all the data will be displayed rather than nothing until searched)
Now if you were to go back to your main screen page, drag this parameter from the left onto the main screen page and set it as a text box. Using this and pressing enter after you have typed something will display the results that match what you have typed so far.
a little more to the above, if you were to click "Edit PostRender Code" and add the below then after 3 characters are entered, the table list your searching through will be updated automatically after each finger stroke...
$searchBox = $("input", $(element));
setTimeout(function () {
$searchBox.focus();
}, 1);
onInputAsYouType(element, 1, function (text) {
contentItem.screen.[CREATED PARAM NAME] = text; //SearchText here is the data item in the screen designer linked to the query parameter
});
function onInputAsYouType(element, numberOfRequiredChars, done) {
var inputbox = $("input", $(element));
inputbox.on("input", function (e) {
var text = $(this).val();
if (text.length >= numberOfRequiredChars)
done(text);
});
};
};

Sharepoint 2013 JSLink (CSR) Not Working

I'm trying to make our list view as an accordion by following this tutorial:
https://code.msdn.microsoft.com/office/Client-side-rendering-code-ccdb2a0e
-
I followed the tutorial:
Create a Custom List, add a new column to the list:
Name: Description
Type: Multiple lines of text
Edit the Default New Form
Go to List view web-part properties and add the JSLink file (~sitecollection/Style Library/JSLink-Samples/Accordion.js) to JS link property under the Miscellaneous Tab. Click Apply.
-
Nothing changed, so I added a Script Editor in that page and pasted js code. Then it kind of works.
Is there anything I did wrong? Thanks!
Unfortunately the list view is rendered properly when Description field is type of Plain text from the specified example.
To render it properly when Description field is type of Rich text or Enhanced, replace the accordionTemplate function with this one:
function accordionTemplate(ctx) {
var title = ctx.CurrentItem["Title"];
var description = ctx.CurrentItem["Description"];
// construct List Item
return "<h2>" + title + "</h2><p>" + $(description).html() + "</p><br/>";
}
Result
I would recommend you to try another approach to render List View as accordion as demonstrated in Customize the rendering of a List View in Sharepoint 2013: Displaying List Items in Accordion article.
Key points:
jQuery IU Accordion is used for rendering List Items as collapsible
content panels
demonstrates how to load multiple JavaScript libraries (e.g. jQuery)
using JSLink property
Result

How to show list of custom objects in a page in Drupal

I want to create a page in Drupal 6 where I can show list of restaurants.When a user clicks on any restaurant page, I should be redirected to Restaurant details page.
For this :
1.) I created a new content type called "Restaurant" with some fields.
2.) Created 3-4 content items for Restaurant( Restaurant1, Restaurant2, Restaurant3)
3.) Created view called: RestaurantList, Added Fields for it. Then added Page Display and gave the path for it http://website/Restaurants
Now, when I browse to Restaurants page, I only get labels of my fields but no values. How can I get the values but not the labels? Also, I want to go to the RestaurantDetails page. How can that be achieved?
Thanks,
Rashmi
Well if I were to set up a page view this is how I would set it up:
Filters:
Node type - Restaurants
Node published - Yes
Fields
Node title
check the option Link this field to it's node
leave the Label: field empty
check option Hide if empty
And if your view style is a HTML list, for extra you can go to Row style options and check the option: Hide empty fields
Make sure you click Preview to see if you get any values. If you don't then there's something wrong with the view settings, most probably the filters which are to restrictive. Start with something loose, like Node type - Restaurants.

Person & Group custom field type sharepoint

I have created a custom field type as it is there in sharepoint OOTB, the difference is only that the end user does not need to check the name i.e I have replaced it with DropDownList. The dropdownlist suggest the no. of users available in the web site for that I have created a FieldClass which inherits from SPFieldUser and a FieldControlClass which inherits from UserField. It is working fine in all conditions i.e when I create a List or Document Libarary it shows me the DropDownList
with respective users after saying OK it creates an item for me. I have overriden a Value property in FieldControlClass as follows,
public override object Value
{
get
{
SPUserCollection userscollection = rootWeb.SiteUsers;
//ddlInfoBox is a DropDownList to which I have Binded the collection of users in the form of string
SPUser user = userscollection.Web.EnsureUser(this.ddlInfoBox.SelectedValue);
SPFieldUserValue userval = new SPFieldUserValue(user.ParentWeb, user.ID, user.LoginName);
return userval;
}
set
{
SPFieldUserValue userval = (SPFieldUserValue) this.ItemFieldValue;
this.ddlInfoBox.SelectedValue = userval.Lookupvalue; //Here look up value is nothing but a Login name e.g In-Wai-Svr2\tjagtap
}
}
Due to above property the Custom Field's Value for this current ListItem will be stored as SPFieldUserValue e.g 27#;In-Wai-Svr2\tjagtap.
The main problem is here, when this particular ListItem is shown in the list page views e.g on AllItems.aspx or the custom view pages associated with it, it shows the
number as 27 as a FieldValue insted of HyperLink with text as "In-Wai-Svr2\tjagtap" and PostBackURL as "/_layouts/userdisp.aspx?ID=27".
When I edit this Item it makes the respective value selected in the dropdownlist, also while viewing this item i.e on DispForm.aspx it also shows the hyperlink. I have
acheived it by writting a custom logic in createchildcontrol() method i.e by using ControlMode if it is New or Edit then fill the dropdown list, if it is Display then get the ItemFieldValue Type Cast it into SPFieldUserValue and get corresponding lookupid and value for making the URL and showing Text of the HyperLink.
I have spent a lot of time on searching and bringing the HyperLink as the user name with navigation insted of UserID (27) as a string on the list view pages e.g AllItem.aspx but to no avail, then after a lot of research I found that there might be a way of achieving such kind of functionality by using field type definition xml file where there is a provision to define a DisplayPatteren as you wish by specifying the html code. But here is a problem How can I get the UserID (27) with respective UserName e.g In-Wai-Svr2\tjagtap inorder to make an anchor tag like In-Wai-Svr2\tjagtap which will solve my problem. I have hard coded this anchor tag within the Default case statement of a switch under DisplayPatteren but it shows me the field value on AllItems.aspx as
In-Wai-Svr2\tjagtap27 i.e the value defined in xml file is concatenating with the string value (27).
Please help me to resolve the above mentioned 2 issue. I am really in need of solving this problem ASAP.
Thanks & Regards,
Tejas Jagtap
Have u tried to override the GetFieldValueAsHtml() method in the the custom field class or maybe the RenderFieldForDisplay() method in the custom field control class.
Can you use the DisplayPattern CAML from the User field type?

Resources