From 2275b431aebfe7a66dcc802693069f0861b78bab Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Fri, 19 Apr 2019 19:43:48 +1000 Subject: [PATCH 1/2] Commerce fields - Fix not matching elements when limiting to a source --- src/fields/CommerceProducts.php | 3 ++- src/fields/CommerceVariants.php | 3 ++- src/fields/DigitalProducts.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fields/CommerceProducts.php b/src/fields/CommerceProducts.php index 22171272..2bc4b56e 100644 --- a/src/fields/CommerceProducts.php +++ b/src/fields/CommerceProducts.php @@ -8,6 +8,7 @@ use craft\feedme\base\Field; use craft\feedme\base\FieldInterface; use craft\feedme\Plugin; +use craft\helpers\Db; class CommerceProducts extends Field implements FieldInterface { @@ -48,7 +49,7 @@ public function parseField() if (is_array($sources)) { foreach ($sources as $source) { list($type, $uid) = explode(':', $source); - $typeIds[] = $uid; + $typeIds[] = Db::idByUid('{{%commerce_producttypes}}', $uid); } } else if ($sources === '*') { $typeIds = null; diff --git a/src/fields/CommerceVariants.php b/src/fields/CommerceVariants.php index 5689fce8..66272774 100644 --- a/src/fields/CommerceVariants.php +++ b/src/fields/CommerceVariants.php @@ -8,6 +8,7 @@ use craft\feedme\base\Field; use craft\feedme\base\FieldInterface; use craft\feedme\Plugin; +use craft\helpers\Db; class CommerceVariants extends Field implements FieldInterface { @@ -48,7 +49,7 @@ public function parseField() if (is_array($sources)) { foreach ($sources as $source) { list($type, $uid) = explode(':', $source); - $typeIds[] = $uid; + $typeIds[] = Db::idByUid('{{%commerce_producttypes}}', $uid); } } else if ($sources === '*') { $typeIds = null; diff --git a/src/fields/DigitalProducts.php b/src/fields/DigitalProducts.php index e0d69c4e..2b5ad74c 100644 --- a/src/fields/DigitalProducts.php +++ b/src/fields/DigitalProducts.php @@ -8,6 +8,7 @@ use craft\feedme\base\Field; use craft\feedme\base\FieldInterface; use craft\feedme\Plugin; +use craft\helpers\Db; class DigitalProducts extends Field implements FieldInterface { @@ -48,7 +49,7 @@ public function parseField() if (is_array($sources)) { foreach ($sources as $source) { list($type, $uid) = explode(':', $source); - $typeIds[] = $uid; + $typeIds[] = Db::idByUid('{{%digitalproducts_producttypes}}', $uid); } } else if ($sources === '*') { $typeIds = null; From 86ae07ac46d30a02439871db77f3f2816dc31717 Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Thu, 3 Oct 2019 12:23:53 +1000 Subject: [PATCH 2/2] Update DefaultField.php --- src/fields/DefaultField.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fields/DefaultField.php b/src/fields/DefaultField.php index d2f4440c..a6be4239 100644 --- a/src/fields/DefaultField.php +++ b/src/fields/DefaultField.php @@ -44,9 +44,13 @@ public function parseField() if ($value !== '') { $value = $this->field->normalizeValue($value); } - + // Lastly, get each field to prepare values how they should - $value = $this->field->serializeValue($value); + try { + $value = $this->field->serializeValue($value); + } catch (\Throwable $e) { + // Ignore + } return $value; }