Get Prices of Attributes

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Moritz
Advanced
Posts: 158
Joined: 07 Nov 2018, 14:05

Get Prices of Attributes

Post by Moritz » 22 Nov 2024, 12:16

In my template I call $attr->getRefItems('price', null, 'default') in the foreach loop and get no prices.
The attribute $attr generally has no ref items.

Code: Select all

$productItem = $this->get('productItem', null);

if (isset($productItem)) {
    $attrPrices = [];

    $attributes = $productItem->getRefItems('attribute', null, 'hidden');
    foreach ($attributes as $attr) {
        $attrPrices = array_merge($attrPrices, $attr->getRefItems('price', null, 'default')->toArray());
    }
}
PHP 8.2.24
Typo3 v12.4.23 LTS
Aimeos web shop 24.10.2

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

Re: Get Prices of Attributes added by Supplier

Post by aimeos » 25 Nov 2024, 11:40

Check if the hidden attributes assigned to the product have prices and if they are loaded by passing the correct referenced domains (at least ['attribute', 'price'] in your case).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Moritz
Advanced
Posts: 158
Joined: 07 Nov 2018, 14:05

Re: Get Prices of Attributes added by Supplier

Post by Moritz » 25 Nov 2024, 14:13

Yes the hidden attributes have prices and are assigned to the product.
In my code example you see how I try to load the prices of the attributes but I get nothing.

I use your ai-customergroups v24.10.2 extension and found out, that it works when I disable the extension.
PHP 8.2.24
Typo3 v12.4.23 LTS
Aimeos web shop 24.10.2

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

Re: Get Prices of Attributes added by Supplier

Post by aimeos » 25 Nov 2024, 14:23

Can you please execute

Code: Select all

composer req aimeoscom/ai-customergroups:2024.10.x-dev
and run the setup tasks again? The "key" column wasn't migrated correctly.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Moritz
Advanced
Posts: 158
Joined: 07 Nov 2018, 14:05

Re: Get Prices of Attributes added by Supplier

Post by Moritz » 27 Nov 2024, 15:03

We have already written a lot on Github about the migration of ai-customergroups.
That works now.
But when the ai-customergroups extension is active, I don't get any prices from the attribute in this line from my code example above.

Code: Select all

$attrPrices = array_merge($attrPrices, $attr->getRefItems('price', null, 'default')->toArray());
When I disable ai-customergroups it works and I get prices.
PHP 8.2.24
Typo3 v12.4.23 LTS
Aimeos web shop 24.10.2

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

Re: Get Prices of Attributes added by Supplier

Post by aimeos » 28 Nov 2024, 11:56

Tested locally with ai-customergroups:2024.10.x-dev installed by adding a hidden attribute with a price to a product and fetching/displaying it in the catalog detail view worked without problems. The pure existence of the ai-customergroups extension can't be the reason for that. Did you assign a customer or group to that price of the hidden attribute?

Make sure, you've installed the latest aimeos/aimeos-typo3:2024.10.x-dev release because the Aimeos TYPO3 extension has an unreleased fix for group handling.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Moritz
Advanced
Posts: 158
Joined: 07 Nov 2018, 14:05

Re: Get Prices of Attributes

Post by Moritz » 28 Nov 2024, 16:26

I have tested with 2024.10.x-dev version of Aimeos and ai-customergroups aswell.
In the checkItem() function of CustomerGroup you can see, that the item has no listItems.

checkItem.png
checkItem.png (46.88 KiB) Viewed 37513 times

But in the backend this attribute has a price item assigned.

attr_price.png
attr_price.png (28.15 KiB) Viewed 37513 times

When I comment out this lines (disable ai-customergroups) I get the price of the attribute correctly.

Code: Select all

plugin.tx_aimeos.settings.mshop.attribute.manager.decorators.global.CustomerGroup = CustomerGroup
plugin.tx_aimeos.settings.mshop.catalog.manager.decorators.local.CatalogCustomerGroup = CatalogCustomerGroup
plugin.tx_aimeos.settings.mshop.index.manager.decorators.local.IndexCustomerGroup = IndexCustomerGroup
plugin.tx_aimeos.settings.mshop.media.manager.decorators.global.CustomerGroup = CustomerGroup
plugin.tx_aimeos.settings.mshop.price.manager.decorators.global.CustomerGroup = CustomerGroup
PHP 8.2.24
Typo3 v12.4.23 LTS
Aimeos web shop 24.10.2

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

Re: Get Prices of Attributes

Post by aimeos » 29 Nov 2024, 14:23

The problem is that this TypoScript configuration overwrites the default decorators:

Code: Select all

plugin.tx_aimeos.settings.mshop.attribute.manager.decorators.global.CustomerGroup = CustomerGroup
plugin.tx_aimeos.settings.mshop.catalog.manager.decorators.local.CatalogCustomerGroup = CatalogCustomerGroup
plugin.tx_aimeos.settings.mshop.index.manager.decorators.local.IndexCustomerGroup = IndexCustomerGroup
plugin.tx_aimeos.settings.mshop.media.manager.decorators.global.CustomerGroup = CustomerGroup
plugin.tx_aimeos.settings.mshop.price.manager.decorators.global.CustomerGroup = CustomerGroup
When using these line, it works as expected:

Code: Select all

plugin.tx_aimeos.settings.mshop.attribute.manager.decorators.global {
  CustomerGroup = CustomerGroup
  Lists = Lists
  Property = Property
  Type = Type
}
plugin.tx_aimeos.settings.mshop.catalog.manager.decorators.local {
  CatalogCustomerGroup = CatalogCustomerGroup
}
plugin.tx_aimeos.settings.mshop.index.manager.decorators.local {
  IndexCustomerGroup = IndexCustomerGroup
}
plugin.tx_aimeos.settings.mshop.media.manager.decorators.global {
  CustomerGroup = CustomerGroup
  Lists = Lists
  Property = Property
  Type = Type
}
plugin.tx_aimeos.settings.mshop.price.manager.decorators.global {
  CustomerGroup = CustomerGroup
  Lists = Lists
  Property = Property
  Type = Type
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Moritz
Advanced
Posts: 158
Joined: 07 Nov 2018, 14:05

Re: Get Prices of Attributes

Post by Moritz » 02 Dec 2024, 09:46

With that TypoScript it works.
Maybe you can change the instruction in README.md of ai-customergroups.
PHP 8.2.24
Typo3 v12.4.23 LTS
Aimeos web shop 24.10.2

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

Re: Get Prices of Attributes

Post by aimeos » 02 Dec 2024, 09:47

That have already been updated in the latest version of the extension
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply