GithubHelp home page GithubHelp logo

lizardmedia / product-attachments-magento2 Goto Github PK

View Code? Open in Web Editor NEW
40.0 7.0 36.0 135 KB

Magento2 module for adding downloadable product attachments

License: MIT License

PHP 96.68% HTML 2.51% JavaScript 0.82%
magento2 magento2-module attachments

product-attachments-magento2's People

Contributors

bartoszkubicki avatar eugene-markov avatar maciejslawik avatar mokadev avatar syidev avatar voytech-net avatar zbigniewkuraslm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

product-attachments-magento2's Issues

PHP 8.0/8.1 compatibility ?

Hello, I can't install this module on a PHP 8.0/8.1 system using composer; is this something you're planning to do? PHP 7.4 won't stay supported much longer.

Attachments get copied to root upon download

Magento: 2.4.1
PHP: 7.3
Module: 1.3.5
Docroot in /pub/

Whenever I download an attached file it will dump a copy of that file in the magento root folder first before allowing the download. In my case the DOCroot is /pub/ but still the files to download end up with a copy in the magento root (where the vendor folder resides). The file dumped is totally inaccessible from the browser so it does not make much sense to put it there. It does not matter if downloaded from frontend or backend, there is always a copy. The download itself works fine though.

Download paths look like this:

Admin
https://www.example.com/admin/downloadable/attachment_file/preview/id/146

Frontend:
https://www.example.com/downloadable/download/attachment/id/102/

Php parse error

PHP Parse error: syntax error, unexpected '?' in /app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php on line 244

Backend url

It seem that backend url is changed to backend_name from env.php
in our case its backend + downloadable

so if i visit site/backend i get 404 but when i visit site/backend/downloadable i get admin login page.

all sections are affected by that backend/downloadable/cache/index

any idea on how to fix this ?

Error when saving a product with existing attachment

When I try to save a product with an existing attachment I get this error:
Item (LizardMedia\ProductAttachment\Model\Attachment) with the same ID "195" already exists.

I cleaned all lizardmedia* tables to be sure everything is from scratch. I also removed all files in pub\media\downloadable\files\attachment.

Then I uploaded a PDF to an existing product which worked fine. But editing this product afterwards failed with the mentioned error.

External script

Hello,
how can i use this module from an external script in php?

Thank you

Problem with Deleting Attachments

Step to reproduce the issue :

  1. Created a product and uploaded the attachment and saved the product.
  2. I want to delete the saved attachment.

I am getting below error while deleting the attachment.

Fatal error: Uncaught TypeError: Return value of LizardMedia\ProductAttachment\Model\AttachmentRepository::updateAttachment() must be of the type integer, string returned in /app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php:466 Stack trace: #0 /app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php(325): LizardMedia\ProductAttachment\Model\AttachmentRepository->updateAttachment(Object(Model\Sample\Model\Catalog\Product\Interceptor), Object(LizardMedia\ProductAttachment\Model\Attachment), true) #1 /app/code/LizardMedia/ProductAttachment/Model/Attachment/UpdateHandler.php(55): LizardMedia\ProductAttachment\Model\AttachmentRepository->save('TestProduct002', Object(LizardMedia\ProductAttachment\Model\Attachment), true) #2 /vendor/magento/framework/EntityManager/Operation/Update/UpdateExtensions.php(49): LizardMedia\ProductAttachment\Model\Attachment\UpdateHandler->execute(Object(Model\Sample\Model\Ca in /app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php on line 466

Tab "Attachments" not change

Hi,

When I try to change from product information page (admin) the name of Tab from "Attachments" to other for example "Extra Files" still the tab shows up as "Attachments".

Any idea why? by the way, when I replace the name of the file or change the file attached all working , only the issue on Tab name that stuck on "Attachments"

getTitle() must be of the type string, null returned in

