zakaria99 Posted March 16, 2015 Share Posted March 16, 2015 Salut, je travail sur une solution personnalise de prestashop, j'ai cree un controller backend qui ajoute une page speical qui permi de cree un produit avec fichier pdf. mon probleme est que j'arrive a cree mon produit puis un attachement qui va avec, seulement quand je telecharge le fichier, il est a 0octect de taille. est ce que peut avoir d'aide sur la classe AttachmementCore et ce bout de code : $atch = new AttachmentCore(); $atch->file = $file['tmp_name']; $atch->file_name = $file['rename']; $atch->mime = $file['mime']; $atch->name = [ConfigurationCore::get('PS_LANG_DEFAULT') => 'Prod_n' . $prod_numero]; $atch->file_size = $file['size']; $atch->add(); $atch->attachProduct($prod->id); //$atch->save(); merci. Link to comment Share on other sites More sharing options...
coeos.pro Posted March 16, 2015 Share Posted March 16, 2015 tu as oublié $file devant [ConfigurationCore::get('PS_LANG_DEFAULT') => 'Prod_n' . $prod_numero]; c'est une faute dans le copié collé de ton code ? 1 Link to comment Share on other sites More sharing options...
zakaria99 Posted March 16, 2015 Author Share Posted March 16, 2015 j'ai oublie la ligne suivante : $prod_numero = getNextProductNumero(); $atch = new AttachmentCore(); ....... Link to comment Share on other sites More sharing options...
zakaria99 Posted March 16, 2015 Author Share Posted March 16, 2015 Problème résolut , je laisse la solution au cas ou : $file = Tools::fileAttachment('myfile'); file_put_contents(_PS_DOWNLOAD_DIR_ . $file['rename'], $file['content']); $atch = new AttachmentCore(); $atch->file = $file['rename']; $atch->file_name = $file['rename']; $atch->mime = $file['mime']; $atch->name = [ConfigurationCore::get('PS_LANG_DEFAULT') => 'document name']; $atch->add(); $atch->attachProduct($prod->id); //en attach le fichier au produit merci. Link to comment Share on other sites More sharing options...
Mediacom87 Posted March 17, 2015 Share Posted March 17, 2015 Bonjour, merci d'indiquer [Résolu] dans le titre de votre premier topic. 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