Download the PHP package drunomics/amazon_product_widget without Composer

On this page you can find all versions of the php package drunomics/amazon_product_widget. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package amazon_product_widget

Deprecated: moved to https://www.drupal.org/project/amazon_product_widget

Amazon product widget

Provides a field widget to render amazon products given ASINs.

The product data will be fetched from Amazon using the Product Advertising API. Once the data is fetched it will be cached locally to stay withins Amazons request limit.

On top of that the widget itself will be loaded via Ajax which will be cached in the response. This way an article or page can be cached indefinitely but the amazon products will be updated regularly disregarding the sites overall caching strategy.

Table of content

Features

Requirements

You will need an Amazon Associates account and register it for the Product Advertising API to get the credentials needed.

Installation

Configuration

Amazon settings configuration

Enable & configure the amazon_paapi module, which was install with composer, see README of the module.

Amazon product widget configuration

Set the following amazon_product_widget.settings configuration:

Add the Amazon product widget field to a node or paragraph and configure form & display.

Deals configuration

Set the following amazon_product_widget.deal_settings configuration:

Caching and request limits

Amazon has very specific requirements regarding request limits (see Efficiency Guidelines.) so it is necessary to cache the data locally and update it on a regular basis via cronjob. At least there is a base limit per day (8640) and one per second, these can be overriden if needed.

When the data is saved it will set a renewal date (which is 48 hours by default) for when the cronjob will try to update the data form amazon again. The next renewal can be overridden in the setting (in hours):

amazon_product_widget.products.renewal_time amazon_product_widget.search_results.renewal_time

The number of items which will be renewed per cron run is by default 100, and can be set in this setting:

amazon_product_widget.products.renewal_limit amazon_product_widget.search_results.renewal_limit

Permissions

Usage

In the form widget, enter one or more ASINs for the products which should be displayed by default. Amazon Standard Identification Numbers (ASINs) are unique blocks of 10 letters and/or numbers that identify items. You can find the ASIN on the item's product information page at Amazon.

Optionally enter search terms which will be used when the products are unavailable to list the search results in place of the entered products.

Overrides

The module allows for overrides to be set for each individual product. This is useful if you want to set any custom data to be stored along with product information, like override images, title, etc. To set an override, simply use the 'amazon_product_widget.product_service' service and call the method setOverrides(). The argument is an array. Each key should be the product ASIN you are setting the overrides for. The value can be any type.

An example:

The overrides are now set. You can get them back by calling getProductData(['B00318CA92']) which will return:

Commands

Basic commands

The module comes with a set of commands which you can use to interact with the modules functionality.

Queues all products for renewal, this will be done in the next cron run.

Runs the product renewal immediately without waiting for cron. When the request limit is reached, this command will stop and show the number of products still waiting for renewal. You can run it multiple times to update all products.

Shows the number of stale products (needing updating) that are currently in the database.

Override commands

Shows the overrides stored for the product with the provided ASIN.

Resets all renewals so that all the products in the database will be considered stale and updated on the next cron run.

Deals commands

The following commands are available related to the Deals Feed API.

Gets the total number of active deals currently in the Deal store.

Updates the Deals store with the deals provided in CSV file. If no path is provided, the file will be downloaded from the Amazon API (if configured).

Gets Deal information for a particular ASIN.

Usage commands

The following commands are available to get information about product usage.

Returns products that are contained in the given entity. <entity_type> is optional and defaults to 'node'.

Returns the entity ID and type that contain the given product (ASIN).

Hooks

The module provides the following hooks:

hook_amazon_product_widget_alter_product_data(array &$products_container, AmazonProductField $product_field, NodeInterface $node = NULL)

It allows modification of product data passed to the product widget template. You would modify the product data in the product container. Also passed is the Amazon product field, and lastly the node on which the field is being displayed on. This can also be NULL in the case where the field is attached to a taxonomy term.

hook_amazon_product_widget_alter_validate_product_data(AmazonProductField $product_field, array $product_data)

Allows you to validate if the product is valid. This allows you to show the amazon product widget even though the product is not available, then you can, for example, show your own custom message instead of the product box being absent altogether.

hook_amazon_product_widget_get_custom_asin_map(FieldableEntityInterface $entity)

Whenever an entity is saved, an ASIN map in the database gets updated, so we always know which entity contains which products (ASINs) and which product belongs to which entities.

If you have products (ASINs) stored in a custom field in an entity, you can extract and return them here, they will be added to the ASIN map for that entity.

Maintainers

Supporting organizations:


All versions of amazon_product_widget with dependencies

PHP Build Version
Package Version
Requires drunomics/amazon_paapi Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package drunomics/amazon_product_widget contains the following files

Loading the files please wait ....