setPrimaryKey((int) $id)->getData('sku'); return new Qs_Validate_Unique($this->_getTable(), 'sku', null, array( 'where' => $this->_db->quote($sku) . ' <> ' . $this->_db->quote($inDbSku), )); } protected function _getFromColumns() { $columns = parent::_getFromColumns(); $columns['imageCount'] = new Zend_Db_Expr('(' . $this->_getFromImageCountSelect() . ')'); return $columns; } protected function _getFromImageCountSelect() { $select = $this->_db->select(); $select->from($this->_getPair($this->_tableAlias . 'Image'), 'COUNT(*)'); $select->where('`productId` = `' . $this->_tableAlias . '`.`id`'); return $select; } protected function _deleteDependency() { $this->_deleteImages(); return $this; } public function getListSelect() { if (null === $this->_select) { parent::getListSelect(); $where = 'Product.categoryId = ProductCategory.id'; $this->_select->join( $this->_getPair('ProductCategory', 'ProductCategory'), $where, array('categoryTitle' => 'title') ); } return $this->_select; } protected function _deleteImages() { $imagesObj = new App_ECommerce_Product_Image_Admin_Obj(); $imagesObj->setProductId($this->_primaryKey); $imagesStatement = $imagesObj->getListStatement(); foreach ($imagesStatement as $image) { $imagesObj->setPrimaryKey($image['id']); $imagesObj->delete(); } return $this; } }