-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add important attributes to be imported even if empty in every product (
#32)
- Loading branch information
1 parent
f83fedf
commit 994ca44
Showing
4 changed files
with
97 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace JustBetter\AkeneoBundle\Plugin\Helper\Import; | ||
|
||
use Akeneo\Connector\Helper\Store as StoreHelper; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
|
||
class Product | ||
{ | ||
protected $codes = null; | ||
|
||
public function __construct( | ||
protected ScopeConfigInterface $config, | ||
protected StoreHelper $storeHelper, | ||
) { | ||
} | ||
|
||
public function beforeCreateTmpTableFromApi($subject, $result, $tableSuffix, $family = null) | ||
{ | ||
if (is_null($this->codes)) { | ||
$this->codes = explode(',', (string)$this->config->getValue('akeneo_connector/justbetter/important_attributes')); | ||
} | ||
|
||
if (!count($this->codes)) { | ||
return [$result, $tableSuffix, $family]; | ||
} | ||
|
||
$stores = $this->storeHelper->getAllStores(); | ||
$storeCodes = []; | ||
foreach ($stores as $local => $affectedStores) { | ||
foreach ($affectedStores as $affectedStore) { | ||
$storeCodes[$affectedStore['lang'] . '-' . $affectedStore['channel_code']] = [ | ||
$affectedStore['lang'], | ||
$affectedStore['channel_code'] | ||
]; | ||
} | ||
} | ||
|
||
foreach ($this->codes as $code) { | ||
if (array_key_exists($code, $result['values'])) { | ||
continue; | ||
} | ||
$result['values'][$code] = [[ | ||
'locale' => null, | ||
'scope' => null, | ||
'data' => null, | ||
]]; | ||
|
||
foreach ($storeCodes as $store) { | ||
$result['values'][$code][] = [ | ||
'locale' => $store[0], | ||
'scope' => $store[1], | ||
'data' => null, | ||
]; | ||
} | ||
} | ||
|
||
return [$result, $tableSuffix, $family]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters