miniShop2: не пишется значение в product.key

Всем привет.
Столкнулся со странной проблемой, буду рад, если подскажете, куда копать.
Сниппет msCart в массиве $products не записывает значение key, вернее, записывает в виде пустого массива:
[key] => Array
        (
            [0] => 
        )
В результате не работает удаление из корзины и другие операции.
Немного в ступоре. Заранее спасибо за помощь!
Дмитрий
03 сентября 2019, 17:37
modx.pro
89
0

Комментарии: 5

ElenaLelo
04 сентября 2019, 16:02
0
Чанк?
    Дмитрий
    05 сентября 2019, 09:30
    0
    Чанк стандартный с небольшими изменениями, но это разве имеет значение?
    Ведь если просто распечатать массив $product, в ['key'] будет лежать пустой массив.

    <div id="msCart">
        {if !count($products)}
            {'ms2_cart_is_empty' | lexicon}
        {else}
            <div class="table-responsive">
                <table class="table table-striped">
                    <tr class="header">
                        <th class="image"> </th>
                        <th class="title">{'ms2_cart_title' | lexicon}</th>
                        <th class="count">{'ms2_cart_count' | lexicon}</th>
                        <th class="price">{'ms2_cart_price' | lexicon}</th>
                        <th class="remove">{'ms2_cart_remove' | lexicon}</th>
                    </tr>
    
                    {foreach $products as $product}
                        <tr id="{$product.key}">
                            <td class="image">
                                {if $product.thumb?}
                                    <img src="{$product.thumb}" alt="{$product.pagetitle}" title="{$product.pagetitle}"/>
                                {else}
                                    <img src="{'assets_url' | option}components/minishop2/img/web/ms2_small.png"
                                         srcset="{'assets_url' | option}components/minishop2/img/web/ms2_small@2x.png 2x"
                                         alt="{$product.pagetitle}" title="{$product.pagetitle}"/>
                                {/if}
                            </td>
                            <td class="title">
                                {if $product.id?}
                                    <a href="{$product.id | url}">{$product.pagetitle}</a>
                                {else}
                                    {$product.name}
                                {/if}
                                {if $product.options?}
                                    <div class="small">
                                        {$product.options | join : '; '}
                                    </div>
                                {/if}
                            </td>
                            <td class="count">
                                <form method="post" class="ms2_form form-inline" role="form">
                                    <input type="hidden" name="key" value="{$product.key}"/>
                                    <div class="form-group">
                                        <input type="number" name="count" value="{$product.count}"
                                               class="input-sm form-control"/>
                                        <span class="hidden-xs">{'ms2_frontend_count_unit' | lexicon}</span>
                                        <button class="btn btn-default" type="submit" name="ms2_action" value="cart/change">
                                            <i class="glyphicon glyphicon-refresh"></i>
                                        </button>
                                    </div>
                                </form>
                            </td>
                            <td class="price">
                                <span>{$product.price}</span> {'ms2_frontend_currency' | lexicon}
                                {if $product.old_price?}
                                <span class="old_price">{$product.old_price}</span> {'ms2_frontend_currency' | lexicon}
                                    {/if}
                            </td>
                            <td class="remove">
                                <form method="post" class="ms2_form">
                                    <input type="hidden" name="key" value="{$product.key}">
                                    <button class="btn btn-default" type="submit" name="ms2_action" value="cart/remove">
                                        <i class="fas fa-times"></i>
                                    </button>
                                </form>
                            </td>
                        </tr>
                    {/foreach}
    
                    <tr class="footer">
                        <th class="total" colspan="2">{'ms2_cart_total' | lexicon}:</th>
                        <th class="total_count">
                            <span class="ms2_total_count">{$total.count}</span>
                            {'ms2_frontend_count_unit' | lexicon}
                        </th>
                        <th class="total_cost">
                            <span class="ms2_total_cost">{$total.cost}</span>
                            {'ms2_frontend_currency' | lexicon}
                        </th>
                        <th> </th>
                    </tr>
                </table>
            </div>
            <form method="post">
                <button class="btn btn-default" type="submit" name="ms2_action" value="cart/clean">
                    <i class="glyphicon glyphicon-remove"></i> {'ms2_cart_clean' | lexicon}
                </button>
            </form>
        {/if}
    </div>
Дмитрий
05 сентября 2019, 09:32
0
Вот так печатается $products с одним товаром в корзине:

