CsuMarketSystem_OpteMais - Version 1.2.3

Version Notes

- Ajuste para adicionar múltiplos produtos à campanha de forma otimizada;
- Validação para não deixar adicionar produto já existente em uma campanha.

Download this release

Release Info

Developer csumarketsystem
Extension CsuMarketSystem_OpteMais
Version 1.2.3
Comparing to
See all releases


Code changes from version 1.2.2 to 1.2.3

app/code/community/CsuMarketSystem/OpteMais/Block/Adminhtml/Paymentmethod.php CHANGED
@@ -56,7 +56,7 @@ class CsuMarketSystem_OpteMais_Block_Adminhtml_Paymentmethod extends Mage_Adminh
56
  $html .= '<p class="note">Número maximo de parcelas permitida para o Método de Pagamento (Selecione somente quando houver parcelamento).</p>';
57
 
58
 
59
- $html .= '<label>' . $this->__('Júros aplicado às parcelas') . '</label>';
60
  $html .= '<input class="input-text" type="text" name="' . $this->getElement()->getName() . '[interest][]" value="' . $this->_getValue('interest/' . $i) . '" ' . $this->_getDisabled() . ' />';
61
  $html .= '<p class="note">Júros que será aplicado ao parcelamento (Preencha somente quando houver parcelamento e júros). Exemplo: 1.9%</p>';
62
 
56
  $html .= '<p class="note">Número maximo de parcelas permitida para o Método de Pagamento (Selecione somente quando houver parcelamento).</p>';
57
 
58
 
59
+ $html .= '<label>' . $this->__('Juros aplicado às parcelas') . '</label>';
60
  $html .= '<input class="input-text" type="text" name="' . $this->getElement()->getName() . '[interest][]" value="' . $this->_getValue('interest/' . $i) . '" ' . $this->_getDisabled() . ' />';
61
  $html .= '<p class="note">Júros que será aplicado ao parcelamento (Preencha somente quando houver parcelamento e júros). Exemplo: 1.9%</p>';
62
 
app/code/community/CsuMarketSystem/OpteMais/Model/Campaign.php CHANGED
@@ -96,6 +96,16 @@ class CsuMarketSystem_OpteMais_Model_Campaign extends CsuMarketSystem_OpteMais_M
96
  return false;
97
  }
98
 
 
 
 
 
 
 
 
 
 
 
99
  public function addItemToCampaign(Mage_Core_Controller_Request_Http $request, $campaignId)
100
  {
101
  $products = explode(',', $request->getParam('products'));
@@ -110,8 +120,9 @@ class CsuMarketSystem_OpteMais_Model_Campaign extends CsuMarketSystem_OpteMais_M
110
  '{{table}}.stock_id=1',
111
  'left'
112
  );
 
 
113
  foreach ($productCollection as $product) {
114
- $campaignItem = Mage::getModel('optemais/campaign_item');
115
  $campaignItem->setId(null);
116
  $campaignItem->setCampaignId($campaignId);
117
  $campaignItem->setProductId($product->getId());
96
  return false;
97
  }
98
 
99
+ public function validateProducts(Mage_Core_Controller_Request_Http $request, $campaignId)
100
+ {
101
+ $products = explode(',', $request->getParam('products'));
102
+ /** @var CsuMarketSystem_OpteMais_Model_Resource_Campaign_Item_Collection $campaignCollection */
103
+ $campaignCollection = Mage::getModel('optemais/campaign_item')->getCollection();
104
+ $campaignCollection->addFieldToFilter('product_id',array('in'=>$products));
105
+ $campaignCollection->addFieldToFilter('campaign_id',$campaignId);
106
+ return !$campaignCollection->getSize();
107
+ }
108
+
109
  public function addItemToCampaign(Mage_Core_Controller_Request_Http $request, $campaignId)
110
  {
111
  $products = explode(',', $request->getParam('products'));
120
  '{{table}}.stock_id=1',
121
  'left'
122
  );
