Post by JNeuhoff » Sun Feb 10, 2013 12:24 am

I also posted it on GitHub, not sure whether it was the right place or not, hence I post it here, too.

It would be nice if the model classes could be made more extension friendly.
Sometimes 3rd party addons introduce new DB fields in e.g. the 'category', 'product'
or other DB tables.

If the add methods, such as the function 'addCategory' in 'admin/model/catalog/category.php'
were to return the primary key value, e.g. 'category_id', then an extended model class
could simply add its own additional field values like this:

Code: Select all

// example of an overridden method in an extended model class
public function addCategory($data) {
  $category_id = parent::addCategory($data);
  $sql = "UPDATE ".DB_PREFIX."category SET newfield = '".$data['newfield']."' WHERE category_id = '".(int)$category_id."'";
  $this->db->query($sql);
  return $category_id;
}
Here is a list of the add functions involved:

admin/model/catalog/attribute.php addAttribute
admin/model/catalog/attribute.php addAttribute
admin/model/catalog/category.php addCategory
admin/model/catalog/download.php addDownload
admin/model/catalog/filter.php addFilter
admin/model/catalog/information.php addInformation
admin/model/catalog/manufacturer.php addManufacturer
admin/model/catalog/option.php addOption
admin/model/catalog/product.php addProduct
admin/model/catalog/review.php addReview
admin/model/design/banner.php addBanner
admin/model/design/custom_field.php addCustomField
admin/model/design/layout.php addLayout
admin/model/localisation/country.php addCountry
admin/model/localisation/currency.php addCurrency
admin/model/localisation/geo_zone.php addGeoZone
admin/model/localisation/language.php addlanguage
admin/model/localisation/length_class.php addLengthClass
admin/model/localisation/order_status.php addOrderStatus
admin/model/localisation/return_action.php addReturnAction
admin/model/localisation/return_reason.php addReturnReason
admin/model/localisation/return_status.php addReturnStatus
admin/model/localisation/stock_status.php addStockStatus
admin/model/localisation/tax_class.php addTaxClass
admin/model/localisation/tax-rate.php addTaxRate
admin/model/localisation/weight_class.php addWeightClass
admin/model/localisation/zone.php addZone
admin/model/sale/affiliate.php addAffiliate
admin/model/sale/affiliate.php addTransaction
admin/model/sale/coupon.php addCoupon
admin/model/sale/customer.php addCustomer
admin/model/sale/customer.php addHistory
admin/model/sale/customer.php addTransaction
admin/model/sale/customer.php addReward
admin/model/sale/customer.php addBanIp
admin/model/sale/customer_ban_ip.php addCustomerBanIp
admin/model/sale/customer_group addCustomerGroup
admin/model/sale/order.php addOrder
admin/model/sale/return.php addReturn
admin/model/sale/voucher.php addVoucher
admin/model/sale/voucher_theme.php addVoucherTheme
admin/model/user/user.php addUser
admin/model/user/user_group addUserGroup
catalog/model/account/address.php addAddress
catalog/model/account/customer.php addCustomer
catalog/model/account/return.php addReturn
catalog/model/catalog/review.php addReview
catalog/model/checkout/order.php addOrder
catalog/model/checkout/voucher.php addVoucher
catalog/model/localisation/return_reason.php addReturnReason

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 2 guests