Skip to content
Merged
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
17 changes: 17 additions & 0 deletions src/classes/XLite/Model/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/classes/XLite/View/Model/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] .= '<br />There are products using this attribute!';
}

if (
\XLite\Model\Attribute::TYPE_NUMBER == $this->getModelObject()->getType()
Expand Down
10 changes: 6 additions & 4 deletions src/skins/admin/en/attributes/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down