O
O
Oleg Shchavelev2017-02-09 19:41:54
MODX
Oleg Shchavelev, 2017-02-09 19:41:54

How to regenerate images in Minishop 2 store?

I wanted to clarify how to regenerate all pictures through the CMS when changing the parameters in the file sources.
On the site in modstore in the description of CCK Minishop 2 it is written:

All preview images are generated when the image is loaded. You can specify the necessary parameters in the file source setting (MS has its own, of course).
When changing parameters, you can regenerate thumbnails for all product images at once.

So I wanted to clarify, who knows where the treasured image refresh button is?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2017-02-09
@Sanes

Version MS2 2.1 to version 2.3 apparently the same way. In 2.4 the gallery has changed.
Perhaps it will work only for 1 product, there was a script for all products.
=================
a06c82d7de55463f8335052bcd0fe49f.png

A
Andrew, 2019-08-31
@Batyabest

Here is a script that will allow you to regenerate all photos. Run it from the admin panel to packages - Console. Console must be pre-installed.

<?php
$step = 5;
$offset = isset($_SESSION['galgenoffset']) && $_SESSION['galgenoffset'] ? $_SESSION['galgenoffset'] : 0;
$miniShop2 = $modx->getService('minishop2');
$modx->setLogLevel(MODX_LOG_LEVEL_ERROR);
$q = $modx->newQuery('msProductFile', array('parent' => 0));
$total = $modx->getCount('msProductFile', $q);
$q->sortby('product_id', 'ASC');
$q->sortby('rank', 'DESC');
$q->limit($step,$offset);
$resources = $modx->getCollection('msProductFile', $q);
foreach ($resources as $resource) {
    $modx->runProcessor('mgr/gallery/generate', array('id' => $resource->id),
        array('processors_path' => $modx->getOption('core_path').'components/minishop2/processors/'));
}

$_SESSION['galgenoffset'] = $offset + $step;
if ($_SESSION['galgenoffset'] >= $total) {
  $sucsess = 100;
  $_SESSION['Console']['completed'] = true;
  unset($_SESSION['galgenoffset']);
} else {
  $sucsess = round($_SESSION['galgenoffset'] / $total, 2) * 100;
  $_SESSION['Console']['completed'] = false;
}
for ($i=0; $i<=100; $i++) {
    if ($i <= $sucsess) {
        print '=';
    } else {
        print '_';
    }
}
$current = $_SESSION['galgenoffset'] ?
           $_SESSION['galgenoffset'] :
           ($sucsess == 100 ? $total : 0);
print "\n";
print $sucsess.'% ('.$current.')'."\n\n";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question