DARLEI FERNANDO ZILL Posted October 9, 2017 Share Posted October 9, 2017 I recently created a module to add a new attribute to product images It works perfectly with the field added by the module, however the native field "cover" has stopped working (the value is not saved while the module is active). In addition to the module files and overrides (Image.php and AdminProductsController.php), i changed some files from the "src" folder. src/PrestaShopBundle/Controller/Admin/ProductImageController.php ->add('infografico', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', array( 'label' => $translator->trans('Infográfico', array(), 'Admin.Catalog.Feature'), 'required' => false, )) src/Adapter/Product/AdminProductWrapper.php (ajaxProcessUpdateImage) $img->infografico = $data['infografico']; src/Adapter/Product/ProductDataProvider.php (getImage) 'infografico' => $imageData->infografico ? true : false, src/PrestaShopBundle/Resources/views/Admin/ProductImage/form.html.twig [spam-filter] form_widget(form.infografico) [spam-filter] Am I forgetting something or doing something wrong? Thank you in advance for any help you can give me. My Prestashop version - 1.7.2.1 Link to comment Share on other sites More sharing options...
NassNus Posted November 21, 2017 Share Posted November 21, 2017 If you have override the methode ajaxProcessUpdateImage in AdminProductWrapper you need add the update of cover image! Quote $img = new Image((int)$idImage); if ($data['cover']) { Image::deleteCover((int)$img->id_product); $img->cover = 1; } $img->legend = $data['legend']; $img->update(); Link to comment Share on other sites More sharing options...
DARLEI FERNANDO ZILL Posted November 21, 2017 Author Share Posted November 21, 2017 Yes Nassnus...my function: public function ajaxProcessUpdateImage($idImage, $data) { $img = new Image((int)$idImage); if ($data['cover']) { Image::deleteCover((int)$img->id_product); $img->cover = 1; } $img->legend = $data['legend']; if ($data['infografico']) { $img->infografico = 1; } $img->update(); return $img; } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now