Posts

Quick guide to search, sort and filter products in prestashop mobile app

PrestaShop is based on open source platform for e-commerce which provides smooth shopping cart system with control over the look and functionality of the store. It is growing in the e-commerce market day by day. More traders are using this platform for their e-store. It provides various feature for an e-commerce store , you can check its features in our previous blog. With the increase in the e-commerce stores, mobile-commerce has also become popular these days. Mobile visits account for one-third of e-commerce sites traffic. To have an e-commerce mobile app for electronic commerce store is like putting a  retail outlet in the customer’s pocket . PrestaShop provides SEO, items management, and other tools which enforce traders to have the mobile app for superb shopping experience for customers.  In this blog, I am going to discuss some important features i.e searching , sorting and filtering implementation in the Prestashop mobile app.

Let me first start with the basics. PrestaShop system API is constructed by principle CRUD (Create, Read, Update, Delete). All methods are to be called through the /api/ gateway. Most methods can be accessed in a REST manner, with the 5 main HTTP request methods: HEAD, GET, POST, PUT, DELETE.

How to Search products in PrestaShop mobile app using REST API

search can only be accessed using GET and HEAD in PrestaShop API . Following the syntax for retrieving searched data or product :

      /api/method/?filter[parameter name to search]=[parameter value to search]

for example- let search a product by its name , then its request call will be like :

 /api/products/?display=full&filter[name]=[Blouse]

This call will return the product full details with the name “Blouse”. In the above syntax “parameter name to search” can be anything that products method has in its schema. You can search as many numbers of values at a time i.e :

 /api/products/?display=full&filter[name]=[Blouse, Shirt, Top]  .

 /api/customers/?display=full&filter[firstname]=[John]&filter[lastname]=[Parol] .

How to Sort products in PrestaShop mobile app using REST API

Following the syntax for retrieving searched data or product :

      /api/method/?sort=[sort by field with the suffix _ASC _DESC or in the order]

for example- let sort products by its name , then its request call will be like :

/api/products/?display=full&sort=[name_ASC]

This call will return the product in ascending order of ‘name’ with all details.

      /api/products/?display=full&sort=[price_DESC]

How to Filter products in PrestaShop mobile app using REST API

Following the syntax for filtering data or products :

      /api/method/?filter[field]=[value1|value2]

Above syntax  filter “field” with value between ‘value1 ” and “value2”

      /api/method/?filter[field]=[value1,value2...]

Above syntax  filter  field for values specified between brackets   

      /api/method/?filter[field]=[value]%

Above syntax  filter “columns” for values containing “value”

for example- let filter products by its ids then its request call will be like :
/api/products/?display=full&filter[id]=[1,10]  – This will list the products with id 1 to 10.

/api/products/?display=full&filter[id]=[1|5]  – This will list all the products between 1 to 5

/api/products/?display=full&filter[name]=[appl]%  – This will list all the products name starting with “Appl”.

NOTE: In the above all calls “display=full” means it will display all product details. You can display your product according to your choice. For example – “display=[birthday]” will display only the birthday.

Conclusion

As the implementation of PrestaShop framework is increasing day by day for the e-commerce stores , demand for mobile-commerce is also increasing with the same speed and popularity. So developing an e-commerce mobile app is becoming common and for any e-commerce store searching, sorting and filtering are very common and powerful property. Keeping these all things  in mind I wrote this article to help the new developer for PrestaShop. I hope this will help you… :-). Below is our sample app based on Prestashop REST API, you can refer it as an example which has shown the use of sort, search and filter APIs.

prestashopeePrestashopee
The PrestaShopee mobile app developed using native platforms that gels well with all mobile devices.It has used PrestaShop’s APIs for data. Further performance wise your app will be steadfast and hence customers are assured of a quick shopping experience.

References

Prestashop is a free open-source which provides the solution for e-commerce. For more information, you can visit the following link PrestaShop.

PrestaShop provides documentation for the list of all basic APIs that  are needed for the e-store.To get more details about the documentation you can visit this link PrestaShop Webservice

Easy way to implement multiple filters in Android Mobile App

Multiple Filters is the selection of the multiple items from the multiple categories. In this tutorial we are going to learn that how we can select multiple items from the different list simultaneously.

Here we use two RecyclerView to implement Multiple Filters. RecyclerView is more useful,valuable,malleable and ahead version of ListView. It is a tub for bigger data set of views that can be recycled. RecyclerView used for Bigger datasets to deliver on the UI like a list. RecyclerView can be scrolled very easily.RecyclerView gives better flexibility to make different kind of views.

ColorSelected

Here first RecyclerView is used as Category and Second RecyclerView is the list of respective selected category item. In first figure we select Size then we get the respective list of Size and in second figure we select Color then get the respective list of color and in third figure we select Style get the respective list of Style in second RecyclerView. When we select Size,Color and Brand items from the list and press the done Button then we get the filtered results.

