คำถามติดแท็ก collection-filtering

4
ฉันจะแก้ไข“ รายการ (Mage_Catalog_Model_Product) ด้วยรหัสเดียวกัน” xxx“ มีอยู่แล้ว” ได้อย่างไร
ฉันได้รับข้อผิดพลาดนี้เมื่อพยายามกรองชุดผลิตภัณฑ์ Item (Mage_Catalog_Model_Product) with the same id "6058" already exist และต้องการถามสิ่งที่อาจทำให้เกิดข้อผิดพลาดเนื่องจากมีผลิตภัณฑ์ (มองเห็นได้) เพียงผลิตภัณฑ์เดียวที่มี ID เดียวกันภายใน Magento มีตารางที่ต้องล้างค่าเพื่อลบรายการที่ซ้ำกันนี้หรือไม่?

3
กรองผลลัพธ์โดยใช้ LIKE
พิจารณาสตริง "Haystack" ทั้งสามนี้: ก) foo bar ข) welcome to foo bar industries ค) foo barer และตอนนี้ "เข็ม" ของฉัน: foo bar (หึ) ฉันต้องการให้ตัวกรองของฉันจับคู่เข็มของฉันกับสตริงที่กองหญ้าเป็น & a แต่ไม่ใช่ c ฉันเหนื่อย: $collection->addAttributeToFilter('name', array('like' => '%'.$needle.'%')); แต่ข้างต้นตรงกับ c ฉันก็ลอง: $collection->addAttributeToFilter('name', array('like' => '% '.$needle.' %')); // Note the spaces ด้านบนตรงกับ b. ความช่วยเหลือใด ๆ ที่ชื่นชมมาก

2
การแบ่งเลขกริดไม่ทำงานเมื่อใช้ส่วนคำสั่งกลุ่มในการรวบรวม
ฉันกำลังทำงานกับตารางผลิตภัณฑ์ แต่การแบ่งหน้าหรือจำนวนผลิตภัณฑ์ไม่ทำงาน (เนื่องจากแสดงจำนวนผิด) เนื่องจากฟังก์ชั่นบล็อกของฉัน _preparecollection มีดังต่อไปนี้ฉันได้เพิ่มรหัสตัวกรองหมวดหมู่ในคอลเลกชันดังนั้นฉันต้องใช้ส่วนคำสั่งกลุ่มเพื่อป้องกันข้อผิดพลาดสำหรับรหัสเดียวกันที่มีอยู่แล้ว protected function _prepareCollection() { $store = $this->_getStore(); $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('sku') ->addAttributeToSelect('name') ->addAttributeToSelect('attribute_set_id') ->addAttributeToSelect('type_id') ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left'); $collection->addAttributeToFilter('category_id', array('in' => array(4,10))) ->distinct(true); $collection->getSelect()->group('e.entity_id'); if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) { $collection->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'); } $collection->joinField('position', 'catalog/category_product', 'position', 'product_id=entity_id', null, 'left'); $collection->joinField('websites', 'catalog/product_website', …
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.