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

Issue Importing Certain Products Based on a Custom Meta Data Field #108

Closed
sm9 opened this issue Apr 22, 2024 · 2 comments
Closed

Issue Importing Certain Products Based on a Custom Meta Data Field #108

sm9 opened this issue Apr 22, 2024 · 2 comments
Labels
bug Something isn't working Plugins → Shopify For Linear sync Plugins For Linear sync

Comments

@sm9
Copy link

sm9 commented Apr 22, 2024

Description

Hi there, we're trying to follow the guide in the readme here, so that we can only import certain products based on a custom meta data field. Perhaps we've misunderstood how this works, but we tried to change the conditional from:

if ($event->metafields['do_not_sync'] ?? false) {

to

if ($event->metafields['custom.sync_to_craft']) {

But we're seeing this error:

Exception 'yii\base\UnknownPropertyException' with message 'Getting unknown property: craft\shopify\events\ShopifyProductSyncEvent::metafields'

in ../vendor/yiisoft/yii2/base/BaseObject.php:141

Stack trace:
#0 ../modules/base/Module.php(77): yii\base\BaseObject->__get('metafields')
#1 [internal function]: modules\base\Module->modules\base\{closure}(Object(craft\shopify\events\ShopifyProductSyncEvent))
#2 ../vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\shopify\events\ShopifyProductSyncEvent))
#3 ../vendor/yiisoft/yii2/base/Component.php(642): yii\base\Event::trigger('craft\\shopify\\s...', 'beforeSynchroni...', Object(craft\shopify\events\ShopifyProductSyncEvent))
#4 ../vendor/craftcms/shopify/src/services/Products.php(193): yii\base\Component->trigger('beforeSynchroni...', Object(craft\shopify\events\ShopifyProductSyncEvent))
#5 ../vendor/craftcms/shopify/src/services/Products.php(76): craft\shopify\services\Products->createOrUpdateProduct(Object(Shopify\Rest\Admin2023_10\Product), Array, Array)
#6 ../vendor/craftcms/shopify/src/services/Products.php(90): craft\shopify\services\Products->_updateProduct(Object(Shopify\Rest\Admin2023_10\Product))
#7 ../vendor/craftcms/shopify/src/console/controllers/SyncController.php(50): craft\shopify\services\Products->syncAllProducts()
#8 ../vendor/craftcms/shopify/src/console/controllers/SyncController.php(32): craft\shopify\console\controllers\SyncController->_syncProducts()
#9 [internal function]: craft\shopify\console\controllers\SyncController->actionAll()
#10 ../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 ../vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#12 ../vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
#13 ../vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('all', Array)
#14 ../vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction('all', Array)
#15 ../vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('all', Array)
#16 ../vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('shopify/sync/al...', Array)
#17 ../vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('shopify/sync/al...', Array)
#18 ../vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('shopify/sync/al...', Array)
#19 ../vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#20 ../vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#21 ../craft(13): yii\base\Application->run()
#22 {main}

Do you have any ideas where we might be going wrong, or have we hit a bug?

Thanks in advance for any help or advice!

Stephen

Additional info

  • Craft version: 4.7.4
  • PHP version: 8.1
  • Database driver & version: MariaDB 11.1.3
  • Plugins & versions: Shopify 4.1.2
@sm9 sm9 added bug Something isn't working Plugins For Linear sync Plugins → Shopify For Linear sync labels Apr 22, 2024
Copy link

linear bot commented Apr 22, 2024

@lukeholder
Copy link
Member

lukeholder commented Apr 24, 2024

Hi Stephen,

The documentation looks wrong, sorry. The event no longer has a metafields array property, you would need to look at the elements meta fields.

Like this:

$metaFields = $event->element->getMetaFields();

We will fix the documentation. Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Plugins → Shopify For Linear sync Plugins For Linear sync
Projects
None yet
Development

No branches or pull requests

2 participants