Guest User

controller

a guest
May 26th, 2016
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. require_once 'Mage/Customer/controllers/AccountController.php';
  5. class Webkul_Marketplace_MarketplaceaccountController extends Mage_Customer_AccountController{
  6.  
  7.  
  8.  
  9. public function marketlogoutAction()
  10. {
  11.  
  12.  
  13.  
  14.  
  15. $this->_getSession()->logout()
  16. ->renewSession();
  17. //add your code here
  18. $this->_redirect('marketplace');
  19.  
  20. echo "something";
  21. exit();
  22.  
  23. }
  24.  
  25.  
  26. public function logoutAction()
  27. {
  28. $this->_getSession()->logout()
  29. ->renewSession();
  30.  
  31. $this->_redirect('*/*/logoutSuccess');
  32. }
  33.  
  34.  
  35.  
  36.  
  37. public function newAction(){
  38. $set=$this->getRequest()->getParam('set');
  39. $type=$this->getRequest()->getParam('type');
  40. if(isset($set) && isset($type)){
  41. $allowedsets=explode(',',Mage::getStoreConfig('marketplace/marketplace_options/attributesetid'));
  42. $allowedtypes=explode(',',Mage::getStoreConfig('marketplace/marketplace_options/allow_for_seller'));
  43. if(!in_array($type,$allowedtypes) || !in_array($set,$allowedsets)){
  44. Mage::getSingleton('core/session')->addError(Mage::helper('marketplace')->__('Product Type Invalide Or Not Allowed'));
  45. $this->_redirect('marketplace/marketplaceaccount/new/');
  46. }
  47. Mage::getSingleton('core/session')->setAttributeSet($set);
  48. switch($type){
  49. case "simple":
  50. $this->loadLayout(array('default','marketplace_account_simpleproduct'));
  51. $this->getLayout()->getBlock('head')->setTitle(Mage::helper('marketplace')->__('MarketPlace Product Type: Simple Product'));
  52. break;
  53. case "downloadable":
  54. $this->loadLayout(array('default','marketplace_account_downloadableproduct'));
  55. $this->getLayout()->getBlock('head')->setTitle(Mage::helper('marketplace')->__('MarketPlace Product Type: Downloabable Product'));
  56. break;
  57. case "virtual":
  58. $this->loadLayout(array('default','marketplace_account_virtualproduct'));
  59. $this->getLayout()->getBlock('head')->setTitle(Mage::helper('marketplace')->__('MarketPlace Product Type: Virtual Product'));
  60. break;
  61. case "configurable":
  62. $this->loadLayout(array('default','marketplace_account_configurableproduct'));
  63. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('MarketPlace Product Type: Configurable Product'));
  64. break;
  65. }
  66. Mage::dispatchEvent('mp_bundalproduct',array('layout'=>$this,'type'=>$type));
  67. Mage::dispatchEvent('mp_groupedproduct',array('layout'=>$this,'type'=>$type));
  68.  
  69. $this->_initLayoutMessages('catalog/session');
  70. $this->renderLayout();
  71. }else{
  72. $this->loadLayout(array('default','marketplace_marketplaceaccount_newproduct'));
  73. $this->renderLayout();
  74. }
  75. }
  76.  
  77. public function categorytreeAction(){
  78. $data = $this->getRequest()->getParams();
  79. $category_model = Mage::getModel("catalog/category");
  80. $category = $category_model->load($data["CID"]);
  81. $children = $category->getChildren();
  82. $all = explode(",",$children);$result_tree = "";$ml = $data["ML"]+20;$count = 1;$total = count($all);
  83. $plus = 0;
  84.  
  85. foreach($all as $each){
  86. $count++;
  87. $_category = $category_model->load($each);
  88. if(count($category_model->getResource()->getAllChildren($category_model->load($each)))-1 > 0){
  89. $result[$plus]['counting']=1;
  90. }else{
  91. $result[$plus]['counting']=0;
  92. }
  93. $result[$plus]['id']= $_category['entity_id'];
  94. $result[$plus]['name']= $_category->getName();
  95.  
  96. $categories = explode(",",$data["CATS"]);
  97. if($data["CATS"] && in_array($_category["entity_id"],$categories)){
  98. $result[$plus]['check']= 1;
  99. }else{
  100. $result[$plus]['check']= 0;
  101. }
  102. $plus++;
  103. }
  104. echo json_encode($result);
  105. }
  106.  
  107. /*save All product*/
  108. public function simpleproductAction(){
  109. if($this->getRequest()->isPost()){
  110. if (!$this->_validateFormKey()) {
  111. $this->_redirect('marketplace/marketplaceaccount/new/');
  112. }
  113.  
  114. list($data, $errors) = $this->validatePost();
  115. $wholedata=$this->getRequest()->getParams();
  116. if(empty($errors)){
  117. Mage::getModel('marketplace/product')->saveSimpleNewProduct($wholedata);
  118. $status=Mage::getStoreConfig('marketplace/marketplace_options/partner_approval');
  119. if($status==1){
  120. $vendorId = Mage::getSingleton('customer/session')->getCustomer()->getId();
  121. $customer = Mage::getModel('customer/customer')->load($vendorId);
  122. $cfname=$customer->getFirstname()." ".$customer->getLastname();
  123. $cmail=$customer->getEmail();
  124. $catagory_model = Mage::getModel('catalog/category');
  125. $categoriesy = $catagory_model->load($wholedata['category'][0]);
  126. $categoryname=$categoriesy->getName();
  127. $emailTemp = Mage::getModel('core/email_template')->loadDefault('approveproduct');
  128. $emailTempVariables = array();
  129. $adminname = 'Administrators';
  130. $admin_storemail = Mage::getStoreConfig('marketplace/marketplace_options/adminemail');
  131. $adminEmail=$admin_storemail? $admin_storemail:Mage::getStoreConfig('trans_email/ident_general/email');
  132. $emailTempVariables['myvar1'] = $wholedata['name'];
  133. $emailTempVariables['myvar2'] =$categoryname;
  134. $emailTempVariables['myvar3'] = $adminname;
  135. $emailTempVariables['myvar4'] = Mage::helper('marketplace')->__('I would like to inform you that recently i have added a new product in the store.');
  136. $processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
  137. $emailTemp->setSenderName($cfname);
  138. $emailTemp->setSenderEmail($cmail);
  139. $emailTemp->send($adminEmail,$adminname,$emailTempVariables);
  140. }
  141. }else{
  142. foreach ($errors as $message) {Mage::getSingleton('core/session')->addError($message);}
  143. $_SESSION['new_products_errors'] = $data;
  144. }
  145. if (empty($errors))
  146. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your product was successfully Saved'));
  147. $this->_redirect('marketplace/marketplaceaccount/new/');
  148. }
  149. else{
  150. $this->_redirect('marketplace/marketplaceaccount/new/');
  151. }
  152. }
  153. public function virtualproductAction() {
  154. if($this->getRequest()->isPost()){
  155. if(!$this->_validateFormKey()) {
  156. $this->_redirect('marketplace/marketplaceaccount/new/');
  157. }
  158. list($data, $errors) = $this->validatePost();
  159. $wholedata=$this->getRequest()->getParams();
  160. if(empty($errors)){
  161. Mage::getModel('marketplace/product')->saveVirtualNewProduct($wholedata);
  162. $status=Mage::getStoreConfig('marketplace/marketplace_options/partner_approval');
  163. if($status==1){
  164. $vendorId = Mage::getSingleton('customer/session')->getCustomer()->getId();
  165. $customer = Mage::getModel('customer/customer')->load($vendorId);
  166. $cfname=$customer->getFirstname()." ".$customer->getLastname();
  167. $cmail=$customer->getEmail();
  168. $catagory_model = Mage::getModel('catalog/category');
  169. $categoriesy = $catagory_model->load($wholedata['category'][0]);
  170. $categoryname=$categoriesy->getName();
  171. $emailTemp = Mage::getModel('core/email_template')->loadDefault('approveproduct');
  172. $emailTempVariables = array();
  173. $adminname = 'Administrators';
  174. $admin_storemail = Mage::getStoreConfig('marketplace/marketplace_options/adminemail');
  175. $adminEmail=$admin_storemail? $admin_storemail:Mage::getStoreConfig('trans_email/ident_general/email');
  176. $emailTempVariables['myvar1'] = $wholedata['name'];
  177. $emailTempVariables['myvar2'] =$categoryname;
  178. $emailTempVariables['myvar3'] = $adminname;
  179. $emailTempVariables['myvar4'] = Mage::helper('marketplace')->__('I would like to inform you that recently i have added a new product in the store.');
  180. $processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
  181. $emailTemp->setSenderName($cfname);
  182. $emailTemp->setSenderEmail($cmail);
  183. $emailTemp->send($adminEmail,$adminname,$emailTempVariables);
  184. }
  185. }else{
  186. foreach ($errors as $message) {$this->_getSession()->addError($message);}
  187. $_SESSION['new_products_errors'] = $data;
  188. }
  189. if (empty($errors))
  190. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your product was successfully Saved'));
  191. $this->_redirect('marketplace/marketplaceaccount/new/');
  192. }
  193. else{
  194. $this->_redirect('marketplace/marketplaceaccount/new/');
  195. }
  196. }
  197. public function downloadableproductAction() {
  198. if($this->getRequest()->isPost()){
  199. if (!$this->_validateFormKey()) {
  200. $this->_redirect('marketplace/marketplaceaccount/new/');
  201. }
  202. list($data, $errors) = $this->validatePost();
  203. $wholedata=$this->getRequest()->getParams();
  204. if(empty($errors)){
  205. Mage::getModel('marketplace/product')->saveDownloadableNewProduct($wholedata);
  206. $status=Mage::getStoreConfig('marketplace/marketplace_options/partner_approval');
  207. if($status==1){
  208. $vendorId = Mage::getSingleton('customer/session')->getCustomer()->getId();
  209. $customer = Mage::getModel('customer/customer')->load($vendorId);
  210. $cfname=$customer->getFirstname()." ".$customer->getLastname();
  211. $cmail=$customer->getEmail();
  212. $catagory_model = Mage::getModel('catalog/category');
  213. $categoriesy = $catagory_model->load($wholedata['category'][0]);
  214. $categoryname=$categoriesy->getName();
  215. $emailTemp = Mage::getModel('core/email_template')->loadDefault('approveproduct');
  216. $emailTempVariables = array();
  217. $adminname = 'Administrators';
  218. $admin_storemail = Mage::getStoreConfig('marketplace/marketplace_options/adminemail');
  219. $adminEmail=$admin_storemail? $admin_storemail:Mage::getStoreConfig('trans_email/ident_general/email');
  220. $emailTempVariables['myvar1'] = $wholedata['name'];
  221. $emailTempVariables['myvar2'] =$categoryname;
  222. $emailTempVariables['myvar3'] = $adminname;
  223. $emailTempVariables['myvar4'] = Mage::helper('marketplace')->__('I would like to inform you that recently i have added a new product in the store.');
  224. $processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
  225. $emailTemp->setSenderName($cfname);
  226. $emailTemp->setSenderEmail($cmail);
  227. $emailTemp->send($adminEmail,$adminname,$emailTempVariables);
  228. }
  229. }else{
  230. foreach ($errors as $message) {$this->_getSession()->addError($message);}
  231. $_SESSION['new_products_errors'] = $data;
  232. }
  233. if (empty($errors))
  234. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your product was successfully Saved'));
  235. return $this->_redirect('marketplace/marketplaceaccount/new/');
  236. }
  237. else{
  238. return $this->_redirect('marketplace/marketplaceaccount/new/');
  239. }
  240. }
  241. public function configurableproductAction() {
  242. $wholedata=$this->getRequest()->getParam('attribute');
  243. $magentoProductModel = Mage::getModel('catalog/product');
  244. $this->_redirect('marketplace/marketplaceaccount/addconfigurableproduct');
  245. }
  246. public function configurableproductattrAction(){
  247. $this->loadLayout( array('default','marketplace_account_configurableproductattr'));
  248. $this->_initLayoutMessages('customer/session');
  249. $this->_initLayoutMessages('catalog/session');
  250. $this->getLayout()->getBlock('head')->setTitle($this->__('Configurable Product Attribute'));
  251. $this->renderLayout();
  252. }
  253.  
  254. public function vieworderAction(){
  255. $available_seller_item = 0;
  256. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  257. $seller_orderslist=Mage::getModel('marketplace/saleslist')->getCollection()
  258. ->addFieldToFilter('mageproownerid',array('eq'=>$customerid))
  259. ->addFieldToFilter('mageorderid',array('eq'=>$this->getRequest()->getParam('id')));
  260. foreach($seller_orderslist as $seller_item){
  261. $available_seller_item = 1;
  262. }
  263. if($available_seller_item){
  264. $this->loadLayout( array('default','marketplace_marketplaceaccount_vieworder'));
  265. $this->_initLayoutMessages('customer/session');
  266. $this->_initLayoutMessages('catalog/session');
  267. $this->getLayout()->getBlock('head')->setTitle($this->__('View Order Details'));
  268. $this->renderLayout();
  269. }else{
  270. $this->_redirect('marketplace/marketplaceaccount/myorderhistory');
  271. }
  272. }
  273. public function printorderAction(){
  274. $available_seller_item = 0;
  275. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  276. $seller_orderslist=Mage::getModel('marketplace/saleslist')->getCollection()
  277. ->addFieldToFilter('mageproownerid',array('eq'=>$customerid))
  278. ->addFieldToFilter('mageorderid',array('eq'=>$this->getRequest()->getParam('id')));
  279. foreach($seller_orderslist as $seller_item){
  280. $available_seller_item = 1;
  281. }
  282. if($available_seller_item){
  283. $this->loadLayout( array('default','marketplace_marketplaceaccount_printorder'));
  284. $this->_initLayoutMessages('customer/session');
  285. $this->_initLayoutMessages('catalog/session');
  286. $this->getLayout()->getBlock('head')->setTitle($this->__('Print Order Details'));
  287. $this->renderLayout();
  288. }else{
  289. $this->_redirect('marketplace/marketplaceaccount/myorderhistory');
  290. }
  291. }
  292.  
  293. public function addconfigurableproductAction(){
  294. return $this->_redirect('marketplace/marketplaceaccount/new/');
  295. /*$this->loadLayout( array('default','marketplace_account_configurableproduct'));
  296. $this->_initLayoutMessages('customer/session');
  297. $this->_initLayoutMessages('catalog/session');
  298. $this->getLayout()->getBlock('head')->setTitle($this->__('Add Configurable Product'));
  299. $this->renderLayout();*/
  300. }
  301.  
  302. public function newattributeAction(){
  303. $this->loadLayout( array('default','marketplace_account_newattribute'));
  304. $this->_initLayoutMessages('customer/session');
  305. $this->_initLayoutMessages('catalog/session');
  306. $this->getLayout()->getBlock('head')->setTitle($this->__(' Manage Attribute'));
  307. $this->renderLayout();
  308. }
  309.  
  310. public function createattributeAction() {
  311. if($this->getRequest()->isPost()){
  312. if (!$this->_validateFormKey()) {
  313. return $this->_redirect('marketplace/marketplaceaccount/newattribute/');
  314. }
  315.  
  316. $wholedata=$this->getRequest()->getParams();
  317. $attributes = Mage::getModel('catalog/product')->getAttributes();
  318.  
  319. foreach($attributes as $a){
  320. $allattrcodes = $a->getEntityType()->getAttributeCodes();
  321. }
  322. if(in_array($wholedata['attribute_code'], $allattrcodes)){
  323. Mage::getSingleton('core/session')->addError(Mage::helper('marketplace')->__('Attribute Code already exists'));
  324. $this->_redirect('marketplace/marketplaceaccount/newattribute/');
  325. }else{
  326. list($data, $errors) = $this->validatePost();
  327. if(array_key_exists('attroptions', $wholedata)){
  328. foreach( $wholedata['attroptions'] as $c){
  329. $data1['.'.$c['admin'].'.'] = array($c['admin'],$c['store']);
  330. }
  331. }else{
  332. $data1=array();
  333. }
  334.  
  335. $_attribute_data = array(
  336. 'attribute_code' => $wholedata['attribute_code'],
  337. 'is_global' => '1',
  338. 'frontend_input' => $wholedata['frontend_input'],
  339. 'default_value_text' => '',
  340. 'default_value_yesno' => '0',
  341. 'default_value_date' => '',
  342. 'default_value_textarea' => '',
  343. 'is_unique' => '0',
  344. 'is_required' => '0',
  345. 'apply_to' => '0',
  346. 'is_configurable' => '1',
  347. 'is_searchable' => '0',
  348. 'is_visible_in_advanced_search' => '1',
  349. 'is_comparable' => '0',
  350. 'is_used_for_price_rules' => '0',
  351. 'is_wysiwyg_enabled' => '0',
  352. 'is_html_allowed_on_front' => '1',
  353. 'is_visible_on_front' => '0',
  354. 'used_in_product_listing' => '0',
  355. 'used_for_sort_by' => '0',
  356. 'frontend_label' => $wholedata['attribute_code']
  357. );
  358. $model = Mage::getModel('catalog/resource_eav_attribute');
  359. if (!isset($_attribute_data['is_configurable'])) {
  360. $_attribute_data['is_configurable'] = 0;
  361. }
  362. if (!isset($_attribute_data['is_filterable'])) {
  363. $_attribute_data['is_filterable'] = 0;
  364. }
  365. if (!isset($_attribute_data['is_filterable_in_search'])) {
  366. $_attribute_data['is_filterable_in_search'] = 0;
  367. }
  368. if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
  369. $_attribute_data['backend_type'] = $model->getBackendTypeByInput($_attribute_data['frontend_input']);
  370. }
  371. $defaultValueField = $model->getDefaultValueByInput($_attribute_data['frontend_input']);
  372. if ($defaultValueField) {
  373. $_attribute_data['default_value'] = $this->getRequest()->getParam($defaultValueField);
  374. }
  375. $model->addData($_attribute_data);
  376. $data['option']['value'] = $data1;
  377. if($wholedata['frontend_input'] == 'select' || $wholedata['frontend_input'] == 'multiselect')
  378. $model->addData($data);
  379. $model->setAttributeSetId($wholedata['attribute_set_id']);
  380. $model->setAttributeGroupId($wholedata['AttributeGroupId']);
  381. $entityTypeID = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
  382. $model->setEntityTypeId($entityTypeID);
  383. $model->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId());
  384. $model->setIsUserDefined(1);
  385. $model->save();
  386. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Attribute Created Successfully'));
  387. $this->_redirect('marketplace/marketplaceaccount/newattribute/');
  388. }
  389. }
  390. }
  391.  
  392. public function quickcreateAction() {
  393. if (!$this->_validateFormKey()) {
  394. return $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  395. }
  396. $wholedata=$this->getRequest()->getParams();
  397. $id = $wholedata['mainid'];
  398. Mage::getModel('marketplace/product')->quickcreate($wholedata);
  399. $this->_redirect('marketplace/marketplaceaccount/configurableassociate',array('id'=>$id));
  400. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Associate Product created Successfully'));
  401. }
  402. public function assignassociateAction() {
  403. $wholedata=$this->getRequest()->getParams();
  404. Mage::getModel('marketplace/product')->editassociate($wholedata);
  405. Mage::getModel('marketplace/product')->saveassociate($wholedata);
  406. $id = $wholedata['mainid'];
  407. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Product has been assigned successfully'));
  408. $this->_redirect('marketplace/marketplaceaccount/configurableassociate',array('id'=>$id));
  409. }
  410.  
  411. public function configproductAction() {
  412. if($this->getRequest()->isPost()){
  413. if (!$this->_validateFormKey()) {
  414. return $this->_redirect('marketplace/marketplaceaccount/new/');
  415. }
  416.  
  417. list($data, $errors) = $this->validatePost();
  418. $wholedata=$this->getRequest()->getParams();
  419. if(empty($errors)){
  420. $id = Mage::getModel('marketplace/product')->saveConfigNewProduct($wholedata);
  421. $status=Mage::getStoreConfig('marketplace/marketplace_options/partner_approval');
  422. if($status==1){
  423. $vendorId = Mage::getSingleton('customer/session')->getCustomer()->getId();
  424. $customer = Mage::getModel('customer/customer')->load($vendorId);
  425. $cfname=$customer->getFirstname()." ".$customer->getLastname();
  426. $cmail=$customer->getEmail();
  427. $catagory_model = Mage::getModel('catalog/category');
  428. $categoriesy = $catagory_model->load($wholedata['category'][0]);
  429. $categoryname=$categoriesy->getName();
  430. $emailTemp = Mage::getModel('core/email_template')->loadDefault('approveproduct');
  431. $emailTempVariables = array();
  432. $adminname = 'Administrators';
  433. $admin_storemail = Mage::getStoreConfig('marketplace/marketplace_options/adminemail');
  434. $adminEmail=$admin_storemail? $admin_storemail:Mage::getStoreConfig('trans_email/ident_general/email');
  435. $emailTempVariables['myvar1'] = $wholedata['name'];
  436. $emailTempVariables['myvar2'] =$categoryname;
  437. $emailTempVariables['myvar3'] =$adminname;
  438. $emailTempVariables['myvar4'] = Mage::helper('marketplace')->__('I would like to inform you that recently i have added a new product in the store.');
  439. $processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
  440. $emailTemp->setSenderName($cfname);
  441. $emailTemp->setSenderEmail($cmail);
  442. $emailTemp->send($adminEmail,$adminname,$emailTempVariables);
  443. }
  444. }else{
  445. foreach ($errors as $message) {$this->_getSession()->addError($message);}
  446. $_SESSION['new_products_errors'] = $data;
  447. }
  448. $attr = $wholedata['attrdata'];
  449. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Product has been Created Successfully'));
  450. $this->_redirect('marketplace/marketplaceaccount/configurableassociate',array('attr'=>$attr,'id'=>$id));
  451. }
  452. else{
  453. return $this->_redirect('marketplace/marketplaceaccount/new/');
  454. }
  455. }
  456.  
  457. public function configurableassociateAction(){
  458. $this->loadLayout( array('default','marketplace_account_configurableassociate'));
  459. $this->_initLayoutMessages('customer/session');
  460. $this->_initLayoutMessages('catalog/session');
  461. $this->getLayout()->getBlock('head')->setTitle($this->__('Add Associate Product'));
  462. $this->renderLayout();
  463. }
  464.  
  465. public function myproductslistAction(){
  466. $this->loadLayout( array('default','marketplace_account_productlist'));
  467. $this->_initLayoutMessages('customer/session');
  468. $this->_initLayoutMessages('catalog/session');
  469. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('My Product List'));
  470. $this->renderLayout();
  471. }
  472. public function becomepartnerAction(){
  473. if($this->getRequest()->isPost()){
  474. if (!$this->_validateFormKey()) {
  475. return $this->_redirect('marketplace/marketplaceaccount/becomepartner/');
  476. }
  477.  
  478. $wholedata=$this->getRequest()->getParams();
  479. Mage::getModel('marketplace/product')->saveBecomePartnerStatus($wholedata);
  480. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your request to become seller was successfully send to admin'));
  481. $this->_redirect('marketplace/marketplaceaccount/becomepartner/');
  482. }
  483. else{
  484. $this->loadLayout( array('default','marketplace_account_becomepartner'));
  485. $this->_initLayoutMessages('customer/session');
  486. $this->_initLayoutMessages('catalog/session');
  487. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('Seller Request Panel'));
  488. $this->renderLayout();
  489. }
  490. }
  491.  
  492. public function myorderhistoryAction(){
  493. $this->loadLayout( array('default','marketplace_account_orderhistory'));
  494. $this->_initLayoutMessages('customer/session');
  495. $this->_initLayoutMessages('catalog/session');
  496. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('My Order History'));
  497. $this->renderLayout();
  498. }
  499.  
  500. public function editapprovedsimpleAction() {
  501. if($this->getRequest()->isPost()){
  502. if (!$this->_validateFormKey()) {
  503. return $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  504. }
  505.  
  506. list($data, $errors) = $this->validatePost();
  507. $id= $this->getRequest()->getParam('productid');
  508. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  509. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  510. if(count($collection_product))
  511. {
  512. if(empty($errors)){
  513. Mage::getSingleton('core/session')->setEditProductId($id);
  514. Mage::getModel('marketplace/product')->editProduct($id,$this->getRequest()->getParams());
  515. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  516. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  517. }else{
  518. foreach ($errors as $message) {Mage::getSingleton('core/session')->addError($message);}
  519. $_SESSION['new_products_errors'] = $data;
  520. $this->_redirect('marketplace/marketplaceaccount/editapprovedsimple',array('id'=>$id));
  521. }
  522. }
  523. else
  524. {
  525. $this->_redirect('marketplace/marketplaceaccount/editapprovedsimple',array('id'=>$id));
  526. }
  527. }
  528. else{
  529. $urlid=$this->getRequest()->getParam('id');
  530. $loadpro =Mage::getModel('catalog/product')->load($urlid);
  531. if($loadpro ->getTypeId()!='simple'){
  532. $type_id = $loadpro ->getTypeId();
  533. if($type_id=='virtual')
  534. $this->_redirect('marketplace/marketplaceaccount/editapprovedvirtual',array('id'=>$urlid));
  535. if($type_id=='downloadable')
  536. $this->_redirect('marketplace/marketplaceaccount/editapproveddownloadable',array('id'=>$urlid));
  537. if($type_id=='configurable')
  538. $this->_redirect('marketplace/marketplaceaccount/editapprovedconfigurable',array('id'=>$urlid));
  539. }
  540. $this->loadLayout( array('default','marketplace_account_simpleproductedit'));
  541. $this->_initLayoutMessages('customer/session');
  542. $this->_initLayoutMessages('catalog/session');
  543. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('MarketPlace: Edit Simple Magento Product'));
  544. $this->renderLayout();
  545. }
  546. }
  547. public function editapprovedvirtualAction() {
  548. if($this->getRequest()->isPost()){
  549. if (!$this->_validateFormKey()) {
  550. return $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  551. }
  552. list($data, $errors) = $this->validatePost();
  553. $id= $this->getRequest()->getParam('productid');
  554. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  555. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  556. if(count($collection_product)){
  557. if(empty($errors)){
  558. Mage::getSingleton('core/session')->setEditProductId($id);
  559. Mage::getModel('marketplace/product')->editVirtualProduct($id,$this->getRequest()->getParams());
  560. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  561. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  562. }else{
  563. foreach ($errors as $message) {Mage::getSingleton('core/session')->addError($message);}
  564. $_SESSION['new_products_errors'] = $data;
  565. $this->_redirect('marketplace/marketplaceaccount/editapprovedvirtual',array('id'=>$id));
  566. }
  567. }else{
  568. $this->_redirect('marketplace/marketplaceaccount/editapprovedvirtual',array('id'=>$id));
  569. }
  570. }else{
  571. $urlid=$this->getRequest()->getParam('id');
  572. $loadpro =Mage::getModel('catalog/product')->load($urlid);
  573. if($loadpro ->getTypeId()!='virtual'){
  574. $type_id = $loadpro ->getTypeId();
  575. if($type_id=='simple')
  576. $this->_redirect('marketplace/marketplaceaccount/editapprovedsimple',array('id'=>$urlid));
  577. if($type_id=='downloadable')
  578. $this->_redirect('marketplace/marketplaceaccount/editapproveddownloadable',array('id'=>$urlid));
  579. if($type_id=='configurable')
  580. $this->_redirect('marketplace/marketplaceaccount/editapprovedconfigurable',array('id'=>$urlid));
  581. }
  582. $this->loadLayout( array('default','marketplace_account_virtualproductedit'));
  583. $this->_initLayoutMessages('customer/session');
  584. $this->_initLayoutMessages('catalog/session');
  585. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('MarketPlace: Edit Virtual Magento Product'));
  586. $this->renderLayout();
  587. }
  588. }
  589. public function editapproveddownloadableAction() {
  590. if($this->getRequest()->isPost()){
  591. if (!$this->_validateFormKey()) {
  592. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  593. }
  594. list($data, $errors) = $this->validatePost();
  595. $id= $this->getRequest()->getParam('productid');
  596. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  597. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  598. if(count($collection_product)){
  599. if(empty($errors)){
  600. Mage::getSingleton('core/session')->setEditProductId($id);
  601. Mage::getModel('marketplace/product')->editDownloadableProduct($id,$this->getRequest()->getParams());
  602. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  603. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  604. }else{
  605. foreach ($errors as $message) {Mage::getSingleton('core/session')->addError($message);}
  606. $_SESSION['new_products_errors'] = $data;
  607. $this->_redirect('marketplace/marketplaceaccount/editapproveddownloadable',array('id'=>$id));
  608. }
  609. }else{
  610. $this->_redirect('marketplace/marketplaceaccount/editapproveddownloadable',array('id'=>$id));
  611. }
  612. }else{
  613. $urlid=$this->getRequest()->getParam('id');
  614. $loadpro =Mage::getModel('catalog/product')->load($urlid);
  615. if($loadpro ->getTypeId()!='downloadable'){
  616. $type_id = $loadpro ->getTypeId();
  617. if($type_id=='simple')
  618. $this->_redirect('marketplace/marketplaceaccount/editapprovedsimple',array('id'=>$urlid));
  619. if($type_id=='virtual')
  620. $this->_redirect('marketplace/marketplaceaccount/editapprovedvirtual',array('id'=>$urlid));
  621. if($type_id=='configurable')
  622. $this->_redirect('marketplace/marketplaceaccount/editapprovedconfigurable',array('id'=>$urlid));
  623. }
  624. $this->loadLayout( array('default','marketplace_account_downloadableproductedit'));
  625. $this->_initLayoutMessages('customer/session');
  626. $this->_initLayoutMessages('catalog/session');
  627. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('MarketPlace: Edit Downloadable Magento Product'));
  628. $this->renderLayout();
  629. }
  630. }
  631. public function editapprovedconfigurableAction() {
  632. if($this->getRequest()->isPost()){
  633. if(!$this->_validateFormKey()){
  634. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  635. }
  636. list($data, $errors) = $this->validatePost();
  637. $id= $this->getRequest()->getParam('productid');
  638. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  639. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  640. if(count($collection_product)){
  641. if(empty($errors)){
  642. Mage::getSingleton('core/session')->setEditProductId($id);
  643. Mage::getModel('marketplace/product')->editProduct($id,$this->getRequest()->getParams());
  644. Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  645. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  646. }else{
  647. foreach ($errors as $message) {Mage::getSingleton('core/session')->addError($message);}
  648. $_SESSION['new_products_errors'] = $data;
  649. $this->_redirect('marketplace/marketplaceaccount/editapprovedconfigurable',array('id'=>$id));
  650. }
  651. }else{
  652. $this->_redirect('marketplace/marketplaceaccount/editapprovedconfigurable',array('id'=>$id));
  653. }
  654. }else{
  655. $urlid=$this->getRequest()->getParam('id');
  656. $loadpro =Mage::getModel('catalog/product')->load($urlid);
  657. if($loadpro ->getTypeId()!='configurable'){
  658. $type_id = $loadpro ->getTypeId();
  659. if($type_id=='simple')
  660. $this->_redirect('marketplace/marketplaceaccount/editapprovedsimple',array('id'=>$urlid));
  661. if($type_id=='virtual')
  662. $this->_redirect('marketplace/marketplaceaccount/editapprovedvirtual',array('id'=>$urlid));
  663. if($type_id=='downloadable')
  664. $this->_redirect('marketplace/marketplaceaccount/editapproveddownloadable',array('id'=>$urlid));
  665. }
  666. $this->loadLayout( array('default','marketplace_account_configurableproductedit'));
  667. $this->_initLayoutMessages('customer/session');
  668. $this->_initLayoutMessages('catalog/session');
  669. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('MarketPlace: Edit Configurable Magento Product'));
  670. $this->renderLayout();
  671. }
  672. }
  673.  
  674. public function deleteAction(){
  675. $urlapp=$_SERVER['REQUEST_URI'];
  676. $record=Mage::getModel('marketplace/product')->deleteProduct($urlapp);
  677. if($record==1){
  678. Mage::getSingleton('core/session')->addError( Mage::helper('marketplace')->__('YOU ARE NOT AUTHORIZE TO DELETE THIS PRODUCT..'));
  679. }else{
  680. Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Your Product Has Been Sucessfully Deleted From Your Account'));
  681. }
  682. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  683. }
  684.  
  685. public function massdeletesellerproAction(){
  686. if($this->getRequest()->isPost()){
  687. if(!$this->_validateFormKey()){
  688. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  689. }
  690. $ids= $this->getRequest()->getParam('product_mass_delete');
  691. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  692. $unauth_ids = array();
  693. Mage::register("isSecureArea", 1);
  694. Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
  695. foreach ($ids as $id){
  696. $data['id']=$id;
  697. Mage::dispatchEvent('mp_delete_product', $data);
  698. $collection_product = Mage::getModel('marketplace/product')->getCollection()
  699. ->addFieldToFilter('mageproductid',array('eq'=>$id))
  700. ->addFieldToFilter('userid',array('eq'=>$customerid));
  701. if(count($collection_product)) {
  702. Mage::getModel('catalog/product')->load($id)->delete();
  703. $collection=Mage::getModel('marketplace/product')->getCollection()
  704. ->addFieldToFilter('mageproductid',array('eq'=>$id));
  705. foreach($collection as $row){
  706. $row->delete();
  707. }
  708. }else{
  709. array_push($unauth_ids, $id);
  710. }
  711. }
  712. }
  713. if(count($unauth_ids)){
  714. Mage::getSingleton('core/session')->addError( Mage::helper('marketplace')->__('You are not authorized to delete products with id '.implode(",", $unauth_ids)));
  715. }else{
  716. Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Products has been sucessfully deleted from your account'));
  717. }
  718. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  719. }
  720.  
  721. public function mydashboardAction(){
  722. $this->loadLayout( array('default','marketplace_account_dashboard'));
  723. $this->_initLayoutMessages('customer/session');
  724. $this->_initLayoutMessages('catalog/session');
  725. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('My Dashboard'));
  726. $this->renderLayout();
  727. }
  728.  
  729. public function verifyskuAction(){
  730. $sku=$this->getRequest()->getParam('sku');
  731. $id = Mage::getModel('catalog/product')->getIdBySku($sku);
  732. if ($id){ $avl=0; }
  733. else{ $avl=1; }
  734. echo json_encode(array("avl"=>$avl));
  735. }
  736. public function deleteimageAction(){
  737. $data= $this->getRequest()->getParams();
  738. $_product = Mage::getModel('catalog/product')->load($data['pid'])->getMediaGalleryImages();
  739. $main = explode('/',$data['file']);
  740. foreach($_product as $_image) {
  741. $arr = explode('/',$_image['path']);
  742. if(array_pop($arr) != array_pop($main)){
  743. $newimage = $_image['file'];
  744. $id = $_image['value_id'];
  745. break;
  746. }
  747. }
  748. $mediaApi = Mage::getModel("catalog/product_attribute_media_api");
  749. $mediaApi->remove($data['pid'], $data['file']);
  750. if($newimage){
  751. $objprod=Mage::getModel('catalog/product')->load($data['pid']);
  752. $objprod->setSmallImage($newimage);
  753. $objprod->setImage($newimage);
  754. $objprod->setThumbnail($newimage);
  755. $objprod->save();
  756. }
  757. }
  758.  
  759. private function validatePost(){
  760. $errors = array();
  761. $data = array();
  762. foreach( $this->getRequest()->getParams() as $code => $value){
  763. switch ($code) :
  764. case 'name':
  765. if(trim($value) == '' ){$errors[] = Mage::helper('marketplace')->__('Name has to be completed');}
  766. else{$data[$code] = $value;}
  767. break;
  768. case 'description':
  769. if(trim($value) == '' ){$errors[] = Mage::helper('marketplace')->__('Description has to be completed');}
  770. else{$data[$code] = $value;}
  771. break;
  772. case 'short_description':
  773. if(trim($value) == ''){$errors[] = Mage::helper('marketplace')->__('Short description has to be completed');}
  774. else{$data[$code] = $value;}
  775. break;
  776. case 'price':
  777. if(!preg_match("/^([0-9])+?[0-9.]*$/",$value)){
  778. $errors[] = Mage::helper('marketplace')->__('Price should contain only decimal numbers');
  779. }else{$data[$code] = $value;}
  780. break;
  781. case 'weight':
  782. if(!preg_match("/^([0-9])+?[0-9.]*$/",$value)){
  783. $errors[] = Mage::helper('marketplace')->__('Weight should contain only decimal numbers');
  784. }else{$data[$code] = $value;}
  785. break;
  786. case 'stock':
  787. if(!preg_match("/^([0-9])+?[0-9.]*$/",$value)){
  788. $errors[] = Mage::helper('marketplace')->__('Product stock should contain only an integer number');
  789. }else{$data[$code] = $value;}
  790. break;
  791. case 'sku_type':
  792. if(trim($value) == '' ){$errors[] = Mage::helper('marketplace')->__('Sku Type has to be selected');}
  793. else{$data[$code] = $value;}
  794. break;
  795. case 'price_type':
  796. if(trim($value) == '' ){$errors[] = Mage::helper('marketplace')->__('Price Type has to be selected');}
  797. else{$data[$code] = $value;}
  798. break;
  799. case 'weight_type':
  800. if(trim($value) == ''){$errors[] = Mage::helper('marketplace')->__('Weight Type has to be selected');}
  801. else{$data[$code] = $value;}
  802. break;
  803. case 'bundle_options':
  804. if(trim($value) == ''){$errors[] = Mage::helper('marketplace')->__('Default Title has to be completed');}
  805. else{$data[$code] = $value;}
  806. break;
  807. endswitch;
  808. }
  809. return array($data, $errors);
  810. }
  811. public function paymentAction(){
  812. $wholedata=$this->getRequest()->getParams();
  813. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  814. $collection = Mage::getModel('marketplace/userprofile')->getCollection();
  815. $collection->addFieldToFilter('mageuserid',array('eq'=>$customerid));
  816. foreach($collection as $row){
  817. $id=$row->getAutoid();
  818. }
  819. $collectionload = Mage::getModel('marketplace/userprofile')->load($id);
  820. $collectionload->setpaymentsource($wholedata['paymentsource']);
  821. $collectionload->save();
  822. Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Your Payment Information Is Sucessfully Saved.'));
  823. $this->_redirect('marketplace/marketplaceaccount/editProfile');
  824. }
  825. public function askquestionAction(){
  826. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  827. $seller = Mage::getModel('customer/customer')->load($customerid);
  828. $email = $seller->getEmail();
  829. $name = $seller->getFirstname()." ".$seller->getLastname();
  830. $adminname = 'Administrators';
  831. $admin_storemail = Mage::getStoreConfig('marketplace/marketplace_options/adminemail');
  832. $adminEmail=$admin_storemail? $admin_storemail:Mage::getStoreConfig('trans_email/ident_general/email');
  833. $emailTemp = Mage::getModel('core/email_template')->loadDefault('queryadminemail');
  834. $emailTempVariables = array();
  835. $emailTempVariables['myvar1'] = $_POST['subject'];
  836. $emailTempVariables['myvar2'] =$name;
  837. $emailTempVariables['myvar3'] = $_POST['ask'];
  838. $processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
  839. $emailTemp->setSenderName($name);
  840. $emailTemp->setSenderEmail($email);
  841. $emailTemp->send($adminEmail,'Administrators',$emailTempVariables);
  842. }
  843. public function deleteprofileimageAction(){
  844. $collection = Mage::getModel('marketplace/userprofile')->getCollection();
  845. $collection->addFieldToFilter('mageuserid',array('eq'=>$this->_getSession()->getCustomerId()));
  846. foreach($collection as $value){
  847. $data = $value;
  848. $id = $value->getAutoid();
  849. }
  850. Mage::getModel('marketplace/userprofile')->load($id)->setBannerpic('')->save();
  851. echo "true";
  852. }
  853. public function deletelogoimageAction(){
  854. $collection = Mage::getModel('marketplace/userprofile')->getCollection();
  855. $collection->addFieldToFilter('mageuserid',array('eq'=>$this->_getSession()->getCustomerId()));
  856. foreach($collection as $value){
  857. $data = $value;
  858. $id = $value->getAutoid();
  859. }
  860. Mage::getModel('marketplace/userprofile')->load($id)->setLogopic('')->save();
  861. echo "true";
  862. }
  863. public function editprofileAction(){
  864. if($this->getRequest()->isPost()){
  865. if (!$this->_validateFormKey()) {
  866. return $this->_redirect('marketplace/marketplaceaccount/editProfile');
  867. }
  868. list($data, $errors) = $this->validateprofiledata();
  869. $fields = $this->getRequest()->getParams();
  870. $loid=$this->_getSession()->getCustomerId();
  871. $img1='';
  872. $img2='';
  873. if(empty($errors)){
  874. $write = Mage::getSingleton('core/resource')->getConnection('core_write');
  875. $collection = Mage::getModel('marketplace/userprofile')->getCollection();
  876. $collection->addFieldToFilter('mageuserid',array('eq'=>$this->_getSession()->getCustomerId()));
  877. foreach($collection as $value){ $data = $value; }
  878. $value->settwitterid($fields['twitterid']);
  879. $value->setfacebookid($fields['facebookid']);
  880. $value->setcontactnumber($fields['contactnumber']);
  881. $value->setbackgroundth($fields['backgroundth']);
  882. $value->setshoptitle($fields['shoptitle']);
  883. $value->setcomplocality($fields['complocality']);
  884. $value->setMetaKeyword($fields['meta_keyword']);
  885.  
  886. if($fields['compdesi']){
  887. $fields['compdesi'] = str_replace('script', '', $fields['compdesi']);
  888. }
  889. $value->setcompdesi($fields['compdesi']);
  890.  
  891. if(isset($fields['returnpolicy'])){
  892. $fields['returnpolicy'] = str_replace('script', '', $fields['returnpolicy']);
  893. $value->setReturnpolicy($fields['returnpolicy']);
  894. }
  895.  
  896. if(isset($fields['shippingpolicy'])){
  897. $fields['shippingpolicy'] = str_replace('script', '', $fields['shippingpolicy']);
  898. $value->setShippingpolicy($fields['shippingpolicy']);
  899. }
  900.  
  901. $value->setMetaDescription($fields['meta_description']);
  902. if(strlen($_FILES['bannerpic']['name'])>0){
  903. $extension = pathinfo($_FILES["bannerpic"]["name"], PATHINFO_EXTENSION);
  904. $temp = explode(".",$_FILES["bannerpic"]["name"]);
  905. $img1 = $temp[0].rand(1,99999).$loid.'.'.$extension;
  906. $value->setbannerpic($img1);
  907. }
  908. if(strlen($_FILES['logopic']['name'])>0){
  909. $extension = pathinfo($_FILES["logopic"]["name"], PATHINFO_EXTENSION);
  910. $temp1 = explode(".",$_FILES["logopic"]["name"]);
  911. $img2 = $temp1[0].rand(1,99999).$loid.'.'.$extension;
  912. $value->setlogopic($img2);
  913. }
  914. if (array_key_exists('countrypic', $fields)) {
  915. $value->setcountrypic($fields['countrypic']);
  916. }
  917. $value->save();
  918. $target =Mage::getBaseDir().'/media/avatar/';
  919. $targetb = $target.$img1;
  920.  
  921. move_uploaded_file($_FILES['bannerpic']['tmp_name'],$targetb);
  922. $targetl = $target.$img2;
  923. move_uploaded_file($_FILES['logopic']['tmp_name'],$targetl);
  924. try{
  925. if(!empty($errors)){
  926. foreach ($errors as $message){$this->_getSession()->addError($message);}
  927. }else{Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Profile information was successfully saved'));}
  928. $this->_redirect('marketplace/marketplaceaccount/editProfile');
  929. return;
  930. }catch (Mage_Core_Exception $e){
  931. $this->_getSession()->addError($e->getMessage());
  932. }catch (Exception $e){
  933. $this->_getSession()->addException($e, Mage::helper('marketplace')->__('Cannot save the customer.'));
  934. }
  935. $this->_redirect('customer/*/*');
  936. }else{
  937. foreach ($errors as $message) {Mage::getSingleton('core/session')->addError($message);}
  938. $_SESSION['new_products_errors'] = $data;
  939. $this->_redirect('marketplace/marketplaceaccount/editProfile');
  940. }
  941. }
  942. else{
  943. $this->loadLayout( array('default','marketplace_account_editaccount'));
  944. $this->_initLayoutMessages('customer/session');
  945. $this->_initLayoutMessages('catalog/session');
  946. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('Profile Information'));
  947. $this->renderLayout();
  948. }
  949. }
  950.  
  951. private function validateprofiledata(){
  952. $errors = array();
  953. $data = array();
  954. foreach( $this->getRequest()->getParams() as $code => $value){
  955. switch ($code) :
  956. case 'twitterid':
  957. if(trim($value) != '' && preg_match('/[\'^£$%&*()}{@#~?><>, |=_+¬-]/', $value)){$errors[] = Mage::helper('marketplace')->__('Twitterid cannot contain space and special charecters');}
  958. else{$data[$code] = $value;}
  959. break;
  960. case 'facebookid':
  961. if(trim($value) != '' && preg_match('/[\'^£$%&*()}{@#~?><>, |=_+¬-]/', $value)){$errors[] = Mage::helper('marketplace')->__('Facebookid cannot contain space and special charecters');}
  962. else{$data[$code] = $value;}
  963. break;
  964. case 'backgroundth':
  965. if(trim($value) != '' && strlen($value)!=6 && substr($value, 0, 1) != "#"){$errors[] = Mage::helper('marketplace')->__('Invalid Background Color');}
  966. else{$data[$code] = $value;}
  967. break;
  968. endswitch;
  969. }
  970. return array($data, $errors);
  971. }
  972.  
  973. public function mytransactionAction(){
  974. $this->loadLayout( array('default','marketplace_transaction_info'));
  975. $this->_initLayoutMessages('customer/session');
  976. $this->_initLayoutMessages('catalog/session');
  977. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('Transactions'));
  978. $this->renderLayout();
  979. }
  980.  
  981. public function viewtransdetailsAction(){
  982. $this->loadLayout( array('default','marketplace_marketplaceaccount_viewtransdetails'));
  983. $this->_initLayoutMessages('customer/session');
  984. $this->_initLayoutMessages('catalog/session');
  985. $this->getLayout()->getBlock('head')->setTitle( Mage::helper('marketplace')->__('Transaction Details'));
  986. $this->renderLayout();
  987. }
  988.  
  989. public function downloadtranscsvAction(){
  990. $id = Mage::getSingleton('customer/session')->getId();
  991. $transid=$this->getRequest()->getParam('transid')!=""?$this->getRequest()->getParam('transid'):"";
  992. $filter_data_frm=$this->getRequest()->getParam('from_date')!=""?$this->getRequest()->getParam('from_date'):"";
  993. $filter_data_to=$this->getRequest()->getParam('to_date')!=""?$this->getRequest()->getParam('to_date'):"";
  994. if($filter_data_to){
  995. $todate = date_create($filter_data_to);
  996. $to = date_format($todate, 'Y-m-d 23:59:59');
  997. }
  998. if($filter_data_frm){
  999. $fromdate = date_create($filter_data_frm);
  1000. $from = date_format($fromdate, 'Y-m-d H:i:s');
  1001. }
  1002. $collection = Mage::getModel('marketplace/sellertransaction')->getCollection();
  1003. $collection->addFieldToFilter('sellerid',array('eq'=>$id));
  1004. if($transid){
  1005. $collection->addFieldToFilter('transactionid', array('eq' => $transid));
  1006. }
  1007. if($from || $to){
  1008. $collection->addFieldToFilter('created_at', array('datetime' => true,'from' => $from,'to' => $to));
  1009. }
  1010. $collection->setOrder('transid');
  1011.  
  1012. $data = array();
  1013. foreach ($collection as $transactioncoll) {
  1014. $data1 =array();
  1015. $data1['Date'] = Mage::helper('core')->formatDate($transactioncoll->getCreatedAt(), 'medium', false);
  1016. $data1['Transaction Id'] = Mage::helper('core')->formatDate($transactioncoll->getCreatedAt(), 'medium', false);
  1017. if($transactioncoll->getCustomnote()) {
  1018. $data1['Comment Message'] = $transactioncoll->getCustomnote();
  1019. }else {
  1020. $data1['Comment Message'] = Mage::helper('marketplace')->__('None');
  1021. }
  1022. $data1['Transaction Amount'] = Mage::helper('core')->currency($transactioncoll->getTransactionamount(), true, false);
  1023. $data[] = $data1;
  1024. }
  1025.  
  1026. header('Content-Type: text/csv');
  1027. header('Content-Disposition: attachment; filename=transactionlist.csv');
  1028. header('Pragma: no-cache');
  1029. header("Expires: 0");
  1030.  
  1031. $outstream = fopen("php://output", "w");
  1032. fputcsv($outstream, array_keys($data[0]));
  1033.  
  1034. foreach($data as $result)
  1035. {
  1036. fputcsv($outstream, $result);
  1037. }
  1038.  
  1039. fclose($outstream);
  1040. }
  1041.  
  1042. public function deletelinkAction(){
  1043. $data= $this->getRequest()->getParams();
  1044. $_product = Mage::getModel('downloadable/link')->load($data['id'])->delete();
  1045. }
  1046.  
  1047. public function deletesampleAction(){
  1048. $data= $this->getRequest()->getParams();
  1049. $_product = Mage::getModel('downloadable/sample')->load($data['id'])->delete();
  1050. }
  1051.  
  1052. public function nicuploadscriptAction(){
  1053. $data= $this->getRequest()->getParams();
  1054. if(isset($_FILES['image'])){
  1055. $img = $_FILES['image'];
  1056. $imagename = rand().$img["name"];
  1057. $path = "nicimages/".$imagename;
  1058. if(!is_dir(Mage::getBaseDir().'/media/marketplace/nicimages')){
  1059. mkdir(Mage::getBaseDir().'/media/marketplace/nicimages', 0755);
  1060. }
  1061. $target =Mage::getBaseDir().'/media/marketplace/nicimages/';
  1062. $targetpath = $target.$imagename;
  1063. move_uploaded_file($img['tmp_name'],$targetpath);
  1064. $data = getimagesize($targetpath);
  1065. $link = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'marketplace/'.$path;
  1066. $res = array("upload" => array(
  1067. "links" => array("original" => $link),
  1068. "image" => array("width" => $data[0],
  1069. "height" => $data[1]
  1070. )
  1071. ));
  1072. }
  1073. echo json_encode($res);
  1074. }
  1075.  
  1076.  
  1077.  
  1078.  
  1079. // Price start
  1080.  
  1081.  
  1082. public function updateFieldPriceAction(){
  1083. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  1084. $id= $this->getRequest()->getParam('id');
  1085. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1086. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1087. //Mage::getSingleton('core/session')->setEditProductId($id);
  1088.  
  1089. try{
  1090. $upd_price = $this->getRequest()->getParam('price');
  1091. $product = Mage::getModel('catalog/product')->load($id);
  1092. //$product->setData('price', $upd_price);
  1093. $product->setPrice($upd_price);
  1094.  
  1095. //$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id);
  1096. //$stockItem->setData('manage_stock', 1);
  1097. //$stockItem->setData('qty', $this->getRequest()->getParam('qty'));
  1098. $product->save();
  1099.  
  1100. echo $price = $product->getPrice();
  1101. echo $name = $product->getName();
  1102.  
  1103. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1104. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1105. //Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  1106.  
  1107.  
  1108. //endif;
  1109. }catch(Exception $e){
  1110. echo "Not Saving"; exit;
  1111. Mage::log($e->getMessage());
  1112. }
  1113.  
  1114. }
  1115.  
  1116. /*
  1117.  
  1118. public function updateFieldQtyAction(){
  1119. $id= $this->getRequest()->getParam('id');
  1120. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1121. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1122. //Mage::getSingleton('core/session')->setEditProductId($id);
  1123. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id);
  1124. $stockItem->setData('manage_stock', 1);
  1125. $stockItem->setData('qty', $this->getRequest()->getParam('qty'));
  1126.  
  1127. $stockItem->save();
  1128.  
  1129. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1130. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1131. //Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  1132. }
  1133.  
  1134. */
  1135. // Price end
  1136.  
  1137. // S P start
  1138.  
  1139. public function updateFieldSpecialPriceAction(){
  1140. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  1141. $id= $this->getRequest()->getParam('id');
  1142. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1143. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1144. //Mage::getSingleton('core/session')->setEditProductId($id);
  1145.  
  1146. try{
  1147. $upd_price = $this->getRequest()->getParam('price');
  1148. $product = Mage::getModel('catalog/product')->load($id);
  1149. //$product->setData('price', $upd_price);
  1150. $product->setSpecialPrice($upd_price);
  1151.  
  1152.  
  1153. //$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id);
  1154. //$stockItem->setData('manage_stock', 1);
  1155. //$stockItem->setData('qty', $this->getRequest()->getParam('qty'));
  1156. $product->save();
  1157.  
  1158. echo $price = $product->getPrice();
  1159. echo $name = $product->getName();
  1160.  
  1161. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1162. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1163. //Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  1164.  
  1165.  
  1166. //endif;
  1167. }catch(Exception $e){
  1168. echo "Not Saving"; exit;
  1169. Mage::log($e->getMessage());
  1170. }
  1171.  
  1172. }
  1173.  
  1174.  
  1175.  
  1176. // S P end
  1177.  
  1178. //local code start
  1179.  
  1180.  
  1181.  
  1182. public function updateFieldLocalAction(){
  1183. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  1184. $id= $this->getRequest()->getParam('id');
  1185. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1186. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1187.  
  1188. try{
  1189. $upd_local = $this->getRequest()->getParam('local');
  1190. $product = Mage::getModel('catalog/product')->load($id);
  1191. $product->setData('mp_local_shipping_charge',$upd_local);
  1192. $product->getResource()->saveAttribute($product,'mp_local_shipping_charge');
  1193.  
  1194. // $product->setLocal($upd_local);
  1195.  
  1196. $product->save();
  1197.  
  1198. echo $local = $product->getLocal();
  1199. echo $name = $product->getName();
  1200.  
  1201. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1202. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1203.  
  1204. }catch(Exception $e){
  1205. echo "Not Saving"; exit;
  1206. Mage::log($e->getMessage());
  1207. }
  1208.  
  1209. }
  1210. //local end
  1211.  
  1212.  
  1213.  
  1214. //regional start
  1215.  
  1216. public function updateFieldRegionalAction(){
  1217. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  1218. $id= $this->getRequest()->getParam('id');
  1219. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1220. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1221.  
  1222. try{
  1223. $upd_regional = $this->getRequest()->getParam('regional');
  1224. $product = Mage::getModel('catalog/product')->load($id);
  1225. $product->setData('mp_regional_shipping_charge',$upd_regional);
  1226. $product->getResource()->saveAttribute($product,'mp_regional_shipping_charge');
  1227. // $product->setRegional($upd_regional);
  1228.  
  1229. $product->save();
  1230.  
  1231. echo $regional = $product->getRegional();
  1232. echo $name = $product->getName();
  1233.  
  1234. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1235. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1236.  
  1237. }catch(Exception $e){
  1238. echo "Not Saving"; exit;
  1239. Mage::log($e->getMessage());
  1240. }
  1241.  
  1242. }
  1243.  
  1244. //regional end
  1245.  
  1246. // state start
  1247.  
  1248.  
  1249. public function updateFieldStateAction(){
  1250. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  1251. $id= $this->getRequest()->getParam('id');
  1252. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1253. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1254.  
  1255. try{
  1256. $upd_state = $this->getRequest()->getParam('state');
  1257. $product = Mage::getModel('catalog/product')->load($id);
  1258. $product->setData('mp_state_shipping_charge',$upd_state);
  1259. $product->getResource()->saveAttribute($product,'mp_state_shipping_charge');
  1260.  
  1261.  
  1262. // $product->setState($upd_state);
  1263.  
  1264. $product->save();
  1265.  
  1266. echo $state = $product->getState();
  1267. echo $name = $product->getName();
  1268.  
  1269. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1270. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1271.  
  1272. }catch(Exception $e){
  1273. echo "Not Saving"; exit;
  1274. Mage::log($e->getMessage());
  1275. }
  1276.  
  1277. }
  1278.  
  1279.  
  1280. //state end
  1281.  
  1282.  
  1283. // cod start
  1284.  
  1285. public function updateFieldCodAction(){
  1286. // Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  1287. $id= $this->getRequest()->getParam('id');
  1288. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1289. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1290.  
  1291. try{
  1292. $upd_cod = $this->getRequest()->getParam('cod');
  1293. $product = Mage::getModel('catalog/product')->load($id);
  1294. $product->setData('cod_available',$upd_cod);
  1295. $product->getResource()->saveAttribute($product,'cod_available');
  1296. // $product->setCod($upd_cod);
  1297.  
  1298. $product->save();
  1299.  
  1300. echo $cod = $product->getCod();
  1301. echo $name = $product->getName();
  1302.  
  1303. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1304. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1305.  
  1306. }catch(Exception $e){
  1307. echo "Not Saving"; exit;
  1308. Mage::log($e->getMessage());
  1309. }
  1310.  
  1311. }
  1312.  
  1313. //cod end
  1314.  
  1315.  
  1316. // Qty start
  1317. /*
  1318. public function updateFieldAction(){
  1319. Mage::getModel('marketplace/product')->editProduct($id,$this->getRequest()->getP‌​arams());
  1320. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
  1321. echo $id= $this->getRequest()->getParam('id');
  1322. $selllermpassignproduct=Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($id);
  1323. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1324. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1325. //Mage::getSingleton('core/session')->setEditProductId($id);
  1326. $assignqty=isset($selllermpassignproduct['assignqty'])?$selllermpassignproduct['assignqty']:0;
  1327. $newqty=$this->getRequest()->getParam('qty')+$assignqty;
  1328. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id);
  1329. $stockItem->setData('manage_stock', 1);
  1330. $stockItem->setData('qty', $newqty);
  1331. echo $newqty;
  1332. // exit();
  1333.  
  1334. $stockItem->save();
  1335.  
  1336. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1337. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1338. //Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  1339. }
  1340. */
  1341. // Qty end
  1342.  
  1343.  
  1344. //assigned qty
  1345.  
  1346. /*
  1347. public function updateFieldAction(){
  1348. //echo "gfggggg";
  1349. //die;
  1350.  
  1351. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
  1352. //$id= $this->getRequest()->getParam('id');
  1353. $id = 2207;
  1354. $pro=Mage::getModel('catalog/product')->load($id);
  1355. $selllermpassignproduct=Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($id);
  1356.  
  1357. $customerid=Mage::getSingleton('customer/session')->getCustomerId();
  1358. $collection_product = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$id))->addFieldToFilter('userid',array('eq'=>$customerid));
  1359.  
  1360. //Mage::getSingleton('core/session')->setEditProductId($id);
  1361. if($selllermpassignproduct['seller_id']==$customerid)
  1362. {
  1363.  
  1364. $assignqty=isset($selllermpassignproduct['assignqty'])?$selllermpassignproduct['assignqty']:0;
  1365. $newq=$pro->getQty()-$assignqty;
  1366. $newqty=$this->getRequest()->getParam('qty')+$newq;
  1367. $connectionresource = Mage::getSingleton('core/resource');
  1368. $connectionWrite = $connectionresource->getConnection('core_write');
  1369. $table1 = $connectionresource->getTableName('mpassignproduct/mpassignproduct');
  1370. echo "<pre>";
  1371. print_r($connectionresource);
  1372. die;
  1373. $connectionWrite->beginTransaction();
  1374.  
  1375. $data = array(
  1376.  
  1377. 'assignqty' => $this->getRequest()->getParam('qty'),
  1378.  
  1379.  
  1380. );
  1381.  
  1382. $connectionWrite->update($table1, $data, array(
  1383. 'seller_id = ?' => $customerid,
  1384. 'mageproductid = ?' => $id,
  1385.  
  1386.  
  1387. ));
  1388. $connectionWrite->commit();
  1389.  
  1390. }else {
  1391.  
  1392. $assignqty=isset($selllermpassignproduct['assignqty'])?$selllermpassignproduct['assignqty']:0;
  1393. $newqty=$this->getRequest()->getParam('qty')+$assignqty;
  1394.  
  1395. }
  1396. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id);
  1397. $stockItem->setData('manage_stock', 1);
  1398. $stockItem->setData('qty', $newqty);
  1399.  
  1400. $stockItem->save();
  1401. //$product->save();
  1402. $pro->save();
  1403. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1404. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1405. //Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  1406. }
  1407. */
  1408. // asigned qty end
  1409.  
  1410.  
  1411.  
  1412. // update all
  1413.  
  1414. /*
  1415.  
  1416. public function massupdatesellerproAction(){
  1417. if($this->getRequest()->isPost()){
  1418. if(!$this->_validateFormKey()){
  1419. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  1420. }
  1421. $ids= $this->getRequest()->getParam('product_mass_update');
  1422. $price= $this->getRequest()->getParam('price');
  1423. $special= $this->getRequest()->getParam('specialprice');
  1424. $qty = $this->getRequest()->getParam('qty');
  1425. $local= $this->getRequest()->getParam('local');
  1426. $regional= $this->getRequest()->getParam('regional');
  1427. $state= $this->getRequest()->getParam('state');
  1428. $cod= $this->getRequest()->getParam('cod');
  1429.  
  1430. foreach ($ids as $key => $value) {
  1431. $product = Mage::getModel('catalog/product')->load($value);
  1432. $product->setPrice($price[$key]);
  1433. $product->setSpecialPrice($special[$key]);
  1434. $product->setQty($qty[$key]);
  1435. $product->setMpLocalShippingCharge($local[$key]);
  1436. $product->setMpRegionalShippingCharge($regional[$key]);
  1437. $product->setMpStateShippingCharge($state[$key]);
  1438. $product->setCodAvailable($cod[$key]);
  1439.  
  1440. $product->save();
  1441. }
  1442. Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Products has been sucessfully deleted from your account'));
  1443. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  1444.  
  1445.  
  1446. }}
  1447.  
  1448. */
  1449.  
  1450.  
  1451. // toan
  1452.  
  1453. public function updateFieldAction()
  1454. {
  1455. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
  1456. $productId = $this->getRequest()->getParam('id');
  1457. $selllermpassignproduct = Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($productId);
  1458. $customerId = Mage::getSingleton('customer/session')->getCustomerId();
  1459. $collectionProduct = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=>$productId))->addFieldToFilter('userid',array('eq'=>$customerId));
  1460. $assignQty = isset($selllermpassignproduct['assignqty']) ? $selllermpassignproduct['assignqty'] : 0;
  1461. $newQty = $this->getRequest()->getParam('qty') + $assignqty;
  1462. $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
  1463. $qtyStock->setProductId($id)->setStockId(1);
  1464. $qtyStock->setData('is_in_stock', true);
  1465. $savedStock = $qtyStock->save();
  1466. $qtyStock->load($savedStock->getId())->setQty($newQty)->save();
  1467. $qtyStock->setProductId($id)->setStockId(1);
  1468. $qtyStock->setData('is_in_stock', true);
  1469. $savedStock = $qtyStock->save();
  1470.  
  1471. //$stockItem->setData('manage_stock', 1);
  1472. //$stockItem->setData('qty', $newqty);
  1473. //$stockItem->save();
  1474.  
  1475. $response['message'] = 'Your Product Is Been Sucessfully Updated';
  1476. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  1477. //Mage::getSingleton('core/session')->addSuccess(Mage::helper('marketplace')->__('Your Product Is Been Sucessfully Updated'));
  1478. }
  1479.  
  1480. //toan end
  1481.  
  1482.  
  1483.  
  1484. //update all end
  1485.  
  1486.  
  1487. public function massupdatesellerproAction(){
  1488. if($this->getRequest()->isPost()){
  1489. if(!$this->_validateFormKey()){
  1490. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  1491. }
  1492. $ids= $this->getRequest()->getParam('product_mass_update');
  1493. $price= $this->getRequest()->getParam('price');
  1494. $special= $this->getRequest()->getParam('specialprice');
  1495. $local= $this->getRequest()->getParam('local');
  1496. $regional= $this->getRequest()->getParam('regional');
  1497. $state= $this->getRequest()->getParam('state');
  1498. $cod= $this->getRequest()->getParam('cod');
  1499.  
  1500.  
  1501. $i=1;
  1502. foreach ($ids as $key => $value) {
  1503. $i=$i+1;
  1504. $qty = $this->getRequest()->getParam('stock'.$i);
  1505. $selllermpassignproduct=Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($value);
  1506. $assignqty=isset($selllermpassignproduct['assignqty'])?$selllermpassignproduct['assignqty']:0;
  1507. $newqty=$qty+$assignqty;
  1508.  
  1509. $product = Mage::getModel('catalog/product')->load($value);
  1510. $product->setPrice($price[$key]);
  1511. $product->setSpecialPrice($special[$key]);
  1512. $product->setMpLocalShippingCharge($local[$key]);
  1513. $product->setMpRegionalShippingCharge($regional[$key]);
  1514. $product->setMpStateShippingCharge($state[$key]);
  1515. $product->setCodAvailable($cod[$key]);
  1516. //$product->setQty($qty);
  1517.  
  1518.  
  1519. $product->save();
  1520. $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($value);
  1521. $stockItem->setData('manage_stock', 1);
  1522. $stockItem->setData('qty', $newqty);
  1523. $stockItem->save();
  1524. }
  1525.  
  1526. Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Products has been sucessfully Updated from your account'));
  1527. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  1528. }}
  1529.  
  1530. }
  1531.  
  1532.  
  1533.  
  1534.  
  1535. /*
  1536.  
  1537. public function singlerowupdateAction(){
  1538. if($this->getRequest()->isPost()){
  1539. if(!$this->_validateFormKey()){
  1540. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  1541. }
  1542. $id= $this->getRequest()->getParam('id');
  1543. $price= $this->getRequest()->getParam('price');
  1544. $speprice= $this->getRequest()->getParam('speprice');
  1545. $qty = $this->getRequest()->getParam('quantity');
  1546. $mp_local_shipping_charge = $this->getRequest()->getParam('mp_local_shipping_charge');
  1547. $cod_available = $this->getRequest()->getParam('cod_available');
  1548. $product = Mage::getModel('catalog/product')->load($id);
  1549. $product->setPrice($price);
  1550. $product->setSpecialPrice($price);
  1551. $product->setQty($qty);
  1552. $product->setLocal($mp_local_shipping_charge);
  1553. $product->setCod($cod_available);
  1554. $product->save();
  1555.  
  1556. Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Products has been sucessfully saved from your account'));
  1557. $this->_redirect('marketplace/marketplaceaccount/myproductslist/');
  1558.  
  1559.  
  1560. }}
  1561.  
  1562. */
RAW Paste Data