I'm using Magento 1.9.x and trying to change default position number of products.
Ex, when we assign product to category via product page i need to set it to 999 position
I changed default position field value of catalog_category_product table
But nothing changed.
i changed magento\\app\\code\\core\\Mage\\Catalog\\Model\\Resource\\Category.php
/**
* Add products to category
*/
if (!empty($insert)) {
$data = array();
foreach ($insert as $productId => $position) {
$data[] = array(
'category_id' => (int)$id,
'product_id' => (int)$productId,
'position' => (int)$position ? (int)$position : 999
);
}
//(int)$position
$adapter->insertMultiple($this->_categoryProductTable, $data);
}
but it only effect when adding products to category via category page.
anyone know a solution for this please, Thank You
whenever you want to apply a change after saving a product you may observe the event "catalog_product_save_after". In the method body you can simply set your desired position via custom sql query.
PS. Always consider to use an event observer or local class rewrite instead of editing the core.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.