Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUPPORT MULTI-SELECT ATTRIBUTES #16

Open
kestraly opened this issue Aug 14, 2023 · 2 comments
Open

SUPPORT MULTI-SELECT ATTRIBUTES #16

kestraly opened this issue Aug 14, 2023 · 2 comments

Comments

@kestraly
Copy link

kestraly commented Aug 14, 2023

Preconditions (*)

  1. Magento 2.4.6
  2. PHP 8.1

Steps to reproduce (*)

  1. Create attribute set it as multiselect.
  2. Select two options on the attribute for the product
  3. Save product
  4. Go to Meta > Configuration and select custom attribute mapping

Expected result (*)

  1. Catalog correctly syncs

Actual result (*)

  1. Failure to sync
  2. Cannot convert array to string vendor/meta/module-catalog/Model/Product/Feed/Builder.php - Line 295

Possible solution

if (is_array($attrValue)) $attrValue = implode(',', $attrValue);

@kestraly kestraly changed the title Multi Select Attribute For Brand Attribute Produces String Error SUPPORT MULTI-SELECT ATTRIBUTES Nov 14, 2023
@kestraly
Copy link
Author

kestraly commented Nov 14, 2023

Alternative solution

/app/code/Meta/Catalog/Model/Product/Feed/Builder/AdditionalAttributes.php

public function getCorrectText(Product $product, string $attribute)
    {
        if ($product->getData($attribute)) {
            $text = $product->getAttributeText($attribute);
            if (!$text) {
                $text = $product->getData($attribute);   
            }
            if (is_array($text))  $text = implode(', ', $text);
            return $text;
        }
        return false;
    }

@kestraly
Copy link
Author

Pull request added
#45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant