I am trying to programmatically update the position value for simple products within a grouped product. I am trying to use the product_link_api with Mag 1.9.01

$api = Mage::getModel('catalog/product_link_api');

The function definition start looks like this:

public function update($type, $productId, $linkedProductId, $data = array(), $identifierType = null)

Now this seems to be very odd function in that you can specify whether the $productId is the magento id or the SKU by using the $identifierType parameter. However the $linkedProductId seems to want a SKU:

    $idBySku = $product->getIdBySku($linkedProductId);
    if ($idBySku) {
        $linkedProductId = $idBySku;

Not sure how it know whether it is not but that is by-the-by. What I am having trouble with is that no matter what I pass in as the $type I get a message like:

Fatal error: Uncaught exception 'Mage_Api_Exception' with message 'type_not_exists' in ......\app\code\core\Mage\Api\Model\Resource\Abstract.php on line 103

I have looked into the catalog_product_link_type table and have:

1 relation
3 super
4 up_sell
5 cross_sell

Looking into the catalog_Product_link table I have seen that the "associated" products I want to modify are related using link type 3 "super". However, passing "super" summons the error, passing "3" causes the error. I have seen that one should pass "grouped" in so I tried that, even thought it made no sense to me given that it wasn't in the link type table. Failed too.

Any pointers on this? Thanks

  • Documentation and code clearly depict the allowed values. The grouped type should be fine. If that failed, it likely failed due to another subsequent error. – mam08ixo May 2 '16 at 12:19
  • Cheers mam08ixo. I was looking at the documention but as "grouped" failed I attempted to nose into the db structure. I confess I hadn't spotted the $_typeMap array though – Jon Holland May 3 '16 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.