original_string: public function add($product_id)
      {
          $result = null;
          $this->hook->attach('product.compare.add.before', $product_id, $result, $this);
  
          if (isset($result)) {
              return (bool) $result;
          }
  
          $product_ids = $this->getList();
  
          if (in_array($product_id, $product_ids)) {
              return false;
          }
  
          array_unshift($product_ids, $product_id);
          $this->controlLimit($product_ids);
  
          $result = $this->set($product_ids);
          $this->hook->attach('product.compare.add.after', $product_id, $result, $this);
          return (bool) $result;
      }
code: public function add($product_id)
      {
          $result = null;
          $this->hook->attach('product.compare.add.before', $product_id, $result, $this);
  
          if (isset($result)) {
              return (bool) $result;
          }
  
          $product_ids = $this->getList();
  
          if (in_array($product_id, $product_ids)) {
              return false;
          }
  
          array_unshift($product_ids, $product_id);
          $this->controlLimit($product_ids);
  
          $result = $this->set($product_ids);
          $this->hook->attach('product.compare.add.after', $product_id, $result, $this);
          return (bool) $result;
      }
code_tokens: public function add ( $ product_id ) { $ result = null ; $ this -> hook -> attach ( 'product.compare.add.before' , $ product_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } $ product_ids = $ this -> getList ( ) ; if ( in_array ( $ product_id , $ product_ids ) ) { return false ; } array_unshift ( $ product_ids , $ product_id ) ; $ this -> controlLimit ( $ product_ids ) ; $ result = $ this -> set ( $ product_ids ) ; $ this -> hook -> attach ( 'product.compare.add.after' , $ product_id , $ result , $ this ) ; return ( bool ) $ result ; }
docstring: Adds a product to comparison
  @param integer $product_id
  @return boolean
docstring_tokens: Adds a product to comparison