Have following error:

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Return value of LizardMedia\\ProductAttachment\\Model\\Attachment::getTitle() must be of the type string, null returned in /home/pplazam2/domains/plafondplaza.nl/public_html/app/code/LizardMedia/ProductAttachment/Model/Attachment.php:167\nStack trace:\n#0 /home/pplazam2/domains/plafondplaza.nl/public_html/app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php(273): LizardMedia\\ProductAttachment\\Model\\Attachment->getTitle()\n#1 /home/pplazam2/domains/plafondplaza.nl/public_html/app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php(258): LizardMedia\\ProductAttachment\\Model\\AttachmentRepository->setBasicFields(Object(LizardMedia\\ProductAttachment\\Model\\Attachment), Object(LizardMedia\\ProductAttachment\\Model\\Attachment))\n#2 /home/pplazam2/domains/plafondplaza.nl/public_html/app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php(223): LizardMedia\\ProductAttachment\\Model\\AttachmentRepository->buildAttachment(Object(Lizard...\n', referer: https://plafondplaza.nl/backend/catalog/product/edit/id/543/key/4a319c0dfcd151b03113021bd5b00cbe0a052d9eae9acc4db8379ba8ee716676/

after this error, was able to save product without any problems.. seem it has something to do with store values ( if you have attachment at store level and not default store )

Tab position

Is it possible to configure Attachments Tab position on product page? Maybe I would like to move the Tab to 2nd or even last position.

Problem with Database if using prefix

Step to reproduce :

  • Installing Magento 2 with a database prefix like mg2_
  • Install Product Attachment with setup:upgrade

Explaination :

  • Magento is trying to find index lizardmedia_product_attachment but during the installation Magento named it {prafix}lizardmedia_product_attachment. So it's not found

Solution to avoid the problem:

  • Replace the following lines :
    • in Setup/InstallSchema.php line 125 : $setup->getTable(Attachment::MAIN_TABLE),
    • in Setup/InstallSchema.php line 129 : $setup->getTable(Attachment::MAIN_TABLE),

PHP Fatal error: Uncaught TypeError: Return value of LizardMedia\ProductAttachment\Model\AttachmentRepository::getAttachments()

Hi,

We get this error, and now i'm wondering if this is correct

private function getAttachments(ProductInterface $product) : ?Collection

Because the error log say this will return a array

return $product->getProductAttachments();

And here it is a array

$this->setProductAttachments($product, $attachments);

PHP Fatal error:  Uncaught TypeError: Return value of LizardMedia\ProductAttachment\Model\AttachmentRepository::getAttachments() must be an instance of LizardMedia\ProductAttachment\Model\ResourceModel\Attachment\Collection or null, array returned in /...../vendor/lizardmedia/module-product-attachments/Model/AttachmentRepository.php:239
Stack trace:
#0 ...../vendor/lizardmedia/module-product-attachments/Model/AttachmentRepository.php(214): LizardMedia\ProductAttachment\Model\AttachmentRepository->getAttachments(Object(Magento\Catalog\Model\Product\Interceptor))
#1 /...../vendor/lizardmedia/module-product-attachments/Model/Attachment/UpdateHandler.php(49): LizardMedia\ProductAttachment\Model\AttachmentRepository->getAttachmentsByProduct(Object(Magento\Catalog\Model\Product\Interceptor))
#2 /var/domains/ in ...../vendor/lizardmedia/module-product-attachments/Model/AttachmentRepository.php on line 239

Can't attach a file

Hello,

I installed the plugin but when I attach a file I get an error in the webpage:

"A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later."

and no file is attached.

Francesco

Its not working for Bundle products

Create any Bundle product with one or more bundle options then save the product.

Now add the Attachments then re save the product, now all the options created for the bundle product getting disappeared and the product type changes to simple product.

Session ID is not used as URL parameter anymore.

Hello,

I´m trying your extension in my project but when I try to run the product edit form, it displays this message"Session ID is not used as URL parameter anymore.", the problem is apparently in Attachments.php in the line where it calls this method:

'url' => $this->urlBuilder->addSessionParam()->getUrl(
'downloadable/attachment_file/upload',
[Attachment::ATTACHMENT_TYPE => 'attachments', '_secure' => true]
)

under the method: $attachmentUploader['arguments']['data']['config']

