Product::getLink PHP Method

    public function getLink()
    {
        return ProductHelper::getUrl($this);
    }

Usage Example

Example #1
0
function sendCartMails()
{
    global $link;
    $sql = "SELECT c.id_cart, cc.email, cc.`firstname`, cc.id_customer\n\tFROM `ps_cart` c\n\tINNER JOIN ps_customer cc ON cc.`id_customer` = c.`id_customer`\n\tINNER JOIN `ps_cart_product` cp ON cp.`id_cart` = c.id_cart\n\tLEFT JOIN ps_orders o ON o.`id_cart` = c.id_cart\n\tWHERE o.id_cart IS NULL\n\tAND datediff(curdate(), c.`date_upd`) = 3\n\tAND cc.newsletter = 0\n\tGROUP BY cc.`id_customer`";
    /*$sql = "SELECT c.id_cart, cc.email, cc.`firstname`, cc.id_customer
    	FROM `ps_cart` c
    	INNER JOIN ps_customer cc ON cc.`id_customer` = c.`id_customer`
    	INNER JOIN `ps_cart_product` cp ON cp.`id_cart` = c.id_cart
    	LEFT JOIN ps_orders o ON o.`id_cart` = c.id_cart
    	WHERE cc.id_customer = 1
    	GROUP BY cc.`id_customer`";*/
    $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
    $count = 0;
    foreach ($res as $row) {
        $count++;
        $id_cart = Cart::lastNoneOrderedCart($row['id_customer']);
        $cart = new Cart($id_cart);
        $id_product = $cart->getLastProduct();
        $id_product = $id_product['id_product'];
        $product = new Product($id_product, true, 1);
        $idImage = $product->getCoverWs();
        if ($idImage) {
            $idImage = $product->id . '-' . $idImage;
        } else {
            $idImage = Language::getIsoById(1) . '-default';
        }
        $templateVars = array();
        $templateVars['{firstname}'] = $row['firstname'];
        $templateVars['{product_url}'] = $product->getLink();
        $templateVars['{product_name}'] = $product->name;
        $templateVars['{image_link}'] = $link->getImageLink($product->link_rewrite, $idImage, 'list');
        $mailTo = $row['email'];
        echo "" . $count . " : " . $mailTo . "\n";
        $subject = $row['firstname'] . ", you left your shopping bag with us";
        @Mail::Send(1, 'abandoned', $subject, $templateVars, $mailTo, $row['firstname'], '*****@*****.**', 'Indusdiva.com', NULL, NULL, _PS_MAIL_DIR_, false);
        usleep(200000);
    }
}
All Usage Examples Of Product::getLink