Technical Guide

PrestaShop eKomi Feedback Plugin Technical Guide

This document contains the following sections:

  1. Plugin Overview
  2. Plugin Structure
  3. Plugin Configurations
  4. Module class
  5. Controller and Model classes
  6. Cron CLI files
  7. Views
  8. Translations

1. Plugin Overview

eKomi Plugin for Prestashop allows you to integrate your Prestashop easily with eKomi system. This allows you to collect verified reviews, display eKomi seal on your website and get your seller ratings on Google. This helps you increase your website's click through rates, conversion rates and also, if you are running Google AdWord Campaigns, this helps in improving your Quality Score and hence your costs per click.

This also allows an easy integration of eKomi Reviews and ratings into your webshop. It allows you individual positioning of product reviews and includes the Google rich snippet functionality.

2. Plugin Structure

3. Plugin Configurations

3.1 config.xml

Plugin metadata  name, description, version number etc… are defined in this config.xml file.

4. Module class

EkomiFeedback class extends the Module class and implements its functions i.e install , uninstall etc..

Hooks and configuration fields used in the plugin also defined in this class.

Methods used in this class are:

  • __construct

Plugin meta data is defined

  • install

On installing the plugin, Checks the current  shop active and nullify all the plugin config fields.

  • hookActionOrderStatusPostUpdate

Hooks which trigers on the status change. It match the status defined in config fields and

sends order data to ekomi system.

  • getRequiredFields

Returns the required fields to send orders data to ekomi system

  • sendPostVars

Calls dashboard api to send order data.

  • hookDisplayProductButtons

Checks if the plugin is enabled, and returns mini stars html source code to place on single Page.

  • hookDisplayProductPriceBlock

Checks if the plugin is enabled, and returns mini stars html source to display either on single page or listing.

  • hookEkomiReviewStars

Checks if the plugin is enabled, and returns mini stars html source code.

  • hookHeader

Checks if the plugin is enabled, and include the CSS and JS files.

  • hookDisplayFooterProduct

Checks if the plugin is enabled and Show Reviews container in config is yes then returns

the html source code of Reviews container. Otherwise will return empty string.

  • hookEkomiReviewsContainer

Checks if the plugin is enabled, and returns the html source code of Reviews container.

  • resolveOrderBy

Checks the filter type and returns the column name and sorting type.

  • getReviewsHtml

Fetch the reviews and returns the reviews html and count of reviews.

  • Uninstall

Drops the database table that was being used to store reviews data. And deletes the plugin Config fields.

  • getContent

This function is executed when displaying the contact form. It can also be used to catch

the form submissions. You can retrieve values of the submitted form here.

  • displayForm

Displays the plugin configuration form.

  • getPostValues

Returns the plugin config fields.

  • updateValues

Updating the plugin config values.

  • verifyAccount

Verifyies the shop id and password by calling getSettings api of ekomi.

  • getBoolOptions

Rerurns the enable and disable options for dropdown.

  • getModeOptions

Returns the mod options

  • getStatusesArray

Returns the orders statuses

  • getInputFields

Makes plugin configs array and returns to displace on plugin config form.

  • getProductIdsArray

Returns product Ids based on group reviews fields in plugin config form.

5. Controller and Model classes

Front Controller Class

EkomiFeedbackReviewModuleFrontController is the class which extends

ModuleFrontController class. Ajax calls are being served in this class.

  • displayAjax

Get the value of type parameter in ajax post call do required action. Ie.

When type=loadReviews, it will Load reviews based on filter and Limit parameter.  

When type=saveFeedback, it will record the user action on a reviews either the reviews Is helpful ord not helpful.

Model Class

The ReviewsModel class which extends ObjectModel.

  • createTable

Creates the table to store reviews data

  • dropTable

Drops the reviews table.

  • populateTable

Calls the getApiReviews method and fetch the reviews. Loops and stores the reviews data in DB.

  • getApiReviews

Fetches the reviews from ekomi system by calling getProductFeedback api.

  • getReviewsStars

Fetches all stars from all reviews stored in DB.

  • getReviews

Fetches the stored reviews in DB and returns.

  • getReviewStarsCountsArray

Makes an  array of 5 size to store count of all stars rating.

  • getReviewsStarsAvg

Query the DB to calculate the average of stars rating.

  • saveFeedback

Saves the feedback of users on reviews listing in reviews container.

  • rateTheReview

Rate the review either helpful or Not helpful.

  • getReviewsCount

Query the DB reviews table to calculate the count of all reviews stored in DB for a product ID.

6. Cron CLI files

Import_all.php

Includes the required core and plugin files. Populate all reviews of the shop mentioned in plugin config in DB reviews table of the plugin.

This file runs manually by hitting this url

{your-shop-url}/modules/ekomifeedback/cron_cli/import_all.php

import_weekly.php

Includes the required core and plugin files. Populate reviews in  range=1w of the shop mentioned in plugin config in DB reviews table of the plugin.

This file can be run manually by hitting this url

{your-shop-url}/modules/ekomifeedback/cron_cli/import_weekly.php

7. Views

This folder contains following scripts, styles and templates.

Css

Ekomi-prc.css files to apply styles on widgets.

Fonts

Contains the fonts file used in plugin.

Img

Contains images used in plugin.

Js

ekomi-prc.js  contains the js script to serve actions by front user.

Jquery-3.1.1.min.js is jquery library.

templates

Mini_stars.tpl, reviews_container.tpl, and reviews_container_partial.tpl are files containing html code for widgets.

8. Translations

Contains translations for following 5 languages French (fr), German (de), Dutch (nl), Spanish (es), Italian (it), and Portuguese (pt).