首页 > 解决方案 > 在 Prestashop Feeder 中将数据添加到文件

问题描述

我正在尝试添加此代码:

$date = date('r', strtotime($product['date_add'])); echo '<pubdate>'.$date.'</pubdate>';

到 Prestashop Feeder 模块https://github.com/PrestaShop/feeder 中的 rss.php 文件,以便在 Mailchimp rss 电子邮件中包含所有产品(现在它只显示一个,因为缺少日期参考)

但我不知道在哪里添加它。

class Ps_FeederrssModuleFrontController extends ModuleFrontController
{
private function getProducts($idCategory, $nProducts, $orderBy, $orderWay)
{
    $category = new Category($idCategory);

    ...
            );
        }
    }

    return $productsForTemplate;
}

private function getSmartyVariables()
{
    $id_category = (int)Tools::getValue('id_category');
    $id_category = $id_category ? $id_category : Configuration::get('PS_HOME_CATEGORY');

    $number = (int)Tools::getValue('n', 4);
    $number = $number > 4 ? 4 : $number;

    $orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
    $orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));

    $products = $this->getProducts($id_category, $number, $orderBy, $orderWay);

    return array(
        'products' => $products,
        'currency' => new Currency((int)$this->context->currency->id),
        'affiliate' => (Tools::getValue('ac') ? '?ac=' . (int)Tools::getValue('ac') : ''),
        'metas' => Meta::getMetaByPage('index', (int)$this->context->language->id),
        'shop_uri' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__,
        'shop_name' => Configuration::get('PS_SHOP_NAME'),
        'shop_email' => Configuration::get('PS_SHOP_EMAIL'),
        'language_iso' => $this->context->language->iso_code,
        'logo' => $this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO')),
    );
}

public function initContent()
{
    parent::initContent();

    $this->context->smarty->assign($this->getSmartyVariables());

    header("Content-Type:text/xml; charset=utf-8");
    $this->setTemplate('module:ps_feeder/views/template/front/rss.tpl');
}
}

标签: phprssprestashopmailchimp

解决方案


推荐阅读