Jump to content

Search index , keywords from meta description


siomosp

Recommended Posts

override getProductsToIndex function  from classes/Search.php and reindex at back-end
Dashboard->Configure->Search:  Re-build the entire index

   protected static function getProductsToIndex($total_languages, $id_product = false, $limit = 50, $weight_array = array())
    {
        $ids = null;
        if (!$id_product) {
            // Limit products for each step but be sure that each attribute is taken into account
            $sql = 'SELECT p.id_product FROM ' . _DB_PREFIX_ . 'product p
				' . Shop::addSqlAssociation('product', 'p', true, null, true) . '
				WHERE product_shop.`indexed` = 0
				AND product_shop.`visibility` IN ("both", "search")
				AND product_shop.`active` = 1
				ORDER BY product_shop.`id_product` ASC
				LIMIT ' . (int) $limit;

            $res = Db::getInstance()->executeS($sql, false);
            while ($row = Db::getInstance()->nextRow($res)) {
                $ids[] = $row['id_product'];
            }
        }

        // Now get every attribute in every language
        $sql = 'SELECT p.id_product, pl.id_lang, pl.id_shop, l.iso_code';

        if (is_array($weight_array)) {
            foreach ($weight_array as $key => $weight) {
                if ((int) $weight) {
                    switch ($key) {
                        case 'pname':
                            $sql .= ', pl.name pname';

                            break;
                        case 'reference':
                            $sql .= ', p.reference';

                            break;
                        case 'supplier_reference':
                            $sql .= ', p.supplier_reference';

                            break;
                        case 'ean13':
                            $sql .= ', p.ean13';

                            break;
                        case 'upc':
                            $sql .= ', p.upc';

                            break;
                        case 'description_short':
                            $sql .= ', pl.description_short';

                            break;
//HEREBY is the change
                        case 'description':
                            $sql .= ', pl.meta_description';
//HEREBY is the change
                            break;
                        case 'cname':
                            $sql .= ', cl.name cname';

                            break;
                        case 'mname':
                            $sql .= ', m.name mname';

                            break;
                    }
                }
            }
        }

        $sql .= ' FROM ' . _DB_PREFIX_ . 'product p
			LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl
				ON p.id_product = pl.id_product
			' . Shop::addSqlAssociation('product', 'p', true, null, true) . '
			LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl
				ON (cl.id_category = product_shop.id_category_default AND pl.id_lang = cl.id_lang AND cl.id_shop = product_shop.id_shop)
			LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m
				ON m.id_manufacturer = p.id_manufacturer
			LEFT JOIN ' . _DB_PREFIX_ . 'lang l
				ON l.id_lang = pl.id_lang
			WHERE product_shop.indexed = 0
			AND product_shop.visibility IN ("both", "search")
			' . ($id_product ? 'AND p.id_product = ' . (int) $id_product : '') . '
			' . ($ids ? 'AND p.id_product IN (' . implode(',', array_map('intval', $ids)) . ')' : '') . '
			AND product_shop.`active` = 1
			AND pl.`id_shop` = product_shop.`id_shop`';

        return Db::getInstance()->executeS($sql, true, false);
    }

 

Link to comment
Share on other sites

yes, you are right, change plz the marked line this way - it should be enough ( i tested it)

//HEREBY is the change
                        case 'description':
                            $sql .= ', pl.meta_description as description';
//HEREBY is the change
                            

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...