Giter Club home page Giter Club logo

oxid-eshop-module's Introduction

FACT-Finder® Web Components for OXID eShop

Packagist Version GitHub contributors

This document helps you to integrate the FACT-Finder® Web Components SDK into your Oxid Shop. In addition, it gives a concise overview of its primary functions. The first chapter Installation walks you through the suggested installation process. The second chapter Backend Configuration explains the customisation options in the Oxid backend. The final chapter Web Component Integration describes how the web components interact with the shop system and how to customise them.

Table of contents

Requirements

  • OXID eShop 6.x
  • PHP version: 7.2, 7.3, 7.4

Note: If you use OXID eShop 7.x, please use SDK version 5.x

Installation

To install the module, open your terminal and run the command:

composer require omikron/oxid-factfinder:^4.0

Activating the Module

From the root of your Oxid installation, clear the cache with:

rm -rf source/tmp/*

Check in the Oxid 2 backend "Stores → Configuration → Advanced → Advanced" if the module output is activated.

Module Enabled

Backend Configuration

Once the module is activated, you can find the configurations page under "Extensions → Modules → FACT-Finder® Web Components | Omikron Data Quality GmbH -> Settings". All sections will be covered in the following paragraphs.

Main Settings

Main Settings

This section contains a critical configuration, which is required in order for the module to work. All fields are self-explained. Configuration set here is used by both Web Components and during the server side communication with FACT-Finder® instance. Credentials you will be given should be placed here.

  • Server URL - FACT-Finder® instance url
    Note: Server URL should contain a used protocol: (e.g. https://) and should end with an endpoint specific for a given version (e.g. in version 7.3 its FACT-Finder-7.3, in NG fact-finder )
  • Channel - Channel you want to serve data from
    Note The number of channel fields is adjusted to the number of active languages used in application. Please make sure you set a correct channel for a given language.
  • Username - for importing data to FF
  • Password - for importing data to FF
  • Username - for fetching data from FF
  • Password - for fetching data from FF
  • Authorization Prefix
  • Authorization Postfix
    Note: FACT-Finder® NG does not require fields Authorization Prefix and Authorization Postfix to be set. Please omit these fields in this case.
  • Version - Used FACT-Finder® version
    Note: Module supports FACT-Finder® from version 6.9 up to NG. by selecting the wrong version you may cause the Web Components to be unable to communicate with FACT-Finder®
  • API Version - Used FACT-Finder® api version
    Note: Module supports FACT-Finder® api version v4 and v5. By selecting the wrong api version you may cause the Web Components to be unable to communicate with FACT-Finder®

Buttons

Buttons

Test Connection Button

By clicking the Test Connection button you can check if your credentials are correct. This functionality uses form data, so there is no need to save first. Note: This functionality uses de channel input value.

Export Feed Button

It is a one of possible ways of exporting feed. You can find more details in section Admin Panel Export

Test FTP Connection Button

This functionality allows you to test if your shop can successfully connect to configured FTP/SFTP server. It uses parameters passed down with the request so there is no need to save the configuration before.

Update Field Roles Button

This functionality allows you to update field roles if you have changed them in FACT-Finder. The field roles are by default configured accordingly to the columns exported by the module. If you are about change one of the column name that serves as a role e.g. Master or ProductNumber, that holds the Master article number and Product number roles respectively, please remember to update the field roles with that functionality

Advanced Settings

Advanced Settings

  • Use URL params? - check this option if you want Web Components to push each used query parameter to the URL,
  • Additional parameters - here you can define extra parameters for each of these properties: add-params, add-tracking-params, keep-url-params, parameter-whitelist. Values will be passed to the Web Components and used in communication. You can find more information about mentioned properties purposes in Web Components documentation.
  • Anonymize User ID? - check this option if you want to send user id with tracking requests in anonymized form. By default the regular id field from user table is sent.
  • Use Proxy - check this option if you want each request sends by Web Components first reach the dedicated module controller which forwards it to the FACT-Finder. Note: If you plan to use proxy, consider reading below paragraph as it requires full instruction how to enable it properly.
  • How to count single click on "Add to cart" button? - select how would you like to count single click on "Add to cart" button
  • Send the SID as userId when user not logged in?

Proxy

Proxy feature adds a oxid controller which serves as a middleware between Web Components and FACT-Finder®. The data flow with proxy enabled is illustrated by the graph below. Communication Overview Having a middleware controller brings many possibilities to customize the request and the response. In addition, if forwarded request does not result with a correct response, you can implement fallback strategy, starting from this point.

   //src/Controller/SearchResultController.php:65
   protected function fallback(): void
    {
        //this function could be used to implement fallback logic in case of any communication error.
        $this->showJsonAndExit('');
    }

To enable proxy you need to change your HTTP server configuration by adding two rewrite rules. This is necessary because Web Components appends a URL parts to the base URL making it unreadable by the Oxid. This is because Oxid use query parameters cl and fnc to instantiate specific controller and execute its function. There is no routing that use url parts, hence any AJAX requests must target index.php file with the aforementioned parameters. Without this rules any request will lead to 404.

NGINX

  location ~ \.ff  {
      rewrite [a-zA-Z].ff /$1 break;
  }

  # the the version might need to be adjusted, depends on the API version you use
  location ~ /rest/v  {
      rewrite rest/v[0-9]/[a-zA-Z]*/ /$1 break;
   }

