-
Notifications
You must be signed in to change notification settings - Fork 143
Description
I have mapped a XML import element to the field Commerce Product inside a matrix field. I have chosen Data Provided this Entry is: Slug AND I also tried Title.
The relationship is not imported.
Here is the FeedMe setting, also tried Title:
Here is the XML setup as referenced in the setting above. I added CDATA due to characters, but when using slug I did not add CDATA.
Here is the content block with no relationship, even though the other products exist (I did an import several times) and are in the feed:
If I switch the field to a Commerce Variant (because I can still see all the products in the list) it still does not work.
If I don't put the Related Field in a Matrix block, so its its own separate field, it also does not work.
FeedMe: v4.1.0
Craft CMS: Craft Solo 3.2.0-RC2
Update 1
When I do an import, this is the query array created in src/fields/CommerceProducts.php, but it does not return any matches. So is the query array correct?
Array
(
[siteId] => 1
[status] =>
[typeId] => Array
(
[0] => b755d0ac-93fb-4de5-9b00-8ca3fa970af0
)
[limit] =>
[where] => Array
(
[0] => =
[1] => slug
[2] => mcs-64
)
)
The only other hunch is if I am relating to entries in my import, are perhaps all entries deleted first, and then when it imports the entry with those slugs dont exist? I can't imagine it woudl do this, I have chosen settings Add & Update.
Update 2
I believe the array is wrong and so the created SQL is wrong. The created SQL is as follows and includes WHERE (commerce_products.typeId='b755d0ac-93fb-4de5-9b00-8ca3fa970af0') - but typeId is not a uid in commerce_products, and even then, the above ID is not a commerce_product uid anyway, but the commerce_producttypes uid.
SELECT `elements`.`id`, `elements`.`fieldLayoutId`, `elements`.`uid`, `elements`.`enabled`, `elements`.`archived`, `elements`.`dateCreated`, `elements`.`dateUpdated`, `elements_sites`.`slug`, `elements_sites`.`siteId`, `elements_sites`.`uri`, `elements_sites`.`enabled` AS `enabledForSite`, `commerce_products`.`id`, `commerce_products`.`typeId`, `commerce_products`.`promotable`, `commerce_products`.`freeShipping`, `commerce_products`.`postDate`, `commerce_products`.`expiryDate`, `commerce_products`.`defaultPrice`, `commerce_products`.`defaultVariantId`, `commerce_products`.`defaultSku`, `commerce_products`.`defaultWeight`, `commerce_products`.`defaultLength`, `commerce_products`.`defaultWidth`, `commerce_products`.`defaultHeight`, `commerce_products`.`taxCategoryId`, `commerce_products`.`shippingCategoryId`, `commerce_products`.`availableForPurchase`, `content`.`id` AS `contentId`, `content`.`title`, `content`.`field_address`, `content`.`field_countryName`, `content`.`field_customLink`, `content`.`field_customSolutionsText`, `content`.`field_customSolutionsVideo`, `content`.`field_duplicated`, `content`.`field_mapCode`, `content`.`field_moreInfoPopUpText`, `content`.`field_oldSiteParentId`, `content`.`field_oldSitePostId`, `content`.`field_openingText`, `content`.`field_pageTitleOverride`, `content`.`field_phoneNumber`, `content`.`field_showDuplicatedProductContent`, `content`.`field_siteEnabled`, `content`.`field_specialistCategory`, `content`.`field_nonTranslatableTitle`, `content`.`field_uniqueIdentifier`
FROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`
FROM `elements` `elements`
INNER JOIN `commerce_products` `commerce_products` ON `commerce_products`.`id` = `elements`.`id`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`
INNER JOIN `content` `content` ON (`content`.`elementId` = `elements`.`id`) AND (`content`.`siteId` = `elements_sites`.`siteId`)
WHERE (`commerce_products`.`typeId`='b755d0ac-93fb-4de5-9b00-8ca3fa970af0') AND (`slug` = 'mcs-64') AND (`elements_sites`.`siteId`='1') AND (`elements`.`archived`=FALSE) AND (`elements`.`dateDeleted` IS NULL) AND (`elements_sites`.`enabled`=TRUE) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)
ORDER BY `commerce_products`.`postDate` DESC) `subquery`
INNER JOIN `commerce_products` `commerce_products` ON `commerce_products`.`id` = `subquery`.`elementsId`
INNER JOIN `elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`
INNER JOIN `content` `content` ON `content`.`id` = `subquery`.`contentId`
ORDER BY `commerce_products`.`postDate` DESC
If I just delete that part, it returns the correct related products.
Note: in the field settings I chose a Type to relate products to. I have not tried doing it with All selected. Maybe its only apparent when a Type is chosen.
So commenting out this in the file, makes it work for me for the normal field, but it still does not import into the matrix field as I guess thats managed in the Matrix field file.
//$criteria['typeId'] = $typeIds;
I will change the way I am building this site to utilise its own related field and not in Matrix, but this obviously should be addressed anyway.


