/**
  * Get current product ids
  *
  * @param Mage_Catalog_Model_Resource_Product_Link_Product_Collection $collection
  * @param string                                                      $idFieldName
  *
  * @return array
  */
 protected function _getProductIds($collection, $idFieldName)
 {
     if ($collection->getProduct() && $collection->getProduct()->getId()) {
         return array($collection->getProduct()->getData($idFieldName));
     }
     $ids = array();
     $product = Mage::registry('product');
     if ($product instanceof Mage_Catalog_Model_Product) {
         $ids[] = $product->getData($idFieldName);
     }
     if ($collection->getLinkModel()->getLinkTypeId() == Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL) {
         $quote = Mage::getSingleton('checkout/session')->getQuote();
         foreach ($quote->getAllItems() as $item) {
             if ($product = $item->getProduct()) {
                 $ids[] = $product->getData($idFieldName);
             }
         }
     }
     return $ids;
 }