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

Add label check for locales in category and family jobs #28

Open
wants to merge 1 commit into
base: develop
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
21 changes: 21 additions & 0 deletions app/code/community/Pimgento/Api/Model/Job/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,25 @@ public function cleanCache($task)
$this->getHelper()->__('Cache cleaned: %s', $cacheTypeList)
);
}

/**
* Check if all locales labels exists
*
* @param string[] $entity
* @param string[] $lang
* @param string $response
*
* @return string
*/
public function checkLabelPerLocales(array $entity, array $lang, $response)
{
/** @var string[] $labels */
$labels = $entity['labels'];
foreach ($lang as $locale => $stores) {
if (empty($labels[$locale])) {
$response .= $this->getHelper()->__("Label for '%1' in %2 is missing. ", $entity['code'], $locale);
}
}
return $response;
}
}
10 changes: 9 additions & 1 deletion app/code/community/Pimgento/Api/Model/Job/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,20 @@ public function insertData($task)
$entitiesHelper = Mage::helper('pimgento_api/entities');
/** @var Pimgento_Api_Model_Resource_Entities $resourceEntities */
$resourceEntities = $this->getResourceEntities();
/** @var string $warning */
$warning = '';
/** @var Pimgento_Api_Helper_Store $storeHelper */
$storeHelper = Mage::helper('pimgento_api/store');

/**
* @var int $index
* @var mixed[] $category
*/
foreach ($categories as $index => $category) {
/** @var string[] $lang */
$lang = $storeHelper->getStores('lang');
/** @var string $checkLabels */
$warning = $this->checkLabelPerLocales($category, $lang, $warning);
/** @var string[] $columns */
$columns = $entitiesHelper->getColumnsFromResult($category);
/** @var bool $result */
Expand All @@ -125,7 +133,7 @@ public function insertData($task)
}
$index++;

$task->setStepMessage($this->getHelper()->__('%d line(s) found', $index));
$task->setStepMessage($this->getHelper()-> __('%d line(s) found. %s', $index, $warning));
}

/**
Expand Down
10 changes: 9 additions & 1 deletion app/code/community/Pimgento/Api/Model/Job/Family.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ public function insertData($task)
$entitiesHelper = Mage::helper('pimgento_api/entities');
/** @var Pimgento_Api_Model_Resource_Entities $resourceEntities */
$resourceEntities = $this->getResourceEntities();
/** @var string $warning */
$warning = '';
/** @var Pimgento_Api_Helper_Store $storeHelper */
$storeHelper = Mage::helper('pimgento_api/store');
/**
* @var int $index
* @var mixed[] $family
*/
foreach ($familyItems as $index => $family) {
/** @var string[] $lang */
$lang = $storeHelper->getStores('lang');
/** @var string $checkLabels */
$warning = $this->checkLabelPerLocales($family, $lang, $warning);
/** @var string[] $columns */
$columns = $entitiesHelper->getColumnsFromResult($family);
/** @var bool $result */
Expand All @@ -97,7 +105,7 @@ public function insertData($task)
}
$index++;

$task->setStepMessage($this->getHelper()->__('%d line(s) found', $index));
$task->setStepMessage($this->getHelper()->__('%d line(s) found. %s', $index, $warning));
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/locale/de_DE/Pimgento_Api.csv
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"Pimgento_Api::Include new categories in menu","Begriffen in Menü"
"Pimgento_Api::Init default groups","Standardgruppen einrichten"
"Pimgento_Api::Init stock","Init-Bestand"
"Pimgento_Api::Label for '%1' in %2 is missing. ","Beschriftung für '%1' in %2 fehlt. "
"Pimgento_Api::Link configurable with children","Link mit Kindern konfigurierbar"
"Pimgento_Api::Lower or equals than on all locales","Niedriger oder gleich als in allen Gebietsschemata"
"Pimgento_Api::Lower or equals than","Niedriger oder gleich als"
Expand Down
1 change: 1 addition & 0 deletions app/locale/en_US/Pimgento_Api.csv
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"Pimgento_Api::Include new categories in menu","Include new categories in menu"
"Pimgento_Api::Init default groups","Init default groups"
"Pimgento_Api::Init stock","Init stock"
"Pimgento_Api::Label for '%1' in %2 is missing. ","Label for '%1' in %2 is missing. "
"Pimgento_Api::Link configurable with children","Link configurable with children"
"Pimgento_Api::Lower or equals than on all locales","Lower or equals than on all locales"
"Pimgento_Api::Lower or equals than","Lower or equals than"
Expand Down
1 change: 1 addition & 0 deletions app/locale/fr_FR/Pimgento_Api.csv
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"Pimgento_Api::Include new categories in menu","Inclure les nouvelles catégories au menu"
"Pimgento_Api::Init default groups","Initialisation des groupes par défaut"
"Pimgento_Api::Init stock","Initialisation du stock"
"Pimgento_Api::Label for '%1' in %2 is missing. ","Le libellé pour '%1' sur la locale %2 est manquant. "
"Pimgento_Api::Link configurable with children","Liaison des configuable aux enfants"
"Pimgento_Api::Lower or equals than on all locales","Plus petit ou égal à sur toutes les locales"
"Pimgento_Api::Lower or equals than","Plus petit ou égal à"
Expand Down