APACHE

RewriteRule (.*\.ff)$ /$1 [L]

# the the version might need to be adjusted, depends on the API version you use
RewriteRule /rest/v[0-9] /$1 [L]

Features Settings

Features Settings

  • Use FACT-Finder® for category pages? - check this option to use Web Components in category pages. More information in separate paragraph.
  • Campaigns - enables ff-campaign-product on product page and ff-campaign-feedbacktext, ff-campaign-shopping-carton cart page
  • Recommendations - enables ff-recommendation on product page
  • Similar products - enables ff-similar-products on product page
  • Pushed products - enables ff-campaign-pushed-products> on cart page

Using FACT-Finder® on category pages

Module in order to preserve categories URLs and hence SEO get use of standard Oxid routing with the combination of FACT-Finder® availability to pass custom parameters to search request. Once user lands on category page search event is emitted immediately (thanks to search-immediate communication parameter usage).

Feed Settings

Feed Settings This section allows setting attributes to export. If you want to export the attribute to separate column, choose it from the select input and set Multi-Attribute column value to No. if Multi-Attribute is set to Yes, the attribute is placed in an aggregate column FilterAttributes Note: Selection attributes are always placed in FilterAttributes automatically.

Export Settings

Export Settings

Use following fields if you want to export feed file to your FTP server, where it could be then imported by FACT-Finder®.

  • FTP host
  • FTP port
  • FTP user
  • FTP password

Additional:

  • SSL-enabled - check this option, if your FTP server requires connection using secure protocol
  • Automatic import of product - enables import executed by FACT-Finder® after uploading
    Note: This option will not work if you have no FTP server configured
  • Import Data - triggers Data (search database)
  • Import Suggest - triggers Suggest database
  • Import Recommendation - triggers Recommendation database
  • Basic Auth user for HTTP export
  • Basic Auth password for HTTP export
    Note: Basic Auth is used to secure HTTP based export, you can read more about in the next section.

Export Methods

HTTP Export

This method uses a specific URL under which the feed will be available. You can set FACT-Finder® to download the feed directly from this location:

[YOUR_SHOP_URL]?cl=http_article_feed&fnc=export

For category export:

[YOUR_SHOP_URL]?cl=http_category_feed&fnc=export

For suggest category export:

[YOUR_SHOP_URL]?cl=http_suggest_category_feed&fnc=export

Note: Please keep in mind that the feed file is not directly available under the location. There is an export mechanism that does it on demand, so the whole process may take some time.

Basic Authentication

Using Export Settings you can secure the HTTP export by setting up a Basic Authentication. Please remember that in this case you will need to include credentials in the URL, otherwise FACT-Finder® will not be able to download the feed file. You can include Basic Authentication credentials in URL using following syntax:

https://[username]:[password]@[REST_OF_URL]

FTP Export

With this approach, the exported feed file is uploaded to a specific FTP/SFTP server. Once the feed file is uploaded, FACT-Finder® is requested to begin an import based on uploaded file (optional). All settings related to this exporting method are found in Export Settings. Fields Key and Key Passphrase are dedicated only to the SFTP. Field SSL Enabled is dedicated only to FTP.

Note: Used FTP/SFTP server should be also accessible to FACT-Finder®.

Admin Panel Export

Export Feed button located in module configuration, could be used to manually trigger an export. By clicking this button, you trigger the whole export process, including upload to FTP server and triggering a FACT-Finder® import (if enabled).

Note: This method does not download the feed file to your local file system. If you need to view it, please use the HTTP Export

Note: Category export is not available here as clicking button start import on channel but category feed is supposed to be an enrichment for main article feed

Console Commands

There are two console commands located in the module bin directory, available for use. Simply run them using the installed PHP CLI.

php [MODULE_LOCATION]/bin/[COMMAND_NAME].php
  • feed-write.php - only saves the feed file on local file system
  • feed-upload.php - run full integration (just like clicking the Export Feed button in admin panel)

If you are using Oxid Enterprise and its multishop feature, you can specify the shop ID by using the -s parameter, e.g.

php source/modules/ff/ffwebcomponents/bin/feed-write.php -s1

If your shop supports multiple languages, enter the language identifier of the language you want to export by adding -l parameter to the command (e.g. php bin/feed-write.php -l 1). You can check the language identifiers at "Master Settings -> Languages". You can specify the type of the feed with the -t option. Default value is product. In order to switch for category, please use -t category

Languages

Tracking

Here you can find a full Tracking Guide. This module follows that guide in order to provide tracking of following events:

Login

This event is tracked automatically by the ff-communication element upon receiving uid attribute.

Click on Product

This event is tracked automatically by the ff-record element bindings. Note: for this to work a directive data-redirect has to be added

Add Product to Cart

We offer a registerAddToCartListener function which helps to register click events on form submit buttons. Note: Example usage can be found in src/views/frontend/blocks/campaign/product.tpl

Place an Order

This event is tracked by the ff-checkout-tracking element which is implemented on order confirmation page

Contribute

For more information, click here

You can also open a new issue if You spot a bug or just have an idea for module improvement To check currently opened issues here.

License

FACT-Finder® Web Components License. For more information see the LICENSE file.

oxid-eshop-module's People

Contributors

grzegorz-jamroz avatar paulfcdd avatar rayn93 avatar svenbrunk avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

oxid-eshop-module's Issues

ArticleFeed misses Filterattributes that are linked to Child-Articles

Imagine an article "MyFavouriteCar" available in two variants for motor power having 100 HP (= horse power) and 150 HP respectivly. Database would contain three records as follows: parent_mycar, child_100hp, child_150hp).OXVARNAME and OXVARSELECT are set accordingly for the 100HP and 150HP

Imagine attribute "Fuel Consumption" exists in the shop. Value assignments would be like:

  • child_100hp: "6 l/100km"
  • child_150hp: "10 l/100km"
    (it's obvious, that the stronger powered car has a higher fuel consumption)

You could also imagine an attribute called "Energy label"

  • child_100hp: "A++"
  • child_150hp: "A+"

Even if these attributes are enlisted as "filter attributes" in module settings, its values are not contained in the article feed.

Root cause can be found in FilterAttributes.php:29-33
in short: if $article is not parent, only the corresponding variant value is collected. Attributes assigned to the child are ignored.

General remark:
attributes value atttached to child articles usually show a direct functional dependence to the corresponding variant value. Here: fuelconsumption = f(horsepower) or energy_label = f(horse_power). Customer must have the possibility to filter for these values.

Export handler for FilterAttributes does not handle non-string values properly

}, [$parent->getFieldData('oxvarname'), $article->getFieldData('oxvarselect')])));
is a bit problematic.
I got this error in my instance a few times already:

Stack trace:
#0 [internal function]: Omikron\FactFinder\Oxid\Export\Field\FilterAttributes->Omikron\FactFinder\Oxid\Export\Field\{closure}()
#1 /var/www/integration/20210708T125103/vendor/omikron/oxid-factfinder/src/Export/Field/FilterAttributes.php(42): array_map()
#2 /var/www/integration/20210708T125103/vendor/omikron/oxid-factfinder/src/Export/Field/FilterAttributes.php(31): Omikron\FactFinder\Oxid\Export\Field\FilterAttributes->getVariantValues()
#3 /var/www/integration/20210708T125103/vendor/omikron/oxid-factfinder/src/Export/Entity/ArticleEntity.php(42): Omikron\FactFinder\Oxid\Export\Field\FilterAttributes->getValue()
#4 [internal function]: Omikron\FactFinder\Oxid\Export\Entity\ArticleEntity->Omikron\FactFinder in /var/www/integration/20210708T125103/vendor/omikron/oxid-factfinder/src/Export/Field/FilterAttributes.php on line 38

Admittedly this is due to corrupted data, but since this can seriously impact a shop as it will completely stop the FACT-Finder export from working, you should not rely on external code and data like this.

Remember, the getFieldData method of the OXID shop currently looks like this:

/**
 * Gets field data
 *
 * @param string $fieldName name (eg. 'oxtitle') of a data field to get
 *
 * @return mixed value of a data field
 */
public function getFieldData($fieldName)
{
    $longFieldName = $this->_getFieldLongName($fieldName);
    return ($this->$longFieldName instanceof Field) ? $this->$longFieldName->value : null;
}