Steps to implement Multiple filters:-

1) Add Support Library:-

 To use RecyclerView in your project firstly you need to add RecyclerView support library in your project.

dependencies {

compile 'com.android.support:recyclerview-v7:+'

}

2) Create XML Layout files:-

We need to create three xml layout file in which first layout have two RecyclerView. Second Layout have View that we use for first RecyclerView and third Layout have View to select the items from the list that we use for second RecyclerView.

2.1) activity_main.xml:-

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/filter_dialog_listview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.7"
            android:paddingRight="1dp"
            />

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="@color/black"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/filter_value_listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.3"
            />
    </LinearLayout>

Now You can make the view as you want.We take here two more layout to make our filters.

3) Create Main Activity:-

3.1)MainActivity.java

@Override protected void onCreate(Bundle savedInstanceState) {
         filterListView = (RecyclerView) findViewById(R.id.filter_dialog_listview);
         adapter = new FilterRecyclerAdapter(this, R.layout.filter_list_item_layout, filterModels); 
         filterListView.setAdapter(adapter);
         filterListView.setLayoutManager(new LinearLayoutManager(this)); 
         filterListView.setHasFixedSize(true); 
         filterValListView = (RecyclerView) findViewById(R.id.filter_value_listview);
         filterValAdapter = new FilterValRecyclerAdapter(this,R.layout.filter_list_val_item_layout, sizeMultipleListModels, MainFilterModel.SIZE);
         filterValListView.setAdapter(filterValAdapter);
         filterValListView.setLayoutManager(new LinearLayoutManager(this)); 
         filterValListView.setHasFixedSize(true); 
}

4)Create Adapter for Filters:-

@Override
    public void onBindViewHolder(PersonViewHolder personViewHolder, int i) {
        personViewHolder.parentView.setSelected(filterModels.get(i).isSelected());
        if (personViewHolder.personName.isSelected()) {
            if (filterModels.get(i).getTitle().equals("Size")) {
                personViewHolder.personName.setCompoundDrawablesWithIntrinsicBounds( 0,R.drawable.sizeblack, 0,0 );
                personViewHolder.personName.setText(R.string.txt_filter_size);
            } else if (filterModels.get(i).getTitle().equals("Color")) {
                personViewHolder.personName.setCompoundDrawablesWithIntrinsicBounds( 0,R.drawable.colorblack, 0, 0);
                personViewHolder.personName.setText(R.string.txt_filter_color);
            } else if (filterModels.get(i).getTitle().equals("Brand")) {
                personViewHolder.personName.setCompoundDrawablesWithIntrinsicBounds( 0,R.drawable.styleblack, 0, 0);
                personViewHolder.personName.setText(R.string.txt_filter_style);
            }
        } 
    }


4.2) FilterValRecyclerAdapter:-

 @Override
    public void onBindViewHolder(ValueViewHolder personViewHolder, int i) {
        personViewHolder.subCategoryName.setText(filterModels.get(i).getName());
        personViewHolder.cbSelected.setChecked(filterModels.get(i).isChecked());

        @Override
        public void onClick(View v) {
            if (mItemClickListener != null) {
                mItemClickListener.onItemClick(v, getPosition());
            }
        }
    }
}

 

Conclusion

If you want to implement Multiple Filters in your project then you will find it more easy to implement.Implementation of Multiple Filters has very easy steps as described above.It gives more flexibility to the android user and make the UI more friendly and attractive.You can edit the xml and adapter files in your own way to make it more attractive as per your requirements. There are various native e-commerce mobile apps available in the market for example Prestashopee – Prestashop AppMagentoShop – Shopping AppWooShopee – Woocommerce AppClovia etc that use mutiple filters to filter the selected items and looking good.

Prestashopee – Prestashop App
Looking for a native Magento mobile app builder (iOS/Android) for your Prestashop based online marketplace? Try the 30-day free trial of our Magento mobile app, go mobile commerce in a few hours and increase your sales exponentially. No Setup Fee, Pay as you go pack at just $69/month.

magento-logo
MagentoShop
Looking for a native Magento mobile app builder (iOS/Android) for your Magento based online marketplace? Try the 30-day free trial of our Magento mobile app, go mobile commerce in a few hours and increase your sales exponentially. No Setup Fee, Pay as you go pack at just $69/month.

wooshopee_logoWooShopee – Woocommerce App
Looking for a native Woocomerce mobile app builder (iOS/Android) for your Woocommerce based online marketplace? Try the 30-day free trial of our Magento mobile app, go mobile commerce in a few hours and increase your sales exponentially. No Setup Fee, Pay as you go pack at just $69/month.

Go to MultipleFilter example on Github

References:-

RecyclerView : Document briefly explain about the Recycler view.