Skip to content

Commit

Permalink
[9.0][IMP] connector_prestashop_catalog_manager: Change image from da…
Browse files Browse the repository at this point in the history
…tabase store to linked to ps image after export

(cherry picked from commit 8e3b16b)
  • Loading branch information
sergio-teruel authored and pedrobaeza committed Aug 21, 2018
1 parent 9d795e6 commit f5d8f24
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from openerp.addons.connector_prestashop.unit.mapper import (
PrestashopExportMapper
)

from openerp.addons.connector_prestashop.unit.backend_adapter import (
PrestaShopWebServiceImage
)
from openerp.addons.connector_prestashop.backend import prestashop

from openerp import models, fields
Expand Down Expand Up @@ -54,9 +56,26 @@ def _run(self, fields=None):
self._validate_data(record)
self.prestashop_id = self._create(record)
self._after_export()
self._link_image_to_url()
message = _('Record exported with ID %s on Prestashop.')
return message % self.prestashop_id

def _link_image_to_url(self):
"""Change image storage to a url linked to product prestashop image"""
api = PrestaShopWebServiceImage(
api_url=self.backend_record.location,
api_key=self.backend_record.webservice_key)
full_public_url = api.get_image_public_url({
'id_image': str(self.prestashop_id),
'type': 'image/jpeg',
})
if self.binding.url != full_public_url:
self.binding.with_context(connector_no_export=True).write({
'url': full_public_url,
'file_db_store': False,
'storage': 'url',
})


@prestashop
class ProductImageExportMapper(PrestashopExportMapper):
Expand Down

0 comments on commit f5d8f24

Please sign in to comment.