diff --git a/src/classes/XLite/Model/Attribute.php b/src/classes/XLite/Model/Attribute.php index a6b4e69102..0a9ed22a40 100644 --- a/src/classes/XLite/Model/Attribute.php +++ b/src/classes/XLite/Model/Attribute.php @@ -168,6 +168,20 @@ public static function getTypes($type = null) : $list; } + /** + * Return values associated with this attribute + * + * @return mixed + */ + public function getAttributeValues() + { + $cnd = new \XLite\Core\CommonCell; + $cnd->attribute = $this; + + return \XLite\Core\Database::getRepo($this->getAttributeValueClass()) + ->search($cnd); + } + /** * Return number of values associated with this attribute * @@ -202,6 +216,9 @@ public function setType($type) foreach ($this->getAttributeOptions() as $option) { \XLite\Core\Database::getEM()->remove($option); } + foreach ($this->getAttributeValues() as $value) { + \XLite\Core\Database::getEM()->remove($value); + } } $this->type = $type; } diff --git a/src/classes/XLite/View/Model/Attribute.php b/src/classes/XLite/View/Model/Attribute.php index b0cfb3e547..2237404fb1 100644 --- a/src/classes/XLite/View/Model/Attribute.php +++ b/src/classes/XLite/View/Model/Attribute.php @@ -73,6 +73,10 @@ protected function getFormFieldsForSectionDefault() { if ($this->getModelObject()->getId()) { $this->schemaDefault['type'][self::SCHEMA_COMMENT] = 'Before editing attriubutes specific for the chosen type you should save the changes'; + + if ($this->getModelObject()->getAttributeValuesCount()) { + $this->schemaDefault['type'][self::SCHEMA_COMMENT] .= '
There are products using this attribute!'; + } if ( \XLite\Model\Attribute::TYPE_NUMBER == $this->getModelObject()->getType() diff --git a/src/skins/admin/en/attributes/style.css b/src/skins/admin/en/attributes/style.css index ae9fa75125..d6a6d9020f 100644 --- a/src/skins/admin/en/attributes/style.css +++ b/src/skins/admin/en/attributes/style.css @@ -204,6 +204,7 @@ div.group table.list th.actions.left { width: auto; margin-left: 10px; float: left; + max-width: 440px; } .ajax-container-loadable .model-properties div.table-value.values-value { @@ -221,13 +222,14 @@ div.group table.list th.actions.left { } .ajax-container-loadable .select-attributetypes div.table-value .form-field-comment { - background: url("../images/icon_warning_round.png") no-repeat scroll 20px center transparent; - padding-left: 50px; + background: url("../images/icon_warning_round.png") no-repeat scroll 0px center transparent; + padding-left: 30px; color: #456583; float: left; display: none; - line-height: 12px; - max-width: 300px; + line-height: 14px; + width: 360px; + margin-top: 25px; } .ajax-container-loadable div.table-value .form-field-comment {