+
+
+
+ Extends the official Akeneo Connector with several features and optimizations.
+
+ Report Bug
+ ยท
+ Request Feature
+
+[PHP-badge]: https://img.shields.io/badge/PHP-777BB4?style=for-the-badge&logo=php&logoColor=white
+[PHP-url]: https://www.php.net/
+[Magento-badge]: https://img.shields.io/badge/Magento-EE672F?style=for-the-badge&logo=magento&logoColor=white
+[Magento-url]: https://business.adobe.com/products/magento/magento-commerce.html
+[Akeneo-badge]: https://img.shields.io/badge/Akeneo-7C1B8A?style=for-the-badge&logo=akeneo&logoColor=white
+[Akeneo-url]: https://www.akeneo.com/
diff --git a/Plugin/CategoryExist.php b/Service/CategoryExist.php
similarity index 92%
rename from Plugin/CategoryExist.php
rename to Service/CategoryExist.php
index 86f6b9b..3e91de4 100644
--- a/Plugin/CategoryExist.php
+++ b/Service/CategoryExist.php
@@ -1,6 +1,7 @@
config->getValue('akeneo_connector/justbetter/categoryexist', ScopeInterface::SCOPE_WEBSITE);
if (!$extensionEnabled) {
@@ -24,12 +25,12 @@ public function beforeSetValues()
}
$connection = $this->entitiesHelper->getConnection();
-
$stores = $this->storeHelper->getStores('lang');
+
foreach ($stores as $local => $affected) {
foreach ($affected as $store) {
$columnName = 'url_key-' . $store['lang'];
-
+
$query = "
UPDATE tmp_akeneo_connector_entities_category temp
LEFT JOIN catalog_category_entity_varchar eav ON (
@@ -43,14 +44,14 @@ public function beforeSetValues()
FROM eav_entity_type
WHERE entity_type_code = 'catalog_category'
)
- AND eav.`value` != ''
+ AND eav.value != ''
)
AND eav.store_id = {$store['store_id']}
)
SET temp.`{$columnName}` = eav.value
WHERE temp._is_new = 0 AND eav.value IS NOT NULL
";
-
+
$connection->query($query);
}
}
diff --git a/Service/CheckWebsiteAssociation.php b/Service/CheckWebsiteAssociation.php
new file mode 100644
index 0000000..7dae384
--- /dev/null
+++ b/Service/CheckWebsiteAssociation.php
@@ -0,0 +1,124 @@
+entitiesHelper->getConnection();
+ $tmpTable = $this->entitiesHelper->getTableName($code);
+ $websiteAttribute = $this->configHelper->getWebsiteAttribute();
+ $websites = $this->storeHelper->getStores('website_code');
+ $websiteAssociation = $this->config->getValue('akeneo_connector/product/website_attribute');
+
+ $requiredAttributes = $this->getRequiredAttributes();
+
+ if (!$connection->tableColumnExists($tmpTable, $websiteAttribute)) {
+ return;
+ }
+
+ $select = $connection->select()->from($tmpTable);
+ $query = $connection->query($select);
+
+ while (($row = $query->fetch()) && is_array($row)) {
+ if (!isset($row[$websiteAssociation])) {
+ continue;
+ }
+
+ $websites = explode(',', $row[$websiteAssociation]);
+ $mapping = $this->getMappedWebsiteChannels();
+
+ foreach ($websites as $key => $website) {
+ $channel = $mapping[$website] ?? '';
+ if (empty($channel)) {
+ continue;
+ }
+
+ $locales = $this->storeHelper->getChannelStoreLangs($channel);
+ foreach ($requiredAttributes as $attribute) {
+ if (!is_array($attribute)) {
+ continue;
+ }
+ if (isset($attribute['localizable']) && $attribute['localizable'] === true) {
+ foreach ($locales as $locale) {
+ if (empty($row[$attribute['akeneo_attribute'] . '-' . $locale . '-' . $channel])) {
+ unset($websites[$key]);
+
+ break 2;
+ }
+ }
+ } else {
+ $attrKey = $attribute['akeneo_attribute'] ?? '';
+ if (empty($row[$attrKey])) {
+ unset($websites[$key]);
+
+ break 2;
+ }
+ }
+ }
+ }
+
+ $connection->update(
+ $tmpTable,
+ [
+ $websiteAssociation => implode(',', $websites),
+ ],
+ ['identifier = ?' => $row['identifier']]
+ );
+ }
+ }
+
+ /**
+ * @return array