nystudio107 / craft-instantanalytics-ga4

Instant Analytics brings full Google GA4 server-side analytics support to your Twig templates and automatic Craft Commerce integration
Other
3 stars 4 forks source link

Brand field not available #2

Closed bossanova808 closed 1 year ago

bossanova808 commented 1 year ago

(Latest of both Craft and this plugin obviously)

My brand field is not available in this list:

image

It is an Entries field:

image

How is this selection built? Is it e.g. filtering out fields that are not on ALL product types perhaps?

In the past I have used code to add the brand, by the looks of thing, but be easier if I could just select the field (and ideally a fallback value if the field is empty or N/A)

khalwat commented 1 year ago

Yeah it's a bug, you should be able to select the field. Will get it fixed.

This is what it is doing currently:

        $commerceFields = [];

        if (self::$commercePlugin !== null) {
            $productTypes = self::$commercePlugin->getProductTypes()->getAllProductTypes();

            foreach ($productTypes as $productType) {
                $productFields = $this->getPullFieldsFromLayoutId($productType->fieldLayoutId);
                /** @noinspection SlowArrayOperationsInLoopInspection */
                $commerceFields = array_merge($commerceFields, $productFields);
                if ($productType->hasVariants) {
                    $variantFields = $this->getPullFieldsFromLayoutId($productType->variantFieldLayoutId);
                    /** @noinspection SlowArrayOperationsInLoopInspection */
                    $commerceFields = array_merge($commerceFields, $variantFields);
                }
            }
        }
bossanova808 commented 1 year ago

That seems like it should work...?

khalwat commented 1 year ago

Added in 4.0.0-beta.2