XH_Shop backend issue

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

milkodb
Posts: 43
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

XH_Shop backend issue

Post by milkodb » Thu Aug 15, 2019 3:24 pm

Hi,
I decided to bring some sites from Wellrad to XH_shop due to problems verified with CMSimple_XH updates and various plugins and also to adapt the layout in a responsive way.
Regardless of the fact that it is almost impossible for me to decide where to put the product images (on wellrad they were in a particular folder, not in "userfiles"), after having moved these images into userfiles> images> (personal folder inserted in config.php) something curious happens: The images are both correctly displayed in the backend, which means that the path is correct and recognized by the controller and the preview image is correctly connected to the product in the catalog. However it is impossible to choose or change the image for existing products or for new products because the selectors are not visible and replaced by the error phrase "No pictures found in" (./userfiles/images/libri/small/!). It seems $ imageArray is always empty although it uses $ path which seems to be correct. I tried to look for discussions on both here and on GiftHub but I didn't find any.

Can anyone suggest a solution?

Thank you
Milko

frase
Posts: 3010
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: XH_Shop backend issue

Post by frase » Thu Aug 15, 2019 3:47 pm

It is difficult to answer without knowing the specific case.

First you should set the paths correctly in the shop configuration.
for the article pictures:
Image folder -> libri/
for the thumbnails:
Preview folder -> libri/small/
(Note the slashes!)

Then everything should work correctly, if the corresponding pictures are really there.

milkodb
Posts: 43
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: XH_Shop backend issue

Post by milkodb » Thu Aug 15, 2019 4:12 pm

Yes, of course.
All it's correct in config.php, slashes included.

Problem should to be connected with general php path declaration somewhere for variable $path for $imageArray:

i.e., commenting lines from 15 till 17 in Backend.php:

public function picSelector($path, array $imageArray, $selectedPic, $element)
{

// if (empty($imageArray)) {
// return '<p class="xhsWarn">' . sprintf($this->labels['no_pictures_found'], $path) . '</p>';
// }

$js = ' data-xhs="' . XH_hsc(json_encode(compact('path', 'element'))) . '"';

$html = "\n" . '<select class="xhsPicSelector" name="' . $element .'"' . $js . '>';
$html .= "\n\t" . '<option>' . $this->labels['no_pic'] . '</option>';
foreach ($imageArray as $pic) {
$selected = ($pic == $selectedPic) ? ' selected="selected"' : '';
$html .= "\n\t" . '<option' . $selected . '>' . $pic . '</option>';
}
$html .= "\n" . '</select>';
return $html;
}

obviously selectors appear and both books image still are correctly shown, while Selectors are both empty.

This issue is only in backend. No code touched here or somewhere else...

So, my question is: $path in Backend.php works both for preview imeges and picts or not? And if not, here I can verify pict path in php from which selectors are connected to folders?

Thanks
Last edited by milkodb on Thu Aug 15, 2019 4:53 pm, edited 1 time in total.
Milko

frase
Posts: 3010
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: XH_Shop backend issue

Post by frase » Thu Aug 15, 2019 4:36 pm

Sorry, I have to ask a stupid question again.
Are you using the latest shop version?

https://github.com/cmsimple-xh/xhshop/releases

For me the name of the file is:
BackEndView.php
And the three deleted lines are 15 - 17.

There is probably something else changed somewhere.

I can't answer the PHP question for you.
You have to wait until Christoph (cmb) answers.

milkodb
Posts: 43
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: XH_Shop backend issue

Post by milkodb » Thu Aug 15, 2019 4:47 pm

Well, I hope I have the last version. (your question isn't stupid at all) :D I've downloaded it from XH repository and it's reported as "Updated on 23 Nov 2018".

Yes, sorry, the function is in BackEndView.php. I were wrong.
I've tried as shown to comment these lines only for verify if selector function was ok and that is.
Thanks for your attention I will waiting fo CMB.

Bye
Milko

milkodb
Posts: 43
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: XH_Shop backend issue

Post by milkodb » Fri Aug 16, 2019 11:22 am

Hi all, ok, I've found the problem:

In Wellrad it was enough to enter the path of the preview folders and the path of the largest image. The path led to the set directory and allowed to view any sub-directories. Thus, if the images were organized by "category" of the product in related folders, it was enough to point final folder in declared path and select the desired image within it because all the images contained in any dependent folders were shown anyway.

XH_Shop does not seem to allow this possibility. In fact, it does not allow the display of any subdirectories present in the final folder indicated in the path set in the plugin configuration. Clearly, the condition required for $ imageArray is not satisfied and even if excluded in the test, just as obviously the selectors appear but do not indicate any image because, in fact, in that specific directory there are none. I will try to solve the problem and ask CMB for his kind cooperation.
If someone comes up with something in the meantime his advice is very welcome. Good summer everyone.
Milko

frase
Posts: 3010
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: XH_Shop backend issue

Post by frase » Fri Aug 16, 2019 12:02 pm

Yes, there are some differences to the Wellrad shop.

Nevertheless I don't see any problem with your pictures.
Use the folders as discussed above.
You could even store all your pictures in one folder - that works too.
To keep the overview you can give the pictures corresponding names.
One prefix for the category and another for the size - and you will find the pictures easily.

Of course it is a bit more complex if you want or have to change from Wellrad to XH-Shop.
But the XH-Shop is more modern and works with the new XH versions ;-)

milkodb
Posts: 43
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: XH_Shop backend issue

Post by milkodb » Fri Aug 16, 2019 12:32 pm

yes, of course, clearly.
Everything's fine if you build a new store.

But the not particularly insignificant detail is that at this point I have to change every link to the images on all the catalogs of each store. And they are not few. :)

Hi.
Milko

frase
Posts: 3010
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: XH_Shop backend issue

Post by frase » Fri Aug 16, 2019 12:40 pm

I see what you mean.
But, probably, we have to live with the XH shop as it is for the time being.
milkodb wrote:
Fri Aug 16, 2019 12:32 pm
But the not particularly insignificant detail is that at this point I have to change every link to the images on all the catalogs of each store. And they are not few. :)
Do you mean external links to the pictures?
Then leave the "old" folder with the Wellrad pictures on the server. Then the links will continue to work.
All "new" pictures you then arrange according to the new method - and the external links then just point to the new pictures.
Would that work?

milkodb
Posts: 43
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: XH_Shop backend issue

Post by milkodb » Fri Aug 16, 2019 12:51 pm

No, I mean the links in catalog.php and catalog.bak.php. At this point the paths to the subfolders must be deleted and only the names of the original documents left. The second question is that some people are not able to act directly in the frontend of the plugin on XH. So I created a database with a "stupid-proof" graphical interface that directly updates the catalog via FTP. And in order not to create any possibility of user manipulation, there is no directory configuration backend. So I have to pick up the application code and change the settings for each database... good job to me ... :D
Milko

Post Reply