我已经为Prestashop 1.7创建了一个模块,以便在“管理产品”页面中添加新字段。由于缺少适当的文档,我想询问添加我的自定义字段(选择)的正确方法。我要保存并更新产品保存。
我使用下面的代码添加包含表单的tpl
public function hookDisplayAdminProductsExtra($params) {
$this->smarty;
$available_items = $this->getAvailableBadges();
$id_product = Tools::getValue('id_product');
$this->context->smarty->assign('items_number', $available_items);
return $this->display(__FILE__, '/views/templates/admin/admin_products.tpl');
}
Run Code Online (Sandbox Code Playgroud)
问题是我不知道如何覆盖Product.php类以拥有$ field以及如何为tpl创建form元素。
我想要创建的表单是这样的
<select name="" id="">
{foreach from=$items_number item=option}
<option value="{$option}">
{$option}
</option>
{/foreach}
</select>
Run Code Online (Sandbox Code Playgroud)
很抱歉缺少信息,但是我发现创建模块的新方法非常令人困惑。提前致谢
我正在尝试使用 WP_Query 在 Wordpress 中通过其 ID 获取特定产品,并且我正在努力从昨天开始寻找正确的论点。我被卡住了。我来自“product_cat”分类法
$args = array(
'post_type' => 'product',
'posts_per_page' => 1,
'id' => $product_id,
);
Run Code Online (Sandbox Code Playgroud) 我正在浏览 Prestashop 1.7,我想覆盖负责产品列表(又名类别存档)的控制器。我正在使用官方的 Prestashop starter 主题,我想覆盖控制器以获取更多数据到 sort-order.tpl
<div class="products-sort-order">
<span>{if isset($listing.sort_selected)}{$listing.sort_selected}{else}{l s='Sort by:' d='Shop.Theme.Global'}{/if}</span>
{foreach from=$sort_orders item=sort_order}
<a
class="{['current' => $sort_order.current, 'js-search-link' => true]|classnames}"
href="{$sort_order.url}"
rel="nofollow"
>
{$sort_order.label}
</a>
{/foreach}
</div>
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中有一个 sort_order 变量,它是来自 products-top.tpl 的 $listing 变量的一部分
<div id="js-product-list-top" class="products-selection">
{if $listing.pagination.total_items|count > 1}
<p>{l s='There are %product_count% products.' d='Shop.Theme.Catalog' sprintf=['%product_count%' => $listing.pagination.total_items|count]}</p>
{elseif $listing.pagination.total_items > 0}
<p>{l s='There is 1 product.' d='Shop.Theme.Catalog'}</p>
{/if}
{block name='sort_by'}
{include file='catalog/_partials/sort-orders.tpl' sort_orders=$listing.sort_orders}
{/block}
{block name='pagination_summary'}
{l s='Showing %from%-%to% of %total% item(s)' d='Shop.Theme.Catalog' …Run Code Online (Sandbox Code Playgroud)