So it can return anything. Including null

My proposal (even though it will degrade performance a little) is to either check those values and throw an error on null and continue with not impacted data rows, force them to be '' on null or change your code to allow for null in other ways.

New version tag needed

We need this line for the module to correctly talk to our shiny new FACT-Finder backend. Else the links within a landing page do not work and the DevConsole of the browser will only show an error message from the web components JavaScript that tracking campaigns does not work (BTW: It is good to throw an error in the console, but it is not good to prevent the links from functioning if the data-redirect-target is _self ... )

'api' => $this->getConfig('ffApiVersion') ? 'v4' : '',

So please, can we have a new release soon? :)

error if 3th-party module function is used / wrong class extension

hi guys,

this is not the way to extend an oxid class ;-) https://github.com/FACT-Finder-Web-Components/oxid-eshop-module/blob/master/src/Export/Data/ExportArticle.php

please see oxid docu for more information: https://docs.oxid-esales.com/developer/en/6.0/modules/good_practices/extend_shop_class.html

this extension doesn´t work if a function from an other oxid module is used, eg.:

Function 'sxGetAttributeValue' does not exist or is not accessible! (Omikron\FactFinder\Oxid\Export\Data\ExportArticle)

regards

feed export

oxid enterprise 6.2

source/modules/ff/ffwebcomponents/bin/feed-upload.php -s 2

always exports the same data, no matter which shop id is used. already talked with @fmarangi about this problem ...

Session Issues and missing URL-Parameters

Module was implemented in OXID EE 6.4.1 with PHP 7.1
Customizations are made in an own Module. Bugs appear also in default/vanilla configuration without the own written module.

Session Issues
Search as a registered customer: The Session terminates and the customer is logged out.
Click path: Log in as Customer -> back to startpage -> search in header search field
Session Handling is working as long as the customer stays on the searchResultPage. After changing to another page e.g product detail page, the next search will cause a log out because of the lost Session.

URL-Parameter issues:
The Url parameter of the controller is not always passed.
Click path: Do multiple searches on the result page. After a couple of searches the URL-Parameter of the controller ist missing.
Instead of https://myshop.com/index.php?cl=search_result&query=test
it's
https://myshop.com/index.phpt&query=test
which does not allow to reload the page without getting redirected to the start page.

Thanks in advance and kind regards

Use Web Components SID

As for now the module is generating custom SID, base on real session id. This could be problematic to track continuity of customer actions when he logs in and his real session id is changed.

Missing logging capabilities

Recently, the http article-feed was found to have no response. Closer inspection offered the cause in poor data quality an not related to ff-module, but debugging the module offered some issues that are worth to note here:

1.) ArticleFeedController.php capsules all export funtionallity in a single try-finally-block, leaving exceptions to evaporate into open sky. Dev has no chance to find any initial hint what's going on. Time consuming line debugging is required. Please catch exception and log $e->message() to oxideshop.log appropriately.

2.) Structure of the module offers surprises: all code is copied to source/module/ff but php-code is executed below vendor/ exclusivly. Any break point set in source/modules is never met. For js the situation is vice versa.

3.) Pls consider changing the export strategy: any exception related to a single article causes the breakdown of the overall stream. Isn't it better behaviour if this exception is logged an this particular article is removed from stream? Doing so, would be a much more ruggedized approach.

tnx

Dangerous change in scripts.tpl

Hello :)

I wanted to warn you about the change you did in scripts.tpl in commit 6786323
(In the meantime you even added some more usages on top)
The oConfig variable used here is available in any eShop in default configuration, but it depends on the performance setting to load languages to be active.
If this is not active, the variable does not exist and several shop pages cease to function.

I can mitigate that in our project and I would also question this dependency towards our development department, but nonetheless I wanted to warn you about it.

Configuration for specific language

The module allows to export feeds for specific languages via CLI command using lang parameter, however Oxid doesn't offer possibility to set configuration value for specific language. It means that all languages for given shop will be using the same FACT-Finder channel

Custom attribute export

As a store admin, I want to be able to define which custom attributes should be added to the product feed. Attributes can be stored in dedicated fields, or in a Multi-Attributes field (i.e. for filterable values).

Special chars in attribute names break feed settings

Customer had an attribute with Title Shopattribute "New"
When open module setting page section feed settings, adding a new attribute is not possible and stored attributes are not displayed.
Quotation marks in titles destroy json structure.
Steps to reproduce:

  • Create an attribute with Quotation marks in Title
  • Open settings page for oxid module

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.