Array
(
    [0] => Array
        (
            [id] => 4162
            [type] => document
            [contentType] => text/html
            [pagetitle] => Стеклянные шкафы купе в прихожую
            [longtitle] => 
            [description] => Стеклянные шкафы купе в прихожую изготавливаем на заказ на собственном производстве. Минимальные сроки! Низкая цена! Быстрый рассчет по телефону!
            [alias] => steklyannyie-shkafyi-kupe-v-prixozhuyu
            [alias_visible] => 1
            [link_attributes] => 
            [published] => 1
            [pub_date] => 0
            [unpub_date] => 0
            [parent] => 3333
            [isfolder] => 0
            [introtext] => 
            [richtext] => 1
            [template] => 4
            [menuindex] => 24
            [searchable] => 1
            [cacheable] => 1
            [createdby] => 1
            [createdon] => 1545582489
            [editedby] => 1
            [editedon] => 1547374278
            [deleted] => 0
            [deletedon] => 0
            [deletedby] => 0
            [publishedon] => 1545582489
            [publishedby] => 1
            [menutitle] => 
            [donthit] => 0
            [privateweb] => 0
            [privatemgr] => 0
            [content_dispo] => 0
            [hidemenu] => 0
            [class_key] => msProduct
            [context_key] => web
            [content_type] => 1
            [uri] => shkafyi-kupe/steklo/steklyannyie-shkafyi-kupe-v-prixozhuyu.html
            [uri_override] => 0
            [hide_children_in_tree] => 0
            [show_in_tree] => 0
            [properties] => Array
                (
                    [autoredirector] => Array
                        (
                            [old_uri] => shkafyi-kupe/steklo/steklyannyie-shkafyi-kupe-v-prixozhuyu.html
                        )

                )

            [article] => KS_SHK_000830
            [price] => 63 700
            [old_price] => 91 000
            [weight] => 0
            [image] => /assets/images/products/4162/1779.jpg
            [thumb] => /assets/images/products/4162/small/1779.jpg
            [vendor] => 0
            [made_in] => 
            [new] => 0
            [popular] => 0
            [favorite] => 0
            [tags] => 
            [color] => 
            [size] => 
            [source] => 2
            [vendor.name] => 
            [vendor.resource] => 
            [vendor.country] => 
            [vendor.logo] => 
            [vendor.address] => 
            [vendor.phone] => 
            [vendor.fax] => 
            [vendor.email] => 
            [vendor.description] => 
            [vendor.properties] => 
            [key] => Array
                (
                    [0] => 
                )

            [count] => 1
            [cost] => 63 700
            [width] => Array
                (
                    [0] => 280
                )

            [width.id] => 1
            [width.key] => width
            [width.caption] => Ширина
            [width.description] => 
            [width.measure_unit] => 
            [width.category] => 0
            [width.type] => textfield
            [width.properties] => 
            [width.product_id] => 4162
            [width.value] => 280
            [width.category_name] => 
            [height] => Array
                (
                    [0] => 270
                )

            [height.id] => 2
            [height.key] => height
            [height.caption] => Высота
            [height.description] => 
            [height.measure_unit] => 
            [height.category] => 0
            [height.type] => textfield
            [height.properties] => 
            [height.product_id] => 4162
            [height.value] => 270
            [height.category_name] => 
            [depth] => Array
                (
                    [0] => 60
                )

            [depth.id] => 3
            [depth.key] => depth
            [depth.caption] => Глубина
            [depth.description] => 
            [depth.measure_unit] => 
            [depth.category] => 0
            [depth.type] => textfield
            [depth.properties] => 
            [depth.product_id] => 4162
            [depth.value] => 60
            [depth.category_name] => 
            [style] => Array
                (
                    [0] => Современный
                )

            [style.id] => 4
            [style.key] => style
            [style.caption] => Стиль
            [style.description] => 
            [style.measure_unit] => 
            [style.category] => 0
            [style.type] => textfield
            [style.properties] => 
            [style.product_id] => 4162
            [style.value] => Современный
            [style.category_name] => 
            [construction] => Array
                (
                    [0] => Встроенный
                )

            [construction.id] => 5
            [construction.key] => construction
            [construction.caption] => Конструкция
            [construction.description] => 
            [construction.measure_unit] => 
            [construction.category] => 0
            [construction.type] => textfield
            [construction.properties] => 
            [construction.product_id] => 4162
            [construction.value] => Встроенный
            [construction.category_name] => 
            [radius] => Array
                (
                    [0] => не радиусный
                )

            [radius.id] => 6
            [radius.key] => radius
            [radius.caption] => Радиусный
            [radius.description] => 
            [radius.measure_unit] => 
            [radius.category] => 0
            [radius.type] => textfield
            [radius.properties] => 
            [radius.product_id] => 4162
            [radius.value] => не радиусный
            [radius.category_name] => 
            [corner_section] => Array
                (
                    [0] => нет угловой секции
                )

            [corner_section.id] => 7
            [corner_section.key] => corner_section
            [corner_section.caption] => Угловая секция
            [corner_section.description] => 
            [corner_section.measure_unit] => 
            [corner_section.category] => 0
            [corner_section.type] => textfield
            [corner_section.properties] => 
            [corner_section.product_id] => 4162
            [corner_section.value] => нет угловой секции
            [corner_section.category_name] => 
            [place] => Array
                (
                    [0] => Прихожая
                )

            [place.id] => 8
            [place.key] => place
            [place.caption] => Место установки
            [place.description] => 
            [place.measure_unit] => 
            [place.category] => 0
            [place.type] => textfield
            [place.properties] => 
            [place.product_id] => 4162
            [place.value] => Прихожая
            [place.category_name] => 
            [doors] => Array
                (
                    [0] => 4
                )

            [doors.id] => 9
            [doors.key] => doors
            [doors.caption] => Количество дверей
            [doors.description] => 
            [doors.measure_unit] => 
            [doors.category] => 0
            [doors.type] => textfield
            [doors.properties] => 
            [doors.product_id] => 4162
            [doors.value] => 4
            [doors.category_name] => 
            [door_dividers] => Array
                (
                    [0] => 2
                )

            [door_dividers.id] => 10
            [door_dividers.key] => door_dividers
            [door_dividers.caption] => Количество делителей двери
            [door_dividers.description] => 
            [door_dividers.measure_unit] => 
            [door_dividers.category] => 0
            [door_dividers.type] => textfield
            [door_dividers.properties] => 
            [door_dividers.product_id] => 4162
            [door_dividers.value] => 2
            [door_dividers.category_name] => 
            [door_frame_material] => Array
                (
                    [0] => Алюминий
                )

            [door_frame_material.id] => 11
            [door_frame_material.key] => door_frame_material
            [door_frame_material.caption] => Материал рамки дверей
            [door_frame_material.description] => 
            [door_frame_material.measure_unit] => 
            [door_frame_material.category] => 0
            [door_frame_material.type] => textfield
            [door_frame_material.properties] => 
            [door_frame_material.product_id] => 4162
            [door_frame_material.value] => Алюминий
            [door_frame_material.category_name] => 
            [door_profile_material] => Array
                (
                    [0] => Алюминий
                )

            [door_profile_material.id] => 12
            [door_profile_material.key] => door_profile_material
            [door_profile_material.caption] => Материал профиля дверей
            [door_profile_material.description] => 
            [door_profile_material.measure_unit] => 
            [door_profile_material.category] => 0
            [door_profile_material.type] => textfield
            [door_profile_material.properties] => 
            [door_profile_material.product_id] => 4162
            [door_profile_material.value] => Алюминий
            [door_profile_material.category_name] => 
            [insert_material] => Array
                (
                    [0] => 
                )

            [insert_material.id] => 13
            [insert_material.key] => insert_material
            [insert_material.caption] => Материал вставки
            [insert_material.description] => 
            [insert_material.measure_unit] => 
            [insert_material.category] => 0
            [insert_material.type] => textfield
            [insert_material.properties] => 
            [insert_material.product_id] => 4162
            [insert_material.value] => 
            [insert_material.category_name] => 
            [insert_decor] => Array
                (
                    [0] => Белый
                )

            [insert_decor.id] => 14
            [insert_decor.key] => insert_decor
            [insert_decor.caption] => Декор вставки
            [insert_decor.description] => 
            [insert_decor.measure_unit] => 
            [insert_decor.category] => 0
            [insert_decor.type] => textfield
            [insert_decor.properties] => 
            [insert_decor.product_id] => 4162
            [insert_decor.value] => Белый
            [insert_decor.category_name] => 
            [door_decor] => Array
                (
                    [0] => нет декора
                )

            [door_decor.id] => 15
            [door_decor.key] => door_decor
            [door_decor.caption] => Декор дверей
            [door_decor.description] => 
            [door_decor.measure_unit] => 
            [door_decor.category] => 0
            [door_decor.type] => textfield
            [door_decor.properties] => 
            [door_decor.product_id] => 4162
            [door_decor.value] => нет декора
            [door_decor.category_name] => 
            [decor] => Array
                (
                    [0] => 
                )

            [decor.id] => 16
            [decor.key] => decor
            [decor.caption] => Декорирование
            [decor.description] => 
            [decor.measure_unit] => 
            [decor.category] => 0
            [decor.type] => textfield
            [decor.properties] => 
            [decor.product_id] => 4162
            [decor.value] => 
            [decor.category_name] => 
            [insert_decor_2] => Array
                (
                    [0] => 
                )

            [insert_decor_2.id] => 17
            [insert_decor_2.key] => insert_decor_2
            [insert_decor_2.caption] => Декор вставки 2
            [insert_decor_2.description] => 
            [insert_decor_2.measure_unit] => 
            [insert_decor_2.category] => 0
            [insert_decor_2.type] => textfield
            [insert_decor_2.properties] => 
            [insert_decor_2.product_id] => 4162
            [insert_decor_2.value] => 
            [insert_decor_2.category_name] => 
            [insert] => Array
                (
                    [0] => Стекло крашенное/тонированное
                )

            [insert.id] => 18
            [insert.key] => insert
            [insert.caption] => Вставка
            [insert.description] => 
            [insert.measure_unit] => 
            [insert.category] => 0
            [insert.type] => textfield
            [insert.properties] => 
            [insert.product_id] => 4162
            [insert.value] => Стекло крашенное/тонированное
            [insert.category_name] => 
            [door_profile_decor] => Array
                (
                    [0] => 
                )

            [door_profile_decor.id] => 19
            [door_profile_decor.key] => door_profile_decor
            [door_profile_decor.caption] => Декор профиля двери
            [door_profile_decor.description] => 
            [door_profile_decor.measure_unit] => 
            [door_profile_decor.category] => 0
            [door_profile_decor.type] => textfield
            [door_profile_decor.properties] => 
            [door_profile_decor.product_id] => 4162
            [door_profile_decor.value] => 
            [door_profile_decor.category_name] => 
            [door_insert] => Array
                (
                    [0] => 
                )

            [door_insert.id] => 20
            [door_insert.key] => door_insert
            [door_insert.caption] => Вставка двери
            [door_insert.description] => 
            [door_insert.measure_unit] => 
            [door_insert.category] => 0
            [door_insert.type] => textfield
            [door_insert.properties] => 
            [door_insert.product_id] => 4162
            [door_insert.value] => 
            [door_insert.category_name] => 
            [door_insert_decor] => Array
                (
                    [0] => 
                )

            [door_insert_decor.id] => 21
            [door_insert_decor.key] => door_insert_decor
            [door_insert_decor.caption] => Декор вставки двери
            [door_insert_decor.description] => 
            [door_insert_decor.measure_unit] => 
            [door_insert_decor.category] => 0
            [door_insert_decor.type] => textfield
            [door_insert_decor.properties] => 
            [door_insert_decor.product_id] => 4162
            [door_insert_decor.value] => 
            [door_insert_decor.category_name] => 
            [features] => Array
                (
                    [0] => стекло|встроенный
                )

            [features.id] => 22
            [features.key] => features
            [features.caption] => Характеристики
            [features.description] => 
            [features.measure_unit] => 
            [features.category] => 0
            [features.type] => textfield
            [features.properties] => 
            [features.product_id] => 4162
            [features.value] => стекло|встроенный
            [features.category_name] => 
            [icons] => Array
                (
                    [0] => eko
                )

            [icons.id] => 23
            [icons.key] => icons
            [icons.caption] => Иконки
            [icons.description] => 
            [icons.measure_unit] => 
            [icons.category] => 0
            [icons.type] => textfield
            [icons.properties] => 
            [icons.product_id] => 4162
            [icons.value] => eko
            [icons.category_name] => 
            [key.id] => 24
            [key.key] => key
            [key.caption] => Ключ (служебное)
            [key.description] => 
            [key.measure_unit] => 
            [key.category] => 0
            [key.type] => textfield
            [key.properties] => 
            [key.product_id] => 4162
            [key.value] => 
            [key.category_name] => 
            [frequency] => Array
                (
                    [0] => 
                )

            [frequency.id] => 25
            [frequency.key] => frequency
            [frequency.caption] => Частотность (служебное)
            [frequency.description] => 
            [frequency.measure_unit] => 
            [frequency.category] => 0
            [frequency.type] => textfield
            [frequency.properties] => 
            [frequency.product_id] => 4162
            [frequency.value] => 
            [frequency.category_name] => 
            [frequency_2] => Array
                (
                    [0] => 
                )

            [frequency_2.id] => 26
            [frequency_2.key] => frequency_2
            [frequency_2.caption] => Частотность в кавычках (служебное)
            [frequency_2.description] => 
            [frequency_2.measure_unit] => 
            [frequency_2.category] => 0
            [frequency_2.type] => textfield
            [frequency_2.properties] => 
            [frequency_2.product_id] => 4162
            [frequency_2.value] => 
            [frequency_2.category_name] => 
        )

)
    ElenaLelo
    05 сентября 2019, 10:16
    0
    Ну, если массив пустой, то разницы нет, да. Тогда для начала откатите в исходники дополнение. проверьте не перебивает ли какой либо js функции ms и через отладчик при добавлении товара поставьте точку на строчке (где то 256) this.Cart.status(response.data), что бы просмотреть есть ли на данном этапе key. потому что у меня были ошибки, когда key генерировался, хранился в data, но в корзине не отображался. мб и у вас тоже самое
Алексей Шумаев
05 сентября 2019, 10:08
0
Проверьте:
1. плагины на системные события
2. кастомизации самой службы

Скорее всего изменена штатная логика работы корзины.
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
5