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

Commerce fields - Fix not matching elements when limiting to a source #522

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/fields/CommerceProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/fields/CommerceVariants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions src/fields/DefaultField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/fields/DigitalProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down