User Tools

Site Tools


Sidebar

magento_2:product_attachments

For more details see the Product Attachments extension page.

Product Attachments for Magento 2

Provide customers with additional details about the products they purchase in your store. The extension allows you to add manuals, licenses, warranties and other downloadble information right on product pages. Equip your attachments of any format with catchy icons to attract customers' attention.

  • Add files using handy drag-and-drop mechanism
  • Upload the unlimited number of attachments
  • Support for any file types
  • Track attachments downloads
  • Equip files with attractive icons

General Settings

To configure general extension settings please go to Stores → Configuration → Amasty Extensions → Product Attachments.

See your store performance in details with the Magento 2 reports.

Display Attachments Block On Product Page — enable the attachments block display on the frontend and backend product pages;

Customer Group to Show Attachments Block — specify customer groups for which the attachments will be visible;

Display Attachments Block if a Product Has Been Ordered — enable this option if you want to show attachments block only after the product is ordered;

The option doesn’t hide all attachments for all products by default. To enable the option for specific products you need to switch the corresponding option on a particular product page as well.

Block Title On Product Page — specify the name of the attachment block for product pages;

Parent Block Name In Layout — specify where to display product attachments (either in a new tab or in any existing layout block);

Sibling Name — define the block position on a page;

Position — choose to place attachments in a new tab in the product info bar – specify its position in the bar;

Directory for Upload by FTP — specify the directory to upload attachments via FTP;

Autodetect File Mime Type on Download — set the option to Yes to let customers open attachments in a new browser window instead of downloading them.

Adding Files to a Product Page

To add new files for a specific product please go to Products → Catalog and open the necessary product.

Expand the Product Attachments tab.

You can specify custom name for this tab by modifying the Block Title On Product Page option on the General Settings page.

Click the Add New File link to add a new attachment. Then, please specify the following attachment details:

Label — fill in the label that will be displayed on the frontend as the name of the attachment;

File Name — specify a separate file name for your internal use;

Attach File or Enter Link — attach a file either by adding it from your computer or by specifying the link;

Customer Group — specify a customer group for which the attachment will be visible on the frontend;

Show Only if a Product has been Ordered — enable this option if you want to display product attachments only when the product is ordered;

Visible — modify this option to hide or display the attachment.

If you show two or more attachments on a product page, you can specify the order for displaying files. Just drag the attachments to place them according to your needs.

Adding Files from the Grid

With the extension, you can add product attachments right on the grid. A new Upload Attachment column should appear on the product grid. Just drag-and-drop the file on the special area to upload it.

Mass Actions with Attachments

To copy attachments from one product to other items please do the following:

  • Tick necessary items to which the files should be copied;
  • Choose Copy Attachments from the actions dropdown;
  • Specify ID of the product from which the attachments should be copied;
  • Click Apply.

Attachments List

To see all attachments please go to Products → List Attachments.

Adding an Icon

To create a new attachment icon or edit already existing ones go to Products → Icon Management.

Click the Add New Icon button or choose one of the existing icons:

Image — choose an icon from your computer;

Type — specify the file format for which the icon will be used;

Status — enable or disable a certain icon.

Hit the Save Icon button.

Adding Files to the Category Products

To attach files to all products within a category, please, go to Products → Categories and select a category to which products you want to download files.

Then, expand the Product Attachments section and hit the Add New File button. Next, please, specify the details. When done, click the Save button to upload the file or use the Add New File button again if you want to upload multiple files in one go.

Download Reports

To see reports on file downloads please go to Reports → Product Attachments → Downloads.

Here you can see statistics on what attachments were downloaded, when this happened and who downloaded the file.

Bulk Attachments Upload

To upload multiple files in bulk please go to Products → Product Attachment → Mass File Import.

  • Upload product attachments via FTP in the Upload Files tab;

  • Create a CSV file to make uploaded documents match the right products (use this file as an example: example.zip);

  • Upload a CSV file in the Import CSV tab.

When creating a CSV file you can use the following attributes:

  • file name
  • product SKU
  • file title
  • sort order
  • customer group IDs
  • show only if a product has been ordered
  • visible
  • URL
Only the File Name and Product SKU attributes are required. Other attribute are optional.

You can see all uploaded files in the Uploaded Files tab. You can use the Actions dropdown menu to delete multiple files.

Placing Attachments

You can place attachments in any location. Please add this PHP code to any template of the product page:

<?php
echo $block->getLayout()->createBlock( 'Amasty\ProductAttachment\Block\Catalog\Product\Attachment', '',
['data'=>['custom mode'=> true, 'skip_head'=>true]]
)->toHtml(); ?>

Working with API

With the Product Attachments for Magento 2 extension, you can manage downloadble files using API. There are 5 operations you can to perform. These are:

  • Get attachments list;
  • Get attachment by ID;
  • Create an attachment;
  • Update attachment;
  • Delete attachment.

Let's dig into details.

Get attachments list

Operation: /V1/productAttachment/search

Method: GET

Format response:

{
    "items": [],
    "search_criteria": {
        "filter_groups": [],
    },
    "total_count": 3
}

Get attachment by ID

Operation: /V1/productAttachment/{AttachmentID}

Method: GET

{
    "id": 1,
    "product_id": 1,
    "file_name": "rtyjrth",
    "file_url": "",
    "file_size": 20,
    "file_type": "file",
    "customer_groups": [
        {
            "store_id": 0,
            "customer_group_id": 0
        }
    ],
    "store_configs": [
        {
            "store_id": 0,
            "label": "rtgrt",
            "is_visible": 1,
            "position": 1,
            "show_for_ordered": 0,
            "customer_group_is_default": 1
        }
    ],
    "content": {
        "base64_encoded_data": "NTU1MjNnNGg1aGo1Nmo1Nmo1Nmo=",
        "type": "text/plain",
        "name": "mysql_slow6.log"
    }
}

Create an attachment

Operation: /V1/productAttachment

Method: POST

Format request:

{
    "productAttachment": {
        "product_id": 1,
        "file_name": "123123213213",
        "file_url": "",
        "file_type": "file",
        "customer_groups": [
            {
                "store_id": 0,
                "customer_group_id": 0
            }
        ],
        "store_configs": [
            {
                "store_id": 0,
                "label": "rtgrt",
                "is_visible": 1,
                "position": 1,
                "show_for_ordered": 0,
                "customer_group_is_default": 1
            }
        ],
        "content": {
            "base64_encoded_data": "NTU1MjNnNGg1aGo1Nmo1Nmo1Nmo=",
            "type": "text/plain",
            "name": "mysql_slow6.log"
        }
    }
}

Update attachment

Operation: /V1/productAttachment/{AttachmentID}

Method: PUT

Request format will be the same as for create attachment operation.

Delete attachment

Operation: /V1/productAttachment/{AttachmentID}

Method: DELETE

Request format will be the same as for create attachment operation.

Find out how to install the Product Attachments extension via Composer.

Rate the user guide
 stars  from 1 votes (Details)
magento_2/product_attachments.txt · Last modified: 2018/09/21 09:44 by milosh