favorite icon

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Dinver
Posts: 27
Joined: 26 Oct 2020, 08:42

favorite icon

Post by Dinver » 15 Nov 2020, 10:59

Hi, there is simple way set favorite/watch icon (on / off), how on ebay or aliexpress?

Image

User avatar
aimeos
Administrator
Posts: 7882
Joined: 01 Jan 1970, 00:00

Re: favorite icon

Post by aimeos » 16 Nov 2020, 10:41

You can enable/disable them using this configuration:
https://aimeos.org/docs/2020.x/config/c ... ions/#list

Add new ones in your own version of this template:
https://github.com/aimeos/ai-client-htm ... andard.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Dinver
Posts: 27
Joined: 26 Oct 2020, 08:42

Re: favorite icon

Post by Dinver » 16 Nov 2020, 13:08

aimeos wrote: 16 Nov 2020, 10:41 You can enable/disable them using this configuration:
https://aimeos.org/docs/2020.x/config/c ... ions/#list

Add new ones in your own version of this template:
https://github.com/aimeos/ai-client-htm ... andard.php
I edited template. I'm interested in how to determine if a product is on the favorites list. For change icon in template.

User avatar
aimeos
Administrator
Posts: 7882
Joined: 01 Jan 1970, 00:00

Re: favorite icon

Post by aimeos » 18 Nov 2020, 08:05

You may use the JSON REST API to check if the product is in the customers favorite list:
https://aimeos.org/docs/latest/frontend ... relations/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Dinver
Posts: 27
Joined: 26 Oct 2020, 08:42

Re: favorite icon

Post by Dinver » 20 Nov 2020, 07:42

aimeos wrote: 18 Nov 2020, 08:05 You may use the JSON REST API to check if the product is in the customers favorite list:
https://aimeos.org/docs/latest/frontend ... relations/
How get customers favorite list, in template?

User avatar
aimeos
Administrator
Posts: 7882
Joined: 01 Jan 1970, 00:00

Re: favorite icon

Post by aimeos » 21 Nov 2020, 10:16

Use the jQuery example from the docs:

Code: Select all

var url = response['links']['customer/relationships']['href']; // from customer response
var args = {include: "product"};
var params = {};

if(options.meta.prefix) { // returned from OPTIONS call
    params[options.meta.prefix] = args;
} else {
    params = args
}

$.ajax({
    url: url,
    method: "GET",
    dataType: "json",
    data: params
}).done( function( result ) {
    console.log( result.data );
});
This requires the customer to be logged in. Contrary, pinned products are session based without the need to log in.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Dinver
Posts: 27
Joined: 26 Oct 2020, 08:42

Re: favorite icon

Post by Dinver » 23 Nov 2020, 15:08

aimeos wrote: 21 Nov 2020, 10:16 Use the jQuery example from the docs:

Code: Select all

var url = response['links']['customer/relationships']['href']; // from customer response
var args = {include: "product"};
var params = {};

if(options.meta.prefix) { // returned from OPTIONS call
    params[options.meta.prefix] = args;
} else {
    params = args
}

$.ajax({
    url: url,
    method: "GET",
    dataType: "json",
    data: params
}).done( function( result ) {
    console.log( result.data );
});
This requires the customer to be logged in. Contrary, pinned products are session based without the need to log in.

Code: Select all

const url = '/jsonapi/customer'
		const params = {
			related: 'relationships',
			include: 'product',
			filter: {
        '==': {'customer.lists.type': 'favorite'}
    	},
			fields: {
        'customer/lists': 'id'
    	}
		}

		$.ajax({
				url: url,
				method: "GET",
				dataType: "json",
				data: params
		}).done( function( result ) {
				console.log( result.data )
		})
Returned all item favorites and item watched. Filter not working. Is there any way to return the id array, whithout trash json data?

User avatar
aimeos
Administrator
Posts: 7882
Joined: 01 Jan 1970, 00:00

Re: favorite icon

Post by aimeos » 25 Nov 2020, 18:03

Yes, the endpoint doesn't support filtering but you can limit the returned fields using:

Code: Select all

const url = '/jsonapi/customer';
const params = {
	related: 'relationships',
	include: 'product',
	fields: {
	        'customer/lists': 'customer.lists.refid,customer.lists.type'
    	}
};

$.ajax({
	url: url,
	method: "GET",
	dataType: "json",
	data: params
}).done( function( result ) {
	console.log( result.data )
});
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Dinver
Posts: 27
Joined: 26 Oct 2020, 08:42

Re: favorite icon

Post by Dinver » 26 Nov 2020, 11:12

aimeos wrote: 25 Nov 2020, 18:03 Yes, the endpoint doesn't support filtering but you can limit the returned fields using:

Code: Select all

const url = '/jsonapi/customer';
const params = {
	related: 'relationships',
	include: 'product',
	fields: {
	        'customer/lists': 'customer.lists.refid,customer.lists.type'
    	}
};

$.ajax({
	url: url,
	method: "GET",
	dataType: "json",
	data: params
}).done( function( result ) {
	console.log( result.data )
});
Thanks! Is it possible to exclude from the response "links"?

I create action add product to cart "jsonapi/basket?Id=default&related=product". In response come a lot of unnecessary data. How to leave only data/attributes?

User avatar
aimeos
Administrator
Posts: 7882
Joined: 01 Jan 1970, 00:00

Re: favorite icon

Post by aimeos » 27 Nov 2020, 13:20

No, the links section is required by the jsonapi.org standard which this API follows.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply