Jump to content
thirty bees forum
  • 0

Show Images from main shop (so no duplicates are needed)


Question

Posted

Hello Everyone 🙂

We have three prestashops of which Shop A is the main shop containing all products. Shop B and C are subshops holding special categories from main shop. All data is synchronized between main and the two subshops everyday. So new products will be distributed to subshops automatically.

Now all images reside only inside the main shops img/p folders. For this I simply replaced the end of Link.php's getImageLink function:

$new_path = str_replace("www.subshopdomain.tld/s2t", "www.mainshopdomain.tld/shop5", $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path);
return $new_path;

But this isn't working anymore and no pictures are being displayed. The new srcset attribute now only displays the three links:

https://www.subshopdomain.tld 211w,
https://www.subshopdomain.tld 218w,
https://www.subshopdomain.tld 250w

So as you can see instead of replacing anything, it just deleted everything important after the TLD and I can't figure out why. Anybody a clue? 🙂

Thanks a lot!

Oli

5 answers to this question

Recommended Posts

  • 0
Posted

Du bisch ja Schwizer :classic_ohmy:

Should be 

$voh_path = str_replace("blue-door.ch/s2t", "visionofhemp.ch/shop5", ($this->protocol_content.Tools::getMediaServer($uriPath).$uriPath));
return $voh_path;

 

 

  • 0
Posted

Before looking into the code. Are you sure this is needed? We have excat the same multistore setup as you. But the images aren't stored multiple times. They are just reachable with multiple domains... 

  • 0
Posted (edited)

Thank you so much for this fast reply!!!

Ahm I'm sorry, we're not running multi shop. We have external self written tools that ex and import the data from main shop to the two separate ones. These tools also sync the shops with our local cash registers (actually the reason why we run those self written tools). I never tried setting up multi shop, not sure how it works. Maybe multishops will be our future but at the moment one subshop and the main shop are still running prestashop. And the second subshop I'm moving to TB right now.

As said, the only thing I had to change so far was in Link.php the last line of the getImageLink function:

return $this->protocol_content.Tools::getMediaServer($uriPath).$uriPath;

As images and URLs are the same over all shops I only took that return value, saved it into a variable and str_replaced the domain names.

$voh_path = str_replace("blue-door.ch/s2t", "visionofhemp.ch/shop5", ($this->protocol_content.Tools::getMediaServer($uri_path).$uri_path));
return $voh_path;

I tried it manually (went to website > browser dev tools > replaced all 3 URLs in srcset) and the images were showing. But the code somehow doesn't work.

And what I get is:

https://www.blue-door.ch/s2t 211w,
https://www.blue-door.ch/s2t 218w,
https://www.blue-door.ch/s2t 250w

instead of

https://www.visionofhemp.ch/shop5/furtherPathToImage1 211w,
https://www.visionofhemp.ch/shop5/furtherPathToImage2 218w,
https://www.visionofhemp.ch/shop5/furtherPathToImage3 250w

 

Edited by oliiiix
  • 0
Posted

Haha jo bini 😄

Who took away this underscore!!! 😃 How embarrassing! Well sometimes four eyes see more than two, lucky me.

Danke viiielmol für dini Hilf!

All the best,

Oli

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...