Skip to content

problem at backend opening atribute with text swatches #7654

Closed
@erik-augustin

Description

@erik-augustin

Preconditions

  1. magento 2.1.2
  2. mysql 5.6
    3 php 7.0

Steps to reproduce

  1. edit text swatches switch to from visual edit dele options

Expected result

  1. it should be possible to edit atributes

Actual result

  1. [Screenshot, logs]

I get an error page:

1 exception(s):
Exception #0 (Exception): Notice: Uninitialized string offset: 0 in /home/78667-61384.cloudwaysapps.com/fbsjfkryyc/public_html/vendor/magento/module-swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php on line 91

Exception #0 (Exception): Notice: Uninitialized string offset: 0 in /home/78667-61384.cloudwaysapps.com/fbsjfkryyc/public_html/vendor/magento/module-swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php on line 91
#0 /home/78667-61384.cloudwaysapps.com/fbsjfkryyc/public_html/vendor/magento/module-swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php(91): Magento\Framework\App\ErrorHandler->handler(8, 'Uninitialized s...', '/home/78667-613...', 91, Array)
#1 /home/78667-61384.cloudwaysapps.com/fbsjfkryyc/public_html/vendor/magento/module-swatches/Block/Adminhtml/Attribute/Edit/Options/Visual.php(47): Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Visual->reformatSwatchLabels(Array)

/**
 * Parse swatch labels for template
 *
 * @codeCoverageIgnore
 * @param null $swatchStoreValue
 * @return string
 */
protected function reformatSwatchLabels($swatchStoreValue = null)
{
    if ($swatchStoreValue === null) {
        return;
    }
    $newSwatch = '';

(LINE91) foreach ($swatchStoreValue as $key => $value) {
if ($value[0] == '#') {
$newSwatch[$key] = 'background: '.$value;
} elseif ($value[0] == '/') {
$mediaUrl = $this->swatchHelper->getSwatchMediaUrl();
$newSwatch[$key] = 'background: url('.$mediaUrl.$value.'); background-size: cover;';
}
}
return $newSwatch;
}
}
At the frontend my configurable itemes with multiple are functioning as expected but at backend i have problems.

when i open add the backend of magento 2.1.2
one of my Product atributes (with text swatches)

I get an error page: see above

i have create "workaround"
by changing: if ($swatchStoreValue === null || 1==1) {

my questions:
-whats the function of this code?
-how to fix this permanent?
-do i have a corrrupted database field (which table is queried field?)

thanks
erik

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions