Magento:$ this-> getAddToCartUrl($ product)当我试图在主页上展示最畅销的产品时无法正常工作

I am new to Magento, so I am stucked in a different situation for me. I found a guide on how to display best selling products on homepage, implemented it and everything is working fine, except the $this->getAddToCartUrl($product). The product are not added to the cart after clicking on "Add to cart". Here is my code:

$totalPerPage = ($this->show_total) ? $this->show_total : 4;
$counter = 1;
$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );

$storeId = Mage::app()->getStore()->getId();
$productCollection = Mage::getResourceModel('reports/product_collection')
                              ->addAttributeToSelect('*')
                              ->addOrderedQty()
                              ->addAttributeToFilter('visibility', $visibility)
                              ->setOrder('ordered_qty', 'desc');

<div class="main_content">
    <div class="container">
        <div class="products_list">
            <div class="best_deals">
                <div class="recommended_products best_deals_products">
                    <ul>
            <?php foreach($productCollection as $product): ?>

            <?php
                    $categories = null;
                    foreach (explode(",", $product->category_ids) as $catId){

                      //Mage_Catalog_Model_Category
                      $cat = Mage::getModel('catalog/category')
                                    ->setStoreId(Mage::app()->getStore()->getId())
                                    ->load($catId);
                      $catName = $cat->getName();

                      $catLink = $cat->getUrlPath();
                      $categories .= '<a href="'.$catLink.'" title="'.$catName.'">'.$catName.'</a>&nbsp;&nbsp;';
                    }

            ?>

            <?php if($counter <= $totalPerPage): ?>

            <?php $productUrl =  $product->getProductUrl() ?> 
                        <li>
            <div class="img_bottle">
            <a href="<?php echo $productUrl ?>" title="View <?php echo $product->name ?>">
            <img src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize(107, 339); ?>" alt="Product image"  />
            </a>
            </div>
            <div class="product_desc">            
            <span><?php echo $product->name ?></span>            
            <span>Our price: $<?php echo number_format($product->getPrice(), 2); ?></span>
            <?php if($product['country_of_manufacture']): ?>
            <span>Country: <i><?php echo strtoupper($product->getAttributeText('country_of_manufacture')); ?></i></span>
            <?php endif; ?>
            <?php if($product['region']): ?>
            <span>Region: <i><?php echo strtoupper($product['region']); ?></i></span>
            <?php endif; ?>                            
                <?php if($product->isSaleable()): ?>
                    <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart buy_now_button" onclick="setLocation('<?php echo $this->getAddToCartUrl($product) ?>')">Add to Cart</button>
                <?php else: ?>
                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                <?php endif; ?>
            </div>
                            </li>
            <?php endif; $counter++; ?>

            <?php endforeach; ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

Thank you in advance, I hope that my problem will be solved here.

Change your button with following.

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart buy_now_button" onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($product)?>')">Add to Cart</button>

I found the solution. The problem was in the admin panel.

I had problem with something else not the code... When I went into the manage product and on a single product, I saw that the products that I want to add to cart had only 1 qty, so I had already added them to cart so I couldn't again.

I changed the qty number on more than 1. It works.

Sorry and thank you for your time, all the best