PHP code example of magepal / link-product

1. Go to this page and download the library: Download magepal/link-product library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

magepal / link-product example snippets

`
    public function __construct(
        ...
        \MagePal\LinkProduct\Model\Accessory $accessory,
        ....
    ) {
        ...
        $this->accessory = $accessory;
    }
    
    $product = $currentProduct;
    return products
    $accessoryItems = $this->accessory->getAccessoryProducts($product);
    //return product ids
    $accessoryItemIds = $this->accessory->getAccessoryProductIds($product);