Prestashop:存储搜索结果返回缺失结果

问题描述 投票:0回答:2

在商店页面,我们可以通过给出城市或地址来搜索商店,当我检查结果时,他们缺少一些商店。 我尝试检查stores.js文件,发现stores是由Stores控制器中的ajax返回的,其中displayAjax函数正在调用getStores函数。

displaAjax 函数

protected function displayAjax()
{
    $stores = $this->getStores();
    $parnode = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><markers></markers>');

    foreach ($stores as $store) {
        $other = '';
        $newnode = $parnode->addChild('marker');
        $newnode->addAttribute('name', $store['name']);
        $address = $this->processStoreAddress($store);

        $other .= $this->renderStoreWorkingHours($store);
        $newnode->addAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));
        $newnode->addAttribute('address', $address);
        $newnode->addAttribute('other', $other);
        $newnode->addAttribute('phone', $store['phone']);
        $newnode->addAttribute('id_store', (int)$store['id_store']);
        $newnode->addAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)$store['id_store'].'.jpg'));
        $newnode->addAttribute('lat', (float)$store['latitude']);
        $newnode->addAttribute('lng', (float)$store['longitude']);
        if (isset($store['distance'])) {
            $newnode->addAttribute('distance', (int)$store['distance']);
        }
    }

    header('Content-type: text/xml');
    die($parnode->asXML());
}

还有 getStores 函数

 public function getStores()
{
    $distance_unit = Configuration::get('PS_DISTANCE_UNIT');
    if (!in_array($distance_unit, array('km', 'mi'))) {
        $distance_unit = 'km';
    }

    if (Tools::getValue('all') == 1) {
        $stores = Db::getInstance()->executeS('
        SELECT s.*, cl.name country, st.iso_code state
        FROM '._DB_PREFIX_.'store s
        '.Shop::addSqlAssociation('store', 's').'
        LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
        LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
        WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id);
    } else {
        $distance = 1000;//(int)Tools::getValue('radius', 100);
        $multiplicator = ($distance_unit == 'km' ? 6371 : 3959);

        $stores = Db::getInstance()->executeS('
        SELECT s.*, cl.name country, st.iso_code state,
        ('.(int)$multiplicator.'
            * acos(
                cos(radians('.(float)Tools::getValue('latitude').'))
                * cos(radians(latitude))
                * cos(radians(longitude) - radians('.(float)Tools::getValue('longitude').'))
                + sin(radians('.(float)Tools::getValue('latitude').'))
                * sin(radians(latitude))
            )
        ) distance,
        cl.id_country id_country
        FROM '._DB_PREFIX_.'store s
        '.Shop::addSqlAssociation('store', 's').'
        LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
        LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
        WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id.'
        HAVING distance < '.(int)$distance.'
        ORDER BY distance ASC
        LIMIT 0,20');
    }

    return $stores;
}

我尝试将半径增加到 1000 公里,但总是得到相同的结果。

php google-maps prestashop prestashop-1.6
2个回答
0
投票
$distance = 1000;//(int)Tools::getValue('radius', 100);

半径值(根据上面的代码行)是通过名为“radius”的 URL 参数获取的。您是否尝试过增加其价值?


0
投票

我取消了结果限制

 LIMIT 0,20

我得到了所有结果

© www.soinside.com 2019 - 2024. All rights reserved.