-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
New feature: ConfigurableSwatches now allows for auto-generation of the swatch image file based on color selection #3686
Changes from 6 commits
25ef34b
d529c87
8a0aa72
b1329fc
7a95a4a
d5500d2
f3760ae
c24ba77
0f7b05d
680dc09
31960b5
e0b046b
9c14a5d
797a01d
8e04589
e929302
4142e60
67976fd
c59d99b
810ff83
4a9d25f
ad08be1
e77742d
434c96e
f515647
74e1e3b
d7cbb38
e45487c
d418f61
990ff47
0eb8bf8
3926da0
553988e
424366b
dc63323
22685f0
0153ced
0247856
79eb30d
1e70f81
5ad246d
834cd58
e5e16b5
0f1387c
b353e2b
aeea471
90e37b4
71c0296
acfa3b0
4a8de41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -34,4 +34,19 @@ public function _construct() | |||||
{ | ||||||
$this->_init('eav/entity_attribute_option'); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Retrieve swatch value | ||||||
* | ||||||
* @return Mage_Eav_Model_Entity_Attribute_Option_Swatch|bool | ||||||
empiricompany marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
*/ | ||||||
public function getSwatch() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
not sure about this but since it returns the value... and in this case we can remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've applied your suggestions but keep comment as "Retrieve swatch hex value" |
||||||
{ | ||||||
$swatch = Mage::getModel('eav/entity_attribute_option_swatch') | ||||||
->load($this->getId(), 'option_id'); | ||||||
if (!$swatch->getId()) { | ||||||
return false; | ||||||
} | ||||||
return $swatch->getValue(); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* 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 at https://opensource.org/license/osl-3-0-php | ||
* | ||
* @category Mage | ||
* @package Mage_Eav | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) | ||
* @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) | ||
empiricompany marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Entity attribute swatch model | ||
* | ||
* @category Mage | ||
* @package Mage_Eav | ||
* | ||
* @method Mage_Eav_Model_Resource_Entity_Attribute_Option_Swatch _getResource() | ||
* @method Mage_Eav_Model_Resource_Entity_Attribute_Option_Swatch getResource() | ||
*/ | ||
class Mage_Eav_Model_Entity_Attribute_Option_Swatch extends Mage_Core_Model_Abstract | ||
{ | ||
public function _construct() | ||
{ | ||
$this->_init('eav/entity_attribute_option_swatch'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* 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 at https://opensource.org/license/osl-3-0-php | ||
* | ||
* @category Mage | ||
* @package Mage_Eav | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) | ||
* @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) | ||
empiricompany marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Entity attribute swatch resource model | ||
* | ||
* @category Mage | ||
* @package Mage_Eav | ||
*/ | ||
class Mage_Eav_Model_Resource_Entity_Attribute_Option_Swatch extends Mage_Core_Model_Resource_Db_Abstract | ||
{ | ||
protected function _construct() | ||
{ | ||
$this->_init('eav/attribute_option_swatch', 'option_id'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* 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 at https://opensource.org/license/osl-3-0-php | ||
* | ||
* @category Mage | ||
* @package Mage_Eav | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) | ||
* @copyright Copyright (c) 2020-2022 The OpenMage Contributors (https://www.openmage.org) | ||
empiricompany marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** @var Mage_Eav_Model_Entity_Setup $installer */ | ||
$installer = $this; | ||
$installer->startSetup(); | ||
|
||
/** | ||
* Create table 'eav/attribute_option_swatch' | ||
*/ | ||
$table = $installer->getConnection() | ||
->newTable($installer->getTable('eav/attribute_option_swatch')) | ||
->addColumn('value_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ | ||
'identity' => true, | ||
'unsigned' => true, | ||
'nullable' => false, | ||
'primary' => true, | ||
], 'Value Id') | ||
->addColumn('option_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ | ||
'unsigned' => true, | ||
'nullable' => false, | ||
'default' => '0', | ||
], 'Option Id') | ||
->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ | ||
'nullable' => true, | ||
'default' => null, | ||
], 'Value') | ||
->addColumn('filename', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ | ||
'nullable' => true, | ||
'default' => null, | ||
], 'Filename') | ||
->addIndex( | ||
$installer->getIdxName('eav/attribute_option_value', ['option_id']), | ||
['option_id'], | ||
['type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE] | ||
) | ||
->addForeignKey( | ||
$installer->getFkName('eav/attribute_option_value', 'option_id', 'eav/attribute_option', 'option_id'), | ||
'option_id', | ||
$installer->getTable('eav/attribute_option'), | ||
'option_id', | ||
Varien_Db_Ddl_Table::ACTION_CASCADE, | ||
Varien_Db_Ddl_Table::ACTION_CASCADE | ||
) | ||
->setComment('Eav Attribute Option Swatch'); | ||
$installer->getConnection()->createTable($table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to me that this method never returns null, am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should return null if it fails to create the swatch from the loaded image, so it creates it from the color picker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not reading it wrong, it doesn't seem to do that check because it returns '' on line 284 and then I don't see any return statement until line 306 but $destPath seems to always be a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I corrected it with false