123
+ $campaignItem = Mage::getModel('optemais/campaign_item');
124
+ /** @var Mage_Catalog_Model_Product $product */
125
  foreach ($productCollection as $product) {
 
126
  $campaignItem->setId(null);
127
  $campaignItem->setCampaignId($campaignId);
128
  $campaignItem->setProductId($product->getId());
app/code/community/CsuMarketSystem/OpteMais/controllers/Adminhtml/Optemais/CampaignController.php CHANGED
@@ -18,14 +18,9 @@ class CsuMarketSystem_OpteMais_Adminhtml_Optemais_CampaignController extends Mag
18
  {
19
  return Mage::getSingleton('admin/session')->isAllowed('admin/promo/optemais_campaign');
20
  }
21
-
22
  public function addItemsAction()
23
  {
24
- if (!$this->_validateProducts($this->getRequest()->getParam('product'))) {
25
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('optemais')->__('Produtos inválidos'));
26
- $this->_redirect('adminhtml/catalog_product/index');
27
- return false;
28
- }
29
  $products = $this->getRequest()->getParam('product');
30
  if (!is_array($products)) {
31
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('optemais')->__('Selecione pelo menos um produto'));
@@ -33,12 +28,13 @@ class CsuMarketSystem_OpteMais_Adminhtml_Optemais_CampaignController extends Mag
33
  return false;
34
  } else {
35
  try {
36
- foreach ($products as $productId) {
37
- /** @var Mage_Catalog_Model_Product $product */
38
- $product = Mage::getModel('catalog/product')->load($productId);
39
- if ($product->getTypeId() != Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
40
- throw new Exception(Mage::helper('optemais')->__('Utilize somente [Produtos Simples] para Campanhas'));
41
- }
 
42
  }
43
  } catch (Exception $e) {
44
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
@@ -46,10 +42,9 @@ class CsuMarketSystem_OpteMais_Adminhtml_Optemais_CampaignController extends Mag
46
  return false;
47
  }
48
  }
49
-
50
  $this->loadLayout()
51
  ->_setActiveMenu('promo')
52
- ->_addBreadcrumb(Mage::helper('optemais')->__('Adicionar itens à Campanha OPTe+'), Mage::helper('optemais')->__('Adicionar Itens à Campanha OPTe+'))
53
  ->_addContent($this->getLayout()->createBlock('optemais/adminhtml_campaign_item'))
54
  ->renderLayout();
55
  }
@@ -61,8 +56,12 @@ class CsuMarketSystem_OpteMais_Adminhtml_Optemais_CampaignController extends Mag
61
  if ($this->getRequest()->getParam('action') == CsuMarketSystem_OpteMais_Model_Source_Campaign_Actions::ACTION_EXISTING) {
62
  try {
63
  $campaignId = $this->getRequest()->getParam('campaign');
64
- $campaign->addItemToCampaign($this->getRequest(), $campaignId);
65
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('optemais')->__('Itens adicionados à campanha com sucesso'));
 
 
 
 
66
  } catch (Exception $e) {
67
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
68
  }
@@ -268,9 +267,4 @@ class CsuMarketSystem_OpteMais_Adminhtml_Optemais_CampaignController extends Mag
268
  die;
269
  }
270
 
271
- private function _validateProducts($products)
272
- {
273
- return true;
274
- }
275
-
276
  }
18
  {
19
  return Mage::getSingleton('admin/session')->isAllowed('admin/promo/optemais_campaign');
20
  }
21
+
22
  public function addItemsAction()
