inkeri21

inkeri21

С нами с 07 февраля 2023; Место в рейтинге пользователей: #6630
inkeri21
21 июня 2023, 10:36
0
[2023-06-15 13:43:35] (ERROR @ /var/www/fastuser/data/www/stropspb.ru/core/cache/includes/elements/modsnippet/24.include.cache.php: 69) [migxResourceMediaPath]: docid could not be determined.
2023-06-15 12:48:35] (ERROR @ /var/www/fastuser/data/www/stropspb.ru/assets/components/modsliderrevolution/vendor/revslider/application/helpers/general_helper.php: 1164) PHP warning: Use of undefined constant MODX_SLIDER_REV_IS_ADMIN — assumed 'MODX_SLIDER_REV_IS_ADMIN' (this will throw an Error in a future version of PHP)

вот такие ошибки в журнале ошибок
inkeri21
21 июня 2023, 09:18
0
Может вы мне подскажите еще. Я когда обновляю в галерее фото товара, то исчезает превью в админке. Хотя до этого, когда вставляла в галерею новое фото, в превью в админке сразу вставлялось новое фото. И в Галерее местами не поменять фото, не дает, чтобы одно стало главным, а другое второстепенным. Только если оба фото удалить и вставить сначала
inkeri21
21 июня 2023, 09:12
0
Спасибо. Буду разбираться)) Единственное, когда в классе 10 я снимаю галочку «Показывать вложенные товары, то из класса 10 товары 8 класса исчезают. Но когда нажимаю сохранить, галочка все равно появляется.
inkeri21
20 июня 2023, 15:57
0
Это полностью код сниппет msProduct

<?php
/** @var modX $modx */
/** @var array $scriptProperties */
/** @var miniShop2 $miniShop2 */
$miniShop2 = $modx->getService('miniShop2');
$miniShop2->initialize($modx->context->key);
/** @var pdoFetch $pdoFetch */
$fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
$path = $modx->getOption('pdofetch_class_path', null, MODX_CORE_PATH . 'components/pdotools/model/', true);
if ($pdoClass = $modx->loadClass($fqn, $path, false, true)) {
    $pdoFetch = new $pdoClass($modx, $scriptProperties);
} else {
    return false;
}
$pdoFetch->addTime('pdoTools loaded.');

if (isset($parents) && $parents === '') {
    $scriptProperties['parents'] = $modx->resource->id;
}

// Start build "where" expression
$where = array(
    'class_key' => 'msProduct',
);
if (empty($showZeroPrice)) {
    $where['Data.price:>'] = 0;
}
// Add grouping
$groupby = array(
    'msProduct.id',
);

// Join tables
$leftJoin = array(
    'Data' => array('class' => 'msProductData'),
    'Vendor' => array('class' => 'msVendor', 'on' => 'Data.vendor=Vendor.id'),
);

$select = array(
    'msProduct' => !empty($includeContent)
        ? $modx->getSelectColumns('msProduct', 'msProduct')
        : $modx->getSelectColumns('msProduct', 'msProduct', '', array('content'), true),
    'Data' => $modx->getSelectColumns('msProductData', 'Data', '', array('id'), true),
    'Vendor' => $modx->getSelectColumns('msVendor', 'Vendor', 'vendor.', array('id'), true),
);

// Include thumbnails
if (!empty($includeThumbs)) {
    $thumbs = array_map('trim', explode(',', $includeThumbs));
    foreach ($thumbs as $thumb) {
        if (empty($thumb)) {
            continue;
        }
        $leftJoin[$thumb] = array(
            'class' => 'msProductFile',
            'on' => "`{$thumb}`.product_id = msProduct.id AND `{$thumb}`.rank = 0 AND `{$thumb}`.path LIKE '%/{$thumb}/%'",
        );
        $select[$thumb] = "`{$thumb}`.url as `{$thumb}`";
        $groupby[] = "`{$thumb}`.url";
    }
}

// Include linked products
$innerJoin = array();
if (!empty($link) && !empty($master)) {
    $innerJoin['Link'] = array(
        'class' => 'msProductLink',
        'on' => 'msProduct.id = Link.slave AND Link.link = ' . $link,
    );
    $where['Link.master'] = $master;
} elseif (!empty($link) && !empty($slave)) {
    $innerJoin['Link'] = array(
        'class' => 'msProductLink',
        'on' => 'msProduct.id = Link.master AND Link.link = ' . $link,
    );
    $where['Link.slave'] = $slave;
}

// Add user parameters
foreach (array('where', 'leftJoin', 'innerJoin', 'select', 'groupby') as $v) {
    if (!empty($scriptProperties[$v])) {
        $tmp = $scriptProperties[$v];
        if (!is_array($tmp)) {
            $tmp = json_decode($tmp, true);
        }
        if (is_array($tmp)) {
            $$v = array_merge($$v, $tmp);
        }
    }
    unset($scriptProperties[$v]);
}
$pdoFetch->addTime('Conditions prepared');

// Add filters by options
$joinedOptions = array();
if (!empty($scriptProperties['optionFilters'])) {
    $filters = json_decode($scriptProperties['optionFilters'], true);
    foreach ($filters as $key => $value) {
        $option = preg_replace('#\:.*#', '', $key);
        $key = str_replace($option, $option . '.value', $key);
        if (!in_array($option, $joinedOptions)) {
            $leftJoin[$option] = array(
                'class' => 'msProductOption',
                'on' => "`{$option}`.product_id = Data.id AND `{$option}`.key = '{$option}'",
            );
            $joinedOptions[] = $option;
            $where[$key] = $value;
        }
    }
}

// Add sort by options
if (!empty($scriptProperties['sortbyOptions'])) {
    $sorts = array_map('trim', explode(',', $scriptProperties['sortbyOptions']));
    foreach ($sorts as $sort) {
        $sort = explode(':', $sort);
        $option = $sort[0];
        if (preg_match("#\b{$option}\b#", $scriptProperties['sortby'], $matches)) {
            $type = 'string';
            if (isset($sort[1])) {
                $type = $sort[1];
            }
            switch ($type) {
                case 'number':
                case 'decimal':
                    $sortbyOptions = "CAST(`{$option}`.`value` AS DECIMAL(13,3))";
                    break;
                case 'int':
                case 'integer':
                    $sortbyOptions = "CAST(`{$option}`.`value` AS UNSIGNED INTEGER)";
                    break;
                case 'date':
                case 'datetime':
                    $sortbyOptions = "CAST(`{$option}`.`value` AS DATETIME)";
                    break;
                default:
                    $sortbyOptions = "`{$option}`.`value`";
                    break;
            }
            $scriptProperties['sortby'] = preg_replace("#\b{$option}\b#", $sortbyOptions, $scriptProperties['sortby']);
            $groupby[] = "`{$option}`.value";
        }

        if (!in_array($option, $joinedOptions)) {
            $leftJoin[$option] = array(
                'class' => 'msProductOption',
                'on' => "`{$option}`.product_id = Data.id AND `{$option}`.key = '{$option}'",
            );
            $joinedOptions[] = $option;
        }

    }
}

$default = array(
    'class' => 'msProduct',
    'where' => $where,
    'leftJoin' => $leftJoin,
    'innerJoin' => $innerJoin,
    'select' => $select,
    'sortby' => 'msProduct.id',
    'sortdir' => 'ASC',
    'groupby' => implode(', ', $groupby),
    'return' => !empty($returnIds)
        ? 'ids'
        : 'data',
    'nestedChunkPrefix' => 'minishop2_',
);
// Merge all properties and run!
$pdoFetch->setConfig(array_merge($default, $scriptProperties), false);
$rows = $pdoFetch->run();

// Process rows
$output = array();
if (!empty($rows) && is_array($rows)) {
    $c = $modx->newQuery('modPluginEvent', array('event:IN' => array('msOnGetProductPrice', 'msOnGetProductWeight')));
    $c->innerJoin('modPlugin', 'modPlugin', 'modPlugin.id = modPluginEvent.pluginid');
    $c->where('modPlugin.disabled = 0');

    $modifications = $modx->getOption('ms2_price_snippet', null, false, true) ||
        $modx->getOption('ms2_weight_snippet', null, false, true) || $modx->getCount('modPluginEvent', $c);
    if ($modifications) {
        /** @var msProductData $product */
        $product = $modx->newObject('msProductData');
    }
    $pdoFetch->addTime('Checked the active modifiers');

    $opt_time = 0;
    foreach ($rows as $k => $row) {
        if ($modifications) {
            $product->fromArray($row, '', true, true);
            $tmp = $row['price'];
            $row['price'] = $product->getPrice($row);
            $row['weight'] = $product->getWeight($row);
            // A discount here, so we should replace old price
            if ($row['price'] < $tmp) {
                $row['old_price'] = $tmp;
            }
        }
        $row['price'] = $miniShop2->formatPrice($row['price']);
        $row['old_price'] = $miniShop2->formatPrice($row['old_price']);
        $row['weight'] = $miniShop2->formatWeight($row['weight']);
        $row['idx'] = $pdoFetch->idx++;

        $opt_time_start = microtime(true);
        $options = $modx->call('msProductData', 'loadOptions', array(&$modx, $row['id']));
        $row = array_merge($row, $options);
        $opt_time += microtime(true) - $opt_time_start;

        $tpl = $pdoFetch->defineChunk($row);
        $output[] = $pdoFetch->getChunk($tpl, $row);
    }
    $pdoFetch->addTime('Time to load products options', $opt_time);
}

$log = '';
if ($modx->user->hasSessionContext('mgr') && !empty($showLog)) {
    $log .= '<pre class="msProductsLog">' . print_r($pdoFetch->getTime(), 1) . '</pre>';
}

// Return output
if (!empty($returnIds) && is_string($rows)) {
    $modx->setPlaceholder('msProducts.log', $log);
    if (!empty($toPlaceholder)) {
        $modx->setPlaceholder($toPlaceholder, $rows);
    } else {
        return $rows;
    }
} elseif (!empty($toSeparatePlaceholders)) {
    $output['log'] = $log;
    $modx->setPlaceholders($output, $toSeparatePlaceholders);
} else {
    if (empty($outputSeparator)) {
        $outputSeparator = "\n";
    }
    $output['log'] = $log;
    $output = implode($outputSeparator, $output);

    if (!empty($tplWrapper) && (!empty($wrapIfEmpty) || !empty($output))) {
        $output = $pdoFetch->getChunk($tplWrapper, array(
            'output' => $output,
        ));
    }

    if (!empty($toPlaceholder)) {
        $modx->setPlaceholder($toPlaceholder, $output);
    } else {
        return $output;
    }
}
inkeri21
20 июня 2023, 15:51
0
Спасибо. В Категории смотрела, галочки стоят верные. У 8 класса и у 10 класса.
inkeri21
20 июня 2023, 15:41
0
Возможно этот более верный

<div class="row">
  [[pdoResources?
  &parents=`1012`
  &resources=`1014,1020,1022`
  &tpl=`category_submenu_cust_tpl`
  &includeTVs=`image`
  &processTVs=`1`
  &tvPrefix=``
  &limit=`48`
  &depth=`1`
  &sortby=`parent`
  ]]
</div>
inkeri21
20 июня 2023, 15:13
0
Не уверена, что тот самый код. Изначально не я сайт писала. Стараюсь самоучкой разобраться.

{if $_modx->resource.pr_hide_category != 1}
                  <div class="prod_cats row">
                    [[pdoResources?
                      	&tpl=`category_list_tpl`
                      	&parents=`[[*id]]`
                      	&templates=`4`
                      	&limit=`48`
                      	&depth=`0`
                      	&sortby=`parent`
                      	&sortby=`{"parent":"ASC","menuindex":"ASC"}`
                      	&includeTVs=`image`
                      	&processTVs=`1`
                      	&tvPrefix=``
                      ]]
                  </div>
             {/if}

            {if $_modx->resource.pr_hide_products != 1}
              <div class="the-category-items row">
                  [[msProducts?
                  	&tpl=`category_prod_tpl`
                  	&parents=`[[*id]]`
                  	&limit=`48`
                  	&sortby=`parent`
                  	&sortby=`{"menuindex":"ASC","parent":"ASC"}`
                  	&includeTVs=`image`
                  ]]
              </div>
inkeri21
01 марта 2023, 17:40
0
да, спасибо, по родителям тоже все верно стоит. У товаров родителя стоят вложенные мама-папа (подкатегории).
А у вложенных (подкатегории) является основная категория.
inkeri21
01 марта 2023, 15:50
0
У меня та же самая проблема. Но галочки в категориях стоят верно. Но в итоге один товары правильно, а в другой и те и другие. Хотя галочки стоят верно. Не могу найти в чем причина.
inkeri21
07 февраля 2023, 13:21
0
Хотелось бы более развернутый ответ. Так как в шаблонах много категорий и они в PdoResource