So far I´ve just installed the extension via composer on a clean magento install

I´m quite new to magento, and I don´t understand what the problem is, Could you please help me?

Thanks in advance.

Issues on WAMP

I have the same issue #34 on WAMP environnement. I know that Magento is not recommended on Windows.

I think there's a problem with the DIRECTORY_SEPARATOR ( "/" on Linux, " \ " on Windows).
On the file vendor\lizardmedia\module-product-attachments\Ui\DataProvider\Product\Form\Modifier\Attachments.php at line 106 :
$attachmentsPath = Composite::CHILDREN_PATH . DIRECTORY_SEPARATOR . Composite::CONTAINER_ATTACHMENTS;
give me "product_attachment/children\container_attachments" instead of "product_attachment\children\container_attachments"

If I do the change, the form appear on admin panel but it doesn't work (the file is uploaded but stay in /tmp directory, no entry on database).

I think there're others issues due to this problem like in this file : lizardmedia\module-product-attachments\Model\Attachment.php
Line 109 : return 'downloadable/tmp/attachment';
Line 117 : return 'downloadable/files/attachment';

I did not succeed to use the plugin on WAMP but I don't think that's a big deal to do it.

Anyways, thank you for your good work !

extra option

Hi, I would like to add same option from front end, we have module that add the product, any option to add same option and store it in the DB?

feel free to contact me [email protected]

Compatibility Magento 2.4 / PHP 7.4?

When I try to update to Magento 2.4 (running PHP 7.4) composer fails with this error message: "lizardmedia/module-product-attachments 1.3.5 requires php ~7.1.0|~7.2.0|~7.3.0 -> your PHP version (7.4.8) does not satisfy that requirement."

Can you update the module?

Title not connected correctly

Hi,

thx for your work!

I found an issue with storing the title of the attachments.

The attachment is saved:
Bildschirmfoto 2020-12-21 um 10 49 11

And the title is saved:
Bildschirmfoto 2020-12-21 um 10 49 02

But the title doesn't show up in the magento backend:
Bildschirmfoto 2020-12-21 um 10 48 38

If I save the attachment again, the the new title is saved but the old one still exists:
Bildschirmfoto 2020-12-21 um 10 51 06

And still does not show up:
Bildschirmfoto 2020-12-21 um 10 52 13

I'm using Magento 2.3.5 and this is a grouped product.

Best, Tim

Conflicts with Magento Base API

Hi,

I have spotted one bugs linked to the Magento API and blocking updates of products.

Context

  • Magento 2.3.3 - REST API

Step to reproduce

  1. Launch the following request :
  • PUT <magento-url>/rest/V1/products/<product-sku>
  • { "product": { "price": 5.27 } }

Expecting Result

  • Product Data

Having

Fatal Error: 'Uncaught TypeError: Return value of LizardMedia\ProductAttachment\Model\AttachmentRepository::getAttachments() must be an instance of LizardMedia\ProductAttachment\Model\ResourceModel\Attachment\Collection or null, array returned in /home/magento/fm-medical/app/code/LizardMedia/ProductAttachment/Model/AttachmentRepository.php:255

Attachments div empty

@bartoszkubicki Hello Bartosz, today I installed Magento 2.3.3 on a clean OS, first I tried installing your extensions version 1.3.2 with no luck and then I triend with version 1.3.4, and Im getting the same issue, I can see the Attachments section on admin panel but it has no content, I checked logs and console, it doesnt trigger any error Same issue with Magento 2.3.5 as I mentioned before. Hope you can help me out. P.D. I dived into the code and I dont see anything under the fieldset section of the attachments module. I dontt know if theres anything else I could check, I`m using windows server 2012, xampp and chrome.

Thanks a lot!

Not Able to Download the PDF

PDF added in admin side successfully and also in end user front end its showing under attachments but when I click on file name to download its redirecting to http:// base-url /downloadable/download/attachment/id/1/ and then redirecting to product page but No pdf attachment downloaded.

Can't download the attached file

Hello,

when I try to download the file I attached, I get this error:

"Sorry, there was an error getting requested content."

Francesco

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.