-
-
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.
attributes to translate is now a multiselect
- Loading branch information
Showing
4 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
app/code/community/Fballiano/FullCatalogTranslate/Model/TranslatableAttributes.php
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,48 @@ | ||
<?php | ||
/** | ||
* FBalliano | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this Module to | ||
* newer versions in the future. | ||
* | ||
* @category FBalliano | ||
* @package FBalliano_FullCatalogTranslate | ||
* @copyright Copyright (c) 2014 Fabrizio Balliano (http://fabrizioballiano.it) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
class Fballiano_FullCatalogTranslate_Model_TranslatableAttributes | ||
{ | ||
public function toOptionArray() | ||
{ | ||
$entityTypeId = Mage::getModel('eav/entity') | ||
->setType(Mage_Catalog_Model_Product::ENTITY) | ||
->getTypeId(); | ||
|
||
$attributes = Mage::getModel("catalog/entity_attribute")->getCollection() | ||
->addFieldToFilter("entity_type_id", $entityTypeId) | ||
->addFieldToFilter("backend_type", array("in" => array("varchar", "text", "textarea"))) | ||
->addFieldToFilter("frontend_input", array("in" => array("text", "textarea"))) | ||
->addFieldToFilter("attribute_code", array("nin" => array("custom_layout_update", "recurring_profile"))) | ||
->setOrder("attribute_code", "ASC"); | ||
|
||
$toreturn = array(); | ||
foreach ($attributes as $attribute) { | ||
$toreturn[] = array( | ||
"value" => $attribute["attribute_code"], | ||
"label" => ucfirst(str_replace("_", " ", $attribute["attribute_code"])) | ||
); | ||
} | ||
|
||
return $toreturn; | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...ano/FullCatalogTranslate/sql/fballiano_fullcatalogtranslate_setup/upgrade-0.2.0-0.3.0.php
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,41 @@ | ||
<?php | ||
/** | ||
* FBalliano | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this Module to | ||
* newer versions in the future. | ||
* | ||
* @category FBalliano | ||
* @package FBalliano_FullCatalogTranslate | ||
* @copyright Copyright (c) 2014 Fabrizio Balliano (http://fabrizioballiano.it) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/* @var $installer Mage_Catalog_Model_Resource_Setup */ | ||
$installer = $this; | ||
$installer->startSetup(); | ||
|
||
$db = Mage::getSingleton('core/resource')->getConnection("core_write"); | ||
$config_table_name = Mage::getSingleton('core/resource')->getTableName("core_config_data"); | ||
$configs = $db->fetchAll("SELECT * FROM $config_table_name WHERE path='fballiano_full_catalog_translate/general/attributes_to_translate'"); | ||
foreach ($configs as $config) { | ||
$newvalues = array(); | ||
$values = explode(",", $config["value"]); | ||
foreach ($values as $value) { | ||
$value = trim($value); | ||
if (strlen($value)) $newvalues[] = $value; | ||
} | ||
$newvalues = implode(",", $newvalues); | ||
$db->update($config_table_name, array("value" => $newvalues), "config_id={$config["config_id"]}"); | ||
} | ||
|
||
$installer->endSetup(); |