23
  {
 
 
 
 
 
24
  $products = $this->getRequest()->getParam('product');
25
  if (!is_array($products)) {
26
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('optemais')->__('Selecione pelo menos um produto'));
28
  return false;
29
  } else {
30
  try {
31
+ /** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
32
+ $productCollection = Mage::getModel('catalog/product')->getCollection();
33
+ $productCollection->addIdFilter($products);
34
+ $productCollection->addAttributeToFilter('type_id','simple');
35
+ $count = $productCollection->getSize();
36
+ if($count != count($products)) {
37
+ throw new Exception(Mage::helper('optemais')->__('Utilize somente [Produtos Simples] para Campanhas'));
38
  }
39
  } catch (Exception $e) {
40
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
42
  return false;
43
  }
44
  }
 
45
  $this->loadLayout()
46
  ->_setActiveMenu('promo')
47
+ ->_addBreadcrumb(Mage::helper('optemais')->__('Adicionar itens à Campanha OPTe+'), Mage::helper('optemais')->__('Adicionar itens à Campanha OPTe+'))
48
  ->_addContent($this->getLayout()->createBlock('optemais/adminhtml_campaign_item'))
49
  ->renderLayout();
50
  }
56
  if ($this->getRequest()->getParam('action') == CsuMarketSystem_OpteMais_Model_Source_Campaign_Actions::ACTION_EXISTING) {
57
  try {
58
  $campaignId = $this->getRequest()->getParam('campaign');
59
+ if($campaign->validateProducts($this->getRequest(),$campaignId)) {
60
+ $campaign->addItemToCampaign($this->getRequest(), $campaignId);
61
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('optemais')->__('Itens adicionados à campanha com sucesso'));
62
+ } else {
63
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('optemais')->__('Alguns dos itens já existem nessa campanha'));
64
+ }
65
  } catch (Exception $e) {
66
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
67
  }
267
  die;
268
  }
269
 
 
 
 
 
 
270
  }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>CsuMarketSystem_OpteMais</name>
4
- <version>1.2.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
@@ -10,11 +10,12 @@
10
  <description>Tenha sua loja totalmente integrada com o maior e mais completo Shopping de E-Commerce.&#xD;
11
  &#xD;
12
  Para mais informa&#xE7;&#xF5;es: www.optemais.com.br.</description>
13
- <notes>- Ajuste para carregar pre&#xE7;o do produto pai na consulta online (getProductBySku).</notes>
14
- <authors><author><name>csumarketsystem</name><user>MAG003432004</user><email>integracaomagento@csu.com.br</email></author></authors>
15
- <date>2016-06-23</date>
16
- <time>19:58:14</time>
17
- <contents><target name="magecommunity"><dir><dir name="CsuMarketSystem"><dir name="OpteMais"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Campaign"><dir name="Edit"><file name="Form.php" hash="0224ccec20310daa354451bdb885ed94"/><dir name="Tab"><file name="Form.php" hash="b6420075c95c1fac234d6693c554b1b0"/><dir name="Product"><file name="Grid.php" hash="f807064e42b11f90736d7a9dca6e2e32"/></dir></dir><file name="Tabs.php" hash="6192f47626cae96918725c265de897eb"/></dir><file name="Edit.php" hash="5fb37aa5528c5bc139bb63126367ebd8"/><file name="Grid.php" hash="88ca48431fecc2500781f49c00c91020"/><dir name="Item"><dir name="Edit"><file name="Form.php" hash="16e4a16e4462309f91ced2eabf30dcf8"/></dir></dir><file name="Item.php" hash="b4c60842f3a73b173ffb9145c178549a"/></dir><file name="Campaign.php" hash="44884ffbc6464f2d95031f45db33dc85"/><file name="Paymentmethod.php" hash="820e3a125362a300c8fca3974e362ba2"/></dir><dir name="Payment"><dir name="Info"><file name="Modelc.php" hash="0a84f429477de898996b0235b65c20ca"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7a1db5b05bc92cca0f1b4ce4fd3b9aec"/></dir><dir name="Model"><file name="Abstract.php" hash="bf404d2900f5da8c166905ae974344d5"/><dir name="Auth"><dir name="Adapter"><file name="Http.php" hash="849b630e8ce379aee56f967d2b65129f"/></dir></dir><dir name="Campaign"><file name="Item.php" hash="76ee48d568206a365b353b25e923ca02"/></dir><file name="Campaign.php" hash="5a68924b6446fa4a1b3b8c06167dfe80"/><dir name="Estimate"><file name="Rate.php" hash="7ab5fc907916144492899e0a526a29ae"/></dir><file name="Observer.php" hash="d40e07a79f07a1d0617ea97a94ec42a6"/><file name="Order.php" hash="62dd398643016e95679547ffc7c7d27b"/><dir name="Payment"><file name="Modelc.php" hash="112fb964895c98495a5a88b580b2720e"/></dir><file name="Product.php" hash="be551808cf41c69cfcc742719eee8dc8"/><dir name="Resource"><dir name="Campaign"><file name="Collection.php" hash="e795201d0f518e5e231a69ed4b4016a4"/><dir name="Item"><file name="Collection.php" hash="4e37c2359c649fd9d8a64df7b1ff6915"/></dir><file name="Item.php" hash="8dbba236eda0e15f01b53df639594f63"/></dir><file name="Campaign.php" hash="8d92b66c14476101b684d3bf2f19d985"/></dir><file name="Response.php" hash="46c92e2fde679ce9c68a089143ce9d55"/><file name="Shipping.php" hash="5a3a24a9cb3a76b62ec8b2ca8b4e2be6"/><dir name="Source"><file name="Attributes.php" hash="a81b2d8547f98268942f9aa5579270b6"/><dir name="Campaign"><file name="Actions.php" hash="be6831dec28e0eac7681fc0cb08cf5bc"/><file name="Statuses.php" hash="e614d614d0a49086693f2a2c28e75158"/></dir><dir name="Customer"><file name="Attributes.php" hash="492032dbe0f81c25d712a50ae123f52d"/></dir><dir name="Select"><file name="Attributes.php" hash="e0761b838ed646a96cc1e7cb80f4fdf0"/></dir><dir name="Shipping"><file name="Pricetype.php" hash="4580b8399fddcad4d6d9a6af9f5a5314"/></dir><file name="Shippingmethods.php" hash="b339f7c3f90f15a8b95f4d3b5d2ecb2c"/><file name="Stores.php" hash="6768255eaacb89d9c72ee8e0e3a232a8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Optemais"><file name="CampaignController.php" hash="c3b2ddc1554f291a8d32e57d20bf561a"/></dir></dir><dir name="Api"><file name="OrderController.php" hash="ede2f74890e94f8ee15aa34c9347e5ce"/><file name="ProductController.php" hash="f3c88c8f09d6be7df71af47025e1b4ee"/><file name="ShippingController.php" hash="e78e99c63e183872aca0e7b48f590b14"/></dir><file name="ApiController.php" hash="7893369fc96e4c9ebab1048dc49d9241"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5b9452d590d86a1f072b47f772c2d1ff"/><file name="config.xml" hash="918b856f0a8980f7e912a3f34e2effb1"/><file name="system.xml" hash="f07bb682cc190e4425e3987800eaf667"/></dir><dir name="sql"><dir name="optemais_setup"><file name="mysql4-install-1.0.0.php" hash="319a1b52745b3c20622346e197854842"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="79f1694a928ea66c85aef99d443fe06c"/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="optemais"><dir><dir name="payment"><dir name="info"><file name="modelc.phtml" hash="6c2e5bb34b9ae9c97c291fa3bb9c759f"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="CsuMarketSystem_OpteMais.xml" hash="cf6ea247e3b860f2dac4758ac643a767"/></dir></dir></target></contents>
 
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>CsuMarketSystem_OpteMais</name>
4
+ <version>1.2.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
10
  <description>Tenha sua loja totalmente integrada com o maior e mais completo Shopping de E-Commerce.&#xD;
11
  &#xD;
12
  Para mais informa&#xE7;&#xF5;es: www.optemais.com.br.</description>
13
+ <notes>- Ajuste para adicionar m&#xFA;ltiplos produtos &#xE0; campanha de forma otimizada;&#xD;
14
+ - Valida&#xE7;&#xE3;o para n&#xE3;o deixar adicionar produto j&#xE1; existente em uma campanha.</notes>
15
+ <authors><author><name>csumarketsystem</name><user>MAG003432004</user><email>pluginoptemais@csu.com.br</email></author></authors>
16
+ <date>2016-07-18</date>
17
+ <time>12:52:52</time>
18
+ <contents><target name="magecommunity"><dir><dir name="CsuMarketSystem"><dir name="OpteMais"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Campaign"><dir name="Edit"><file name="Form.php" hash="0224ccec20310daa354451bdb885ed94"/><dir name="Tab"><file name="Form.php" hash="b6420075c95c1fac234d6693c554b1b0"/><dir name="Product"><file name="Grid.php" hash="f807064e42b11f90736d7a9dca6e2e32"/></dir></dir><file name="Tabs.php" hash="6192f47626cae96918725c265de897eb"/></dir><file name="Edit.php" hash="5fb37aa5528c5bc139bb63126367ebd8"/><file name="Grid.php" hash="88ca48431fecc2500781f49c00c91020"/><dir name="Item"><dir name="Edit"><file name="Form.php" hash="16e4a16e4462309f91ced2eabf30dcf8"/></dir></dir><file name="Item.php" hash="b4c60842f3a73b173ffb9145c178549a"/></dir><file name="Campaign.php" hash="44884ffbc6464f2d95031f45db33dc85"/><file name="Paymentmethod.php" hash="bb307881cd64c14c15e2f5f7c89fb466"/></dir><dir name="Payment"><dir name="Info"><file name="Modelc.php" hash="0a84f429477de898996b0235b65c20ca"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7a1db5b05bc92cca0f1b4ce4fd3b9aec"/></dir><dir name="Model"><file name="Abstract.php" hash="bf404d2900f5da8c166905ae974344d5"/><dir name="Auth"><dir name="Adapter"><file name="Http.php" hash="849b630e8ce379aee56f967d2b65129f"/></dir></dir><dir name="Campaign"><file name="Item.php" hash="76ee48d568206a365b353b25e923ca02"/></dir><file name="Campaign.php" hash="88e6b37ee7710e604900ef7e7b33b4da"/><dir name="Estimate"><file name="Rate.php" hash="7ab5fc907916144492899e0a526a29ae"/></dir><file name="Observer.php" hash="d40e07a79f07a1d0617ea97a94ec42a6"/><file name="Order.php" hash="62dd398643016e95679547ffc7c7d27b"/><dir name="Payment"><file name="Modelc.php" hash="112fb964895c98495a5a88b580b2720e"/></dir><file name="Product.php" hash="be551808cf41c69cfcc742719eee8dc8"/><dir name="Resource"><dir name="Campaign"><file name="Collection.php" hash="e795201d0f518e5e231a69ed4b4016a4"/><dir name="Item"><file name="Collection.php" hash="4e37c2359c649fd9d8a64df7b1ff6915"/></dir><file name="Item.php" hash="8dbba236eda0e15f01b53df639594f63"/></dir><file name="Campaign.php" hash="8d92b66c14476101b684d3bf2f19d985"/></dir><file name="Response.php" hash="46c92e2fde679ce9c68a089143ce9d55"/><file name="Shipping.php" hash="5a3a24a9cb3a76b62ec8b2ca8b4e2be6"/><dir name="Source"><file name="Attributes.php" hash="a81b2d8547f98268942f9aa5579270b6"/><dir name="Campaign"><file name="Actions.php" hash="be6831dec28e0eac7681fc0cb08cf5bc"/><file name="Statuses.php" hash="e614d614d0a49086693f2a2c28e75158"/></dir><dir name="Customer"><file name="Attributes.php" hash="492032dbe0f81c25d712a50ae123f52d"/></dir><dir name="Select"><file name="Attributes.php" hash="e0761b838ed646a96cc1e7cb80f4fdf0"/></dir><dir name="Shipping"><file name="Pricetype.php" hash="4580b8399fddcad4d6d9a6af9f5a5314"/></dir><file name="Shippingmethods.php" hash="b339f7c3f90f15a8b95f4d3b5d2ecb2c"/><file name="Stores.php" hash="6768255eaacb89d9c72ee8e0e3a232a8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Optemais"><file name="CampaignController.php" hash="7c2a76bb67fe4238a47e3fc0de5501bd"/></dir></dir><dir name="Api"><file name="OrderController.php" hash="ede2f74890e94f8ee15aa34c9347e5ce"/><file name="ProductController.php" hash="f3c88c8f09d6be7df71af47025e1b4ee"/><file name="ShippingController.php" hash="e78e99c63e183872aca0e7b48f590b14"/></dir><file name="ApiController.php" hash="7893369fc96e4c9ebab1048dc49d9241"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5b9452d590d86a1f072b47f772c2d1ff"/><file name="config.xml" hash="918b856f0a8980f7e912a3f34e2effb1"/><file name="system.xml" hash="f07bb682cc190e4425e3987800eaf667"/></dir><dir name="sql"><dir name="optemais_setup"><file name="mysql4-install-1.0.0.php" hash="319a1b52745b3c20622346e197854842"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="79f1694a928ea66c85aef99d443fe06c"/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="optemais"><dir><dir name="payment"><dir name="info"><file name="modelc.phtml" hash="6c2e5bb34b9ae9c97c291fa3bb9c759f"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="CsuMarketSystem_OpteMais.xml" hash="cf6ea247e3b860f2dac4758ac643a767"/></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
21
  </package>