ส่วนนี้จะเป็น ฟิลที่ผมสร้างใหม่เราจะนำ name ไปใช้งานนะครับ
โค้ด: เลือกทั้งหมด
<fields name="params"><field name="defindproduct" type="number" default="" label="MOD_MZC_PRODUCTS_SLIDES_SHOW_DEFIND_PRODUCT" description="" size="5" /</fieldset>
</fields>
โค้ด: เลือกทั้งหมด
$limitproduct = $params->get('defindproduct');
โค้ด: เลือกทั้งหมด
$helper_newproduct = new ModShowProductNewItem();
$product_slisdershow = $params->get('selectids'); //ตัวแปรที่มีอยู่แล้ว
$limitproduct = $params->get('defindproduct'); // ตัวแปรที่เพิ่มมาใหม่
$setid = $helper_newproduct->newItem(implode(",",$product_slisdershow),$limitproduct); // <= ตัวแปร $limitproduct จะเห็นได้ว่า เติม , แล้วใส่ตัวแปรหลังจากนั้น ฟังก์ชันจะส่งคืนค่ากลับไปยัง $helper_newproduct ทั้ง 2 ค่านะครับ
โค้ด: เลือกทั้งหมด
public function newItem($setid,$limitproduct) // ตัวแปรเดิมคือ $setid ตัวแปรใหม่คือ $limitproduct
โค้ด: เลือกทั้งหมด
public function newItem($setid,$limitproduct) //ตัวแปรที่จะต้องใช้งาน
{
$lang_tag = \Joomla\CMS\Factory::getLanguage()->getTag();
$db = Joomla\CMS\Factory::getDbo();
$query = $db ->getQuery(true)
->select('a.category_id, b.product_id, b.image ,b.product_price,'.$db->qn('b.name_'.$lang_tag))
->from('products as b')
->where('a.product_id in ('.$setid.')') //ตัวแปรที่มีอยู่แล้ว
->leftJoin('products_to_categories AS a ON b.product_id = a.product_id')
->order('product_id DESC');
$db->setQuery($query,0,$limitproduct); //ตัวแปรที่ผมสร้างมาใหม่
$items = $db ->loadAssocList();
return $items;
}