После обновления Shopware 6.5.5.2 => 6.5.8.11 плагин пользовательского фильтра не работает. Он должен фильтровать свойства в зависимости от другого выбранного свойства.
Вот как выглядит класс Subscriber.php:
class Subscriber implements EventSubscriberInterface
{
private EntityRepository $optionRepository;
public function __construct(EntityRepository $optionRepository)
{
$this->optionRepository = $optionRepository;
}
public static function getSubscribedEvents(): array
{
return [
ProductListingCriteriaEvent::class => [
['onListingCriteria', -200],
],
];
}
public function onListingCriteria(ProductListingCriteriaEvent $event): void
{
$event->getCriteria()->addAssociation('properties');
$event->getCriteria()->addAssociation('properties.group');
$criteria = $event->getCriteria();
$filters = $criteria->getExtension('filters');
if (!$filters instanceof FilterCollection) {
return;
}
$propertyFilter = $filters->get('properties');
if (!$propertyFilter instanceof Filter || !\is_array($propertyFilter->getValues())) {
return;
}
$currentPropertyOptions = $propertyFilter->getValues();
$event->getContext()->addExtension('currentPropertyOptionsCriteria', new ArrayEntity($currentPropertyOptions));
$criteria1 = new Criteria();
$criteria1->addAssociation('myTags');
$criteria1->setIds($currentPropertyOptions);
$tags = new TagCollection();
$options = $this->optionRepository->search($criteria1, $event->getContext())->getEntities();
/** @var PropertyGroupOptionEntity $option */
foreach ($options as $option) {
$extension = $option->getExtension('myTags');
if (!$extension instanceof TagCollection) {
continue;
}
$tags->merge($extension);
}
$tags = $option->getExtension('myTags');
$tagnames = $tags->map(fn (TagEntity $tag) => $tag->getName());
$event->getContext()->addExtension('myTagsNames1', new ArrayEntity($tagnames));
$prefixes = ['84a5f522d04f463a93a858b3c1bb8f7a','40f24f88c4c34196ad21ec5dcd094e6a', 'e892c99ffc5747848aea3aa5c8126201', '96e839a6e32a4301b238e90088f4a778', 'c5d7bcee60f7493bb6203965e15068e0', '9c493945d37b4ff1b527a874d8315519', 'f032b2d21c484196ad3a98d90379f6c0', 'a07ec367574a4c3d81b7fb6ceae66ffe'];
if (in_array('3f777000a2734deead391133cee3a6a9', $currentPropertyOptions)) {
$multiFilter = new MultiFilter(MultiFilter::CONNECTION_OR);
foreach ($tagnames as $tagname) { $multiFilter->addQuery(new PrefixFilter('product.properties.name', $tagname));}
foreach ($prefixes as $prefix) {
$multiFilter->addQuery(new EqualsFilter('product.properties.group.id', $prefix));
}
$criteria->addFilter($multiFilter);
}
..
if (in_array('a637fe94fe794a84b0ce7fc2a13e1485', $currentPropertyOptions)) {
$multiFilter = new MultiFilter(MultiFilter::CONNECTION_OR);
foreach ($tagnames as $tagname) { $multiFilter->addQuery(new PrefixFilter('product.properties.name', $tagname));}
foreach ($prefixes as $prefix) {
$multiFilter->addQuery(new EqualsFilter('product.properties.group.id', $prefix));
}
$criteria->addFilter($multiFilter);
}
}
}
Я пытаюсь отладить его, но не могу найти проблему. Теги связанных свойств имеются. Но он не фильтрует свойства в зависимости от выбранного.
Может кто-нибудь дать совет по отладке? Или, может быть, есть новый способ реализации такого рода пользовательской фильтрации в Shopware 6.5.8.11 или 6.6 (мы собираемся обновить его до последней версии)?
При попытке переустановить плагин , мы получаем эту ошибку:
Internal Server Error: Table "myfilter_property_group_option_tag" has to be prefixed with "custom_entity_ or ce_"
Подробнее здесь: https://stackoverflow.com/questions/788 ... oesnt-work
После обновления Shopware 6.5.5.2 => 6.5.8.11 плагин фильтра не работает ⇐ Php
Кемеровские программисты php общаются здесь
1722869891
Anonymous
После обновления Shopware 6.5.5.2 => 6.5.8.11 плагин пользовательского фильтра не работает. Он должен фильтровать свойства в зависимости от другого выбранного свойства.
Вот как выглядит класс Subscriber.php:
class Subscriber implements EventSubscriberInterface
{
private EntityRepository $optionRepository;
public function __construct(EntityRepository $optionRepository)
{
$this->optionRepository = $optionRepository;
}
public static function getSubscribedEvents(): array
{
return [
ProductListingCriteriaEvent::class => [
['onListingCriteria', -200],
],
];
}
public function onListingCriteria(ProductListingCriteriaEvent $event): void
{
$event->getCriteria()->addAssociation('properties');
$event->getCriteria()->addAssociation('properties.group');
$criteria = $event->getCriteria();
$filters = $criteria->getExtension('filters');
if (!$filters instanceof FilterCollection) {
return;
}
$propertyFilter = $filters->get('properties');
if (!$propertyFilter instanceof Filter || !\is_array($propertyFilter->getValues())) {
return;
}
$currentPropertyOptions = $propertyFilter->getValues();
$event->getContext()->addExtension('currentPropertyOptionsCriteria', new ArrayEntity($currentPropertyOptions));
$criteria1 = new Criteria();
$criteria1->addAssociation('myTags');
$criteria1->setIds($currentPropertyOptions);
$tags = new TagCollection();
$options = $this->optionRepository->search($criteria1, $event->getContext())->getEntities();
/** @var PropertyGroupOptionEntity $option */
foreach ($options as $option) {
$extension = $option->getExtension('myTags');
if (!$extension instanceof TagCollection) {
continue;
}
$tags->merge($extension);
}
$tags = $option->getExtension('myTags');
$tagnames = $tags->map(fn (TagEntity $tag) => $tag->getName());
$event->getContext()->addExtension('myTagsNames1', new ArrayEntity($tagnames));
$prefixes = ['84a5f522d04f463a93a858b3c1bb8f7a','40f24f88c4c34196ad21ec5dcd094e6a', 'e892c99ffc5747848aea3aa5c8126201', '96e839a6e32a4301b238e90088f4a778', 'c5d7bcee60f7493bb6203965e15068e0', '9c493945d37b4ff1b527a874d8315519', 'f032b2d21c484196ad3a98d90379f6c0', 'a07ec367574a4c3d81b7fb6ceae66ffe'];
if (in_array('3f777000a2734deead391133cee3a6a9', $currentPropertyOptions)) {
$multiFilter = new MultiFilter(MultiFilter::CONNECTION_OR);
foreach ($tagnames as $tagname) { $multiFilter->addQuery(new PrefixFilter('product.properties.name', $tagname));}
foreach ($prefixes as $prefix) {
$multiFilter->addQuery(new EqualsFilter('product.properties.group.id', $prefix));
}
$criteria->addFilter($multiFilter);
}
..
if (in_array('a637fe94fe794a84b0ce7fc2a13e1485', $currentPropertyOptions)) {
$multiFilter = new MultiFilter(MultiFilter::CONNECTION_OR);
foreach ($tagnames as $tagname) { $multiFilter->addQuery(new PrefixFilter('product.properties.name', $tagname));}
foreach ($prefixes as $prefix) {
$multiFilter->addQuery(new EqualsFilter('product.properties.group.id', $prefix));
}
$criteria->addFilter($multiFilter);
}
}
}
Я пытаюсь отладить его, но не могу найти проблему. Теги связанных свойств имеются. Но он не фильтрует свойства в зависимости от выбранного.
Может кто-нибудь дать совет по отладке? Или, может быть, есть новый способ реализации такого рода пользовательской фильтрации в Shopware 6.5.8.11 или 6.6 (мы собираемся обновить его до последней версии)?
При попытке переустановить плагин , мы получаем эту ошибку:
Internal Server Error: Table "myfilter_property_group_option_tag" has to be prefixed with "custom_entity_ or ce_"
Подробнее здесь: [url]https://stackoverflow.com/questions/78824643/after-shopware-update-6-5-5-2-6-5-8-11-filter-plugin-doesnt-work[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия