/* شبکه محصولات 4 ستونه شفاف */ .products, .product-list, .products-grid { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 18px; } /* موبایل و تبلت */ @media (max-width: 992px) { .products, .product-list, .products-grid { grid-template-columns: repeat(2, 1fr); } } /* کارت محصول */ .product, .product-card { background: #ffffff; border: 1px solid #eeeeee; border-radius: 12px; padding: 12px; } /* عکس محصول */ .product img, .product-card img { width: 100%; border-radius: 10px; } /* قیمت */ .price { font-size: 18px; font-weight: bold; color: #1b5e20; } /* دکمه خرید */ .add-to-cart, button[type="submit"] { background-color: #2e7d32; color: #ffffff; border-radius: 8px; padding: 10px; }xml_add($dom_g, $item, "g:link", $p['link']); xml_add($dom_g, $item, "g:image_link", $p['image']); xml_add($dom_g, $item, "g:brand", $p['brand']); xml_add($dom_g, $item, "g:price", $p['price'] . " IRR"); xml_add($dom_g, $item, "g:availability", "in stock"); $channel->appendChild($item); } $rss->appendChild($channel); $dom_g->appendChild($rss); $dom_g->save($google_feed_file); log_msg("INFO", "Google feed generated."); // ===================================================== // آپلود خودکار فید به ترب // ===================================================== $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $torob_api, CURLOPT_POST => true, CURLOPT_POSTFIELDS => [ 'feed_file' => new CURLFile($torob_feed_file) ], CURLOPT_RETURNTRANSFER => true ]); $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if ($error) { log_msg("ERROR", "Torob upload failed: $error"); exit("Torob upload failed."); } log_msg("INFO", "Torob upload OK. Response: $response"); // ===================================================== // پینگ خودکار گوگل جهت بروزرسانی // ===================================================== $ping_url = "https://www.google.com/ping?sitemap=" . urlencode("https://lavasemkhangi.ir/google-feed.xml"); @file_get_contents($ping_url); log_msg("INFO", "Google ping sent."); echo "Feed built, uploaded to Torob, and Google notified."; ?>// npm install puppeteer node-fetch const puppeteer = require('puppeteer'); const fetch = require('node-fetch'); // ⚙️ تنظیمات const SITE_URL = 'https://yoursite.com/admin/products'; // صفحه محصولات میکسین const USERNAME = 'username_اینجا'; const PASSWORD = 'password_اینجا'; const API_KEY = "API_KEY_خودت_اینجا"; const SHOP_ID = "SHOP_ID_خودت_اینجا"; const API_URL = "https://api.trebsale.com/v1/products"; // تابع ارسال محصول به ترب async function sendProduct(product) { try { const response = await fetch(API_URL, { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(product) }); const data = await response.json(); if (response.ok) { console.log(`✅ محصول '${product.title}' ارسال شد`, data); return true; } else { console.error(`❌ خطا در ارسال '${product.title}':`, data); return false; } } catch (err) { console.error(`❌ خطای شبکه برای '${product.title}':`, err); return false; } } // تابع اصلی Puppeteer async function run() { const browser = await puppeteer.launch({ headless: true }); const page = await browser.newPage(); // ورود به پنل میکسین await page.goto(SITE_URL, { waitUntil: 'networkidle2' }); await page.type('#username', USERNAME); // جایگزین با selector واقعی await page.type('#password', PASSWORD); await page.click('#login-button'); // جایگزین با selector واقعی await page.waitForNavigation({ waitUntil: 'networkidle2' }); // گرفتن محصولات جدید از جدول const products = await page.evaluate(() => { // ⚠️ باید selector واقعی جدول محصولات سایت شما جایگزین شود const rows = Array.from(document.querySelectorAll('table#products tbody tr')); return rows.map(row => ({ title: row.querySelector('.product-title').innerText.trim(), price: parseInt(row.querySelector('.product-price').innerText.replace(/\D/g,'')), sku: row.querySelector('.product-sku').innerText.trim(), stock: parseInt(row.querySelector('.product-stock').innerText), description: row.querySelector('.product-description').innerText.trim() })); }); console.log(`محصولات پیدا شده: ${products.length}`); // ارسال هر محصول به ترب for (const product of products) { await sendProduct(product); } await browser.close(); console.log("✅ ارسال خودکار تمام شد!"); } // اجرا هر 5 دقیقه run(); setInterval(run, 5 * 60 * 1000);(function() { let products = []; let cards = document.querySelectorAll(".css-1j1h0gu"); // کلاس کارت محصول ترب، ممکنه تغییر کنه cards.forEach(card => { let title = card.querySelector(".css-1bn5q0h")?.innerText || "بدون عنوان"; let price = card.querySelector(".css-1m5kx4v")?.innerText || "بدون قیمت"; let link = card.querySelector("a")?.href || "بدون لینک"; products.push({title, price, link}); }); // نمایش در کنسول console.log(products); // تبدیل به CSV برای کپی و ذخیره let csv = "Title,Price,Link\n" + products.map(p => `"${p.title}","${p.price}","${p.link}"`).join("\n"); console.log("کپی CSV:\n", csv); })(); "https://schema.org/", "@type"=>"Product", "name"=>$product['title'], "image"=>$product['image'], "description"=>substr(strip_tags($description),0,500), "sku"=>$product['sku'] ?? '', "brand"=>["@type"=>"Brand","name"=>$product['brand']], "offers"=>[ "@type"=>"Offer", "url"=>$product['url'], "priceCurrency"=>"IRR", "price"=>$product['price'], "availability"=>"https://schema.org/InStock" ] ]; echo ''; // 3️⃣ آپدیت خودکار فید ترب $feedXml = simplexml_load_file(FEED_FILE) ?: new SimpleXMLElement(''); $productXml = $feedXml->addChild('product'); $productXml->addChild('name',$product['title']); $productXml->addChild('url',$product['url']); $productXml->addChild('price',$product['price']); $productXml->addChild('image',$product['image']); $productXml->addChild('brand',$product['brand']); $productXml->addChild('availability','instock'); $productXml->addChild('description',strip_tags($description)); $feedXml->asXML(FEED_FILE); // 4️⃣ ارسال خودکار ایندکس گوگل $client = new Google_Client(); $client->setAuthConfig(GOOGLE_CREDENTIALS); $client->addScope('https://www.googleapis.com/auth/indexing'); $indexingService = new Google_Service_Indexing($client); $urlNotification = new Google_Service_Indexing_UrlNotification(); $urlNotification->setUrl($product['url']); $urlNotification->setType("URL_UPDATED"); try { $indexingService->urlNotifications->publish($urlNotification); } catch(Exception $e){ error_log("Indexing API error: ".$e->getMessage()); } } // تابع گرفتن 100 محصول پرفروش میکسین (خودکار) function get_top_100_products(){ // اینجا با دیتابیس میکسین ارتباط داره // و 100 محصول پرفروش رو برمیگردونه return query_top_100_products_from_db(); // فرضی } // اجرای خودکار روی همه محصولات $products = get_top_100_products(); foreach($products as $product){ autoSeoIndexTorob($product); } ?> input('title'); // Prompt برای GPT $prompt = " عنوان محصول: $title یک توضیح کامل و SEO شده بنویس، شامل: - توضیح کوتاه - توضیح بلند - کلمات کلیدی SEO - Meta Description فرمت JSON بده: {\"short_description\":\"...\",\"description\":\"...\",\"seo_keywords\":\"...\",\"meta_description\":\"...\"} "; // درخواست به GPT $response = Http::withHeaders([ 'Authorization' => 'Bearer YOUR_OPENAI_KEY' ])->post('https://api.openai.com/v1/chat/completions', [ 'model' => 'gpt-4.1-mini', 'messages' => [ ['role' => 'user', 'content' => $prompt] ], 'temperature' => 0.7 ]); $content = $response->json(); $json_data = json_decode($content['choices'][0]['message']['content'], true); // ذخیره در دیتابیس میکسین $product = new Product(); $product->title = $title; $product->short_description = $json_data['short_description'] ?? ''; $product->description = $json_data['description'] ?? ''; $product->seo_keywords = $json_data['seo_keywords'] ?? ''; $product->meta_description = $json_data['meta_description'] ?? ''; $product->save(); // ساخت Excel خروجی برای ترب $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', 'Title'); $sheet->setCellValue('B1', 'Short Description'); $sheet->setCellValue('C1', 'Description'); $sheet->setCellValue('D1', 'SEO Keywords'); $sheet->setCellValue('E1', 'Meta Description'); $sheet->setCellValue('A2', $product->title); $sheet->setCellValue('B2', $product->short_description); $sheet->setCellValue('C2', $product->description); $sheet->setCellValue('D2', $product->seo_keywords); $sheet->setCellValue('E2', $product->meta_description); $writer = new Xlsx($spreadsheet); $excel_file = storage_path('app/public/products.xlsx'); $writer->save($excel_file); return response()->json([ 'status' => 'success', 'product' => $product, 'excel' => url('storage/products.xlsx') ]); } } info("شروع پردازش محصولات جدید..."); $products = Product::whereNull('description')->get(); if ($products->isEmpty()) { $this->info("محصول جدیدی برای پردازش وجود ندارد."); return; } foreach ($products as $product) { $title = $product->title; $prompt = " عنوان محصول: $title یک توضیح کامل و SEO شده بنویس، شامل: - توضیح کوتاه - توضیح بلند - کلمات کلیدی SEO - Meta Description فرمت خروجی JSON بده: {\"short_description\":\"...\",\"description\":\"...\",\"seo_keywords\":\"...\",\"meta_description\":\"...\"} "; try { $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . env('OPENAI_API_KEY') ])->post('https://api.openai.com/v1/chat/completions', [ 'model' => 'gpt-4.1-mini', 'messages' => [ ['role' => 'user', 'content' => $prompt] ], 'temperature' => 0.7 ]); $content = $response->json(); $json_data = json_decode($content['choices'][0]['message']['content'], true); $product->short_description = $json_data['short_description'] ?? ''; $product->description = $json_data['description'] ?? ''; $product->seo_keywords = $json_data['seo_keywords'] ?? ''; $product->meta_description = $json_data['meta_description'] ?? ''; $product->save(); $this->info("پردازش شد: $title"); } catch (\Exception $e) { $this->error("خطا برای محصول $title: " . $e->getMessage()); } } // خروجی Excel برای ترب $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', 'Title'); $sheet->setCellValue('B1', 'Short Description'); $sheet->setCellValue('C1', 'Description'); $sheet->setCellValue('D1', 'SEO Keywords'); $sheet->setCellValue('E1', 'Meta Description'); $row = 2; foreach (Product::all() as $product) { $sheet->setCellValue("A$row", $product->title); $sheet->setCellValue("B$row", $product->short_description); $sheet->setCellValue("C$row", $product->description); $sheet->setCellValue("D$row", $product->seo_keywords); $sheet->setCellValue("E$row", $product->meta_description); $row++; } $writer = new Xlsx($spreadsheet); $excel_file = storage_path('app/public/products.xlsx'); $writer->save($excel_file); $this->info("Excel خروجی ساخته شد: " . $excel_file); $this->info("پردازش روزانه تمام شد ✅"); } } isDir()){ continue; } if(in_array($file->getExtension(), ['php','html','htm'])){ $pages[] = $file->getPathname(); } } // اضافه کردن متا robots به صفحات PHP foreach($pages as $page){ if(pathinfo($page, PATHINFO_EXTENSION) == 'php'){ $content = file_get_contents($page); if(strpos($content,'/i', "\n\n", $content, 1); file_put_contents($page, $content); } } } // ساخت sitemap.xml $sitemapContent = '' . "\n"; $sitemapContent .= '' . "\n"; foreach($pages as $page){ $relative = str_replace($siteDir, '', $page); $relative = str_replace('\\','/',$relative); $sitemapContent .= "\n$domain/$relative\ndaily\n0.8\n\n"; } $sitemapContent .= ''; file_put_contents($sitemapFile, $sitemapContent); echo "

تمام صفحات آماده ایندکس شدند ✅

"; echo "

فایل sitemap.xml ساخته شد. URL آن را در Google Search Console ارسال کنید.

"; ?> . info("شروع پردازش محصولات جدید..."); // گرفتن محصولات جدید که هنوز توضیح ندارند $products = Product::whereNull('description')->get(); if ($products->isEmpty()) { $this->info("محصول جدیدی برای پردازش وجود ندارد."); return; } foreach ($products as $product) { $title = $product->title; $prompt = " عنوان محصول: $title یک توضیح کامل و SEO شده بنویس، شامل: - توضیح کوتاه - توضیح بلند - کلمات کلیدی SEO - Meta Description فرمت خروجی JSON بده: {\"short_description\":\"...\",\"description\":\"...\",\"seo_keywords\":\"...\",\"meta_description\":\"...\"} "; try { $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . env('OPENAI_API_KEY') ])->post('https://api.openai.com/v1/chat/completions', [ 'model' => 'gpt-4.1-mini', 'messages' => [ ['role' => 'user', 'content' => $prompt] ], 'temperature' => 0.7 ]); $content = $response->json(); $json_data = json_decode($content['choices'][0]['message']['content'], true); $product->short_description = $json_data['short_description'] ?? ''; $product->description = $json_data['description'] ?? ''; $product->seo_keywords = $json_data['seo_keywords'] ?? ''; $product->meta_description = $json_data['meta_description'] ?? ''; $product->save(); $this->info("پردازش شد: $title"); } catch (\Exception $e) { $this->error("خطا برای محصول $title: " . $e->getMessage()); } } // ساخت Excel خروجی برای ترب $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', 'Title'); $sheet->setCellValue('B1', 'Short Description'); $sheet->setCellValue('C1', 'Description'); $sheet->setCellValue('D1', 'SEO Keywords'); $sheet->setCellValue('E1', 'Meta Description'); $row = 2; foreach (Product::all() as $product) { $sheet->setCellValue("A$row", $product->title); $sheet->setCellValue("B$row", $product->short_description); $sheet->setCellValue("C$row", $product->description); $sheet->setCellValue("D$row", $product->seo_keywords); $sheet->setCellValue("E$row", $product->meta_description); $row++; } $writer = new Xlsx($spreadsheet); $excel_file = storage_path('app/public/products.xlsx'); $writer->save($excel_file); $this->info("Excel خروجی ساخته شد: " . $excel_file); $this->info("پردازش روزانه تمام شد ✅"); } } . (function() { let products = []; let cards = document.querySelectorAll(".css-1j1h0gu"); // کلاس کارت محصول ترب، ممکنه تغییر کنه cards.forEach(card => { let title = card.querySelector(".css-1bn5q0h")?.innerText || "بدون عنوان"; let price = card.querySelector(".css-1m5kx4v")?.innerText || "بدون قیمت"; let link = card.querySelector("a")?.href || "بدون لینک"; products.push({title, price, link}); }); // نمایش در کنسول console.log(products); // تبدیل به CSV برای کپی و ذخیره let csv = "Title,Price,Link\n" + products.map(p => `"${p.title}","${p.price}","${p.link}"`).join("\n"); console.log("کپی CSV:\n", csv); })();
جستجو در محصولات
کالایی در این صفحه موجود نیست
    پروفایلسبد خریددسته‌بندیخانه