clever_adwords - Version 1.0.4

Version Notes

Fixed minor bugs

Download this release

Release Info

Developer Rodrigo
Extension clever_adwords
Version 1.0.4
Comparing to
See all releases


Code changes from version 1.0.3 to 1.0.4

app/code/local/Rodrigo/Munoz/controllers/Adminhtml/IndexController.php CHANGED
@@ -384,11 +384,11 @@ class Rodrigo_Munoz_Adminhtml_IndexController extends Mage_Adminhtml_Controller_
384
  if($wholekeyword['budget']){
385
  $collection =Mage::getModel('munoz/keyword')->getCollection();
386
  $collection->addFieldToFilter('keyword_title','complete');
387
- if(count($collection) >0){
388
  return true;
389
  }
390
  else{
391
- require_once 'shell/createInstance.php';
392
  exec('php -f createInstance.php > /dev/null 2>&1 &');
393
  }
394
  }
384
  if($wholekeyword['budget']){
385
  $collection =Mage::getModel('munoz/keyword')->getCollection();
386
  $collection->addFieldToFilter('keyword_title','complete');
387
+ if(count($collection) > 0){
388
  return true;
389
  }
390
  else{
391
+ require('shell/createInstance.php');
392
  exec('php -f createInstance.php > /dev/null 2>&1 &');
393
  }
394
  }
app/design/adminhtml/default/default/template/munoz/waiting.phtml CHANGED
@@ -13,33 +13,6 @@
13
  */
14
 
15
  ?>
16
-
17
- <?php
18
- //require_once 'shell/defaultAttribute.php';
19
- //$arra_attrcode=array();
20
- //$count=0;
21
- //$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
22
- //foreach($attributes as $attcode){
23
- //
24
- // if(!in_array($attcode->getAttributecode(),getDefaultAttribute())){
25
- // if($count <51){
26
- // foreach(Mage::getModel('catalog/product')->getCollection() as $product)
27
- // {
28
- // $product = Mage::getModel('catalog/product')->load($product->getProductId());
29
- // $my_attribute = $product->getAttributeText($attcode->getAttributecode());
30
- // if($my_attribute){
31
- // $arra_attrcode=$attcode->getAttributecode();
32
- // }
33
- //
34
- // }
35
- // $count++;
36
- // }
37
- // }
38
- // }
39
- //print_r($arra_attrcode);
40
- //
41
- //die();
42
- ?>
43
  <div id="waitting_for_creation">
44
  <center>
45
  <br><br>
13
  */
14
 
15
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  <div id="waitting_for_creation">
17
  <center>
18
  <br><br>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>clever_adwords</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
@@ -21,9 +21,9 @@ No work from your side, &lt;b&gt;we will upload all campaigns for you.&lt;/b&gt;
21
  &lt;h2&gt;</description>
22
  <notes>Fixed minor bugs</notes>
23
  <authors><author><name>Rodrigo</name><user>Rodrigo</user><email>rodrigo@cleverppc.com</email></author></authors>
24
- <date>2016-08-09</date>
25
- <time>12:45:01</time>
26
- <contents><target name="magelocal"><dir name="Rodrigo"><dir name="Munoz"><dir name="Block"><dir name="Adminhtml"><file name="Form.php" hash="54444c96513238d9c562c540f9d94916"/></dir></dir><dir name="Helper"><file name="Data.php" hash="fc1bcf8c0fb907db2a545ca518af1fcf"/></dir><dir name="Model"><file name="Keyword.php" hash="f0e4ff03e65f91ff5b24e3246e9e3636"/><dir name="Mysql4"><dir name="Keyword"><file name="Collection.php" hash="5e74a7fc484cb68f003d8d843fad7852"/></dir><file name="Keyword.php" hash="b3ff64494c92d5ca070ebf0a33d2c072"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExcelsheetController.php" hash="0fb1074059edf54c21413cb215175ff4"/><file name="IndexController.php" hash="5edbf86a9f2599ed9088a4ecab7f6591"/></dir><file name="IndexController.php" hash="fa73f9ae7feb2e3fa80edea3e8774838"/></dir><dir name="etc"><file name="adminhtml.xml" hash="cdf47fa749068b411c2704fda8eb4444"/><file name="config.xml" hash="516d1ae5dcdf5cb9ce5bdba33c540a1c"/><file name="system.xml" hash="b1eec31001ae641320cc79f86a62f760"/></dir><dir name="sql"><dir name="keyword_setup"><file name="mysql4-install-0.1.0.php" hash="854409a2d6bff834005798d4d0368f54"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rodrigo_Munoz.xml" hash="6b1a61c409f48a95f87c61d678a26a42"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="munoz.xml" hash="5855ebab13f8e3da65c4fe4e9a3f1e2c"/></dir><dir name="template"><dir name="munoz"><file name="accurate.phtml" hash="68b76695cc680381d808c0c82fa54a18"/><file name="dashboard.phtml" hash="771ef9cedfed14f9cd500e1010ff6a34"/><file name="form.phtml" hash="8cd9e5f3009cb70449b597ae0e71d9e6"/><file name="step1.phtml" hash="538a3e757cba14cb58185459fb4fd976"/><file name="step2.phtml" hash="3fca6072ed0de6face5a14f5868b57ab"/><file name="step3.phtml" hash="851a245ca5f910653644fcbe2ef27d41"/><file name="step4.phtml" hash="ed94768698daf4e4333624f5ed980402"/><file name="step5.phtml" hash="016382faed88f6a64456d5997a3036aa"/><file name="switch.phtml" hash="0b4affaa8e4e9bfb78d1ed36a6ae1c8f"/><file name="waiting.phtml" hash="b333ce7bb744aa01a669597efd088ea6"/><file name="welcome.phtml" hash="956926f7fa15775f0755f59533f2dbe9"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir><dir name="template"><dir name="munoz"><dir name="google"><dir name="adwords"><file name="conversion.phtml" hash="fcea58042d20c6f8c7b3d0b845f99134"/><file name="remarket_tag.phtml" hash="69d3c79cc68eebd3f79455e32576c0db"/></dir></dir></dir></dir></dir><dir name="layout"><file name="ro.xml" hash="ad1086f90d433a59d51823be9110ecee"/></dir></dir></dir></dir></target><target name="magemedia"><dir name="munoz"><file name="Selecci&#xF3;n_007.png" hash="a7f34f0918bd15ad6e5fe3c103433d58"/><file name="ads_tips.png" hash="555cc05f3b14b7cfb089cb6bf0fe4900"/><file name="adwords-logo.png" hash="fbfcea42be8bdc62b1ca559dc72bbd5e"/><file name="adwords-screen.png" hash="6261a10c000b75b2b7b6e22307a4e5e5"/><file name="adwords-symbol.png" hash="90a1ce04aa7bc5e82594677d2b7aa119"/><file name="age.png" hash="fb7b4011e56345875426191d470cb9c1"/><file name="checked_rmkt.png" hash="2136fb7110ae7fe6fa64f170c036451f"/><file name="computer.png" hash="614895299f0ff062326222284969f66b"/><file name="devices.png" hash="7f0ea3c3260ee54fe266f2c13ae6704b"/><file name="female.png" hash="95ee4dcaef28e8422e0f4966253d6c2c"/><file name="gender.png" hash="96fe85bd81be701de76bec1236b26226"/><file name="ico1.png" hash="deea6977b369c8a252db6c7ad70b13c9"/><file name="ico2.png" hash="258381acb1c2829660fe78916fa7f7b1"/><file name="ico4.png" hash="df8e0052bea21c4fdcac45cbb6b11f00"/><file name="ico5.png" hash="fd197c3807a51238958d83b1986ac47a"/><file name="imgpsh_fullsize.png" hash="a9de1d69724f0cd96727045ea9403992"/><file name="keywords.png" hash="075655566b7b7abe2cf36d12f1aa6ca9"/><file name="logo.png" hash="55c45b86a18f3c94e1dbd70af8db2487"/><file name="male.png" hash="c71923fdae30561fb1cb7d3a3db10809"/><file name="mobile.png" hash="9a0c157149bdccf33b92e556e4442cc3"/><file name="old-adwords-screen.png" hash="cef9f147366c521f4e089d049128a21c"/><file name="rockstar.png" hash="6d88b35fbeba82088f8969215aca88a3"/><file name="wait.png" hash="946052e085a5c60fc71f3c716fb806c1"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="munoz"><dir name="css"><file name="ad-icon.jpg" hash="b87496c052b306a94eabf5af3544a717"/><file name="adwords-symbol.png" hash="90a1ce04aa7bc5e82594677d2b7aa119"/><file name="font-awesome.css" hash="b652e3b759188ceaf79182f2fe72ea64"/><file name="font-awesome.min.css" hash="4083f5d376eb849a458cc790b53ba080"/><file name="imgpsh_fullsize.png" hash="a9de1d69724f0cd96727045ea9403992"/><file name="jquery-ui.css" hash="b50192cf9c90fe83462ce9a7bcdd29c7"/><file name="jquery.steps.css" hash="5a25f593fe74b7d73a3c2a4212ac6612"/><file name="main.css" hash="aa03751cf9078dc47675f907e22bd2a5"/><file name="progress-bar.png" hash="bd5b9782b845486917de1b1e9fc2c631"/><file name="simple_container_bg.gif" hash="56f1ac91169eb4896b8c91384fc8bf15"/><file name="styles.css" hash="102a0ff89ef27e400b9df25de82e053e"/></dir><dir name="fonts"><file name="FontAwesome.otf" hash="5dc41d8fe329a22fa1ee9225571c843e"/><file name="fontawesome-webfont.eot" hash="25a32416abee198dd821b0b17a198a8f"/><file name="fontawesome-webfont.svg" hash="d7c639084f684d66a1bc66855d193ed8"/><file name="fontawesome-webfont.ttf" hash="1dc35d25e61d819a9c357074014867ab"/><file name="fontawesome-webfont.woff" hash="c8ddf1e5e5bf3682bc7bebf30f394148"/><file name="fontawesome-webfont.woff2" hash="e6cf7c6ec7c2d6f670ae9d762604cb0b"/></dir><dir name="images"><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="delete_dust.png" hash="948ef1640b50d09d385597f967e6ebc1"/><file name="elbow-end-minus-nl.gif" hash="6dc08c43109cc6a365bd0270f05e2f1c"/><file name="elbow-end-minus.gif" hash="3dbdb88a9297fe5631e832f046b0350b"/><file name="elbow-end-plus-nl.gif" hash="6dc08c43109cc6a365bd0270f05e2f1c"/><file name="elbow-end-plus.gif" hash="5470e5712a9742ba666c26cb429baaeb"/><file name="elbow-end.gif" hash="63fe879440e2784e0cc0d316ce017745"/><file name="elbow-line.gif" hash="b316a39455304e20e01dbc437f57fd32"/><file name="elbow-minus-nl.gif" hash="0e3129bff70475c8f7f297e0e59d1608"/><file name="elbow-minus.gif" hash="e7b18ff6800e65c6e171bbb2a911762e"/><file name="elbow-plus-nl.gif" hash="78a8f737941fa658f1e770258a3791cd"/><file name="elbow-plus.gif" hash="b02cb264df55aef2105b1b245d075e56"/><file name="elbow.gif" hash="b6bd0e0237e3cd413fa2dac27701c724"/><file name="elbow_minus.png" hash="3fc01d7af6d0f10fb6ea321f85cfc4ce"/><file name="elbow_plus.png" hash="1deaa077bfe1c95f161e323aae1dc989"/><file name="folder-open.gif" hash="e3cd196406d4857dc0c926807f16c409"/><file name="folder.gif" hash="03eb26c42137ac792609822862ef4d0f"/><file name="keywords.png" hash="075655566b7b7abe2cf36d12f1aa6ca9"/><file name="leaf.gif" hash="e3cd196406d4857dc0c926807f16c409"/><file name="loading.gif" hash="00ef871b291bc03a497d608a5bd8ec99"/><file name="loading.png" hash="be5a561a53b5efe2e464f5acb811e90e"/><file name="s.gif" hash="df3e567d6f16d040326c7a0ea29a4f41"/><file name="simple_container_bg.gif" hash="56f1ac91169eb4896b8c91384fc8bf15"/><file name="styles.css" hash="73525c4881f2048bf59a594c61de3e09"/></dir><dir name="js"><dir name="build"><file name="jQuery.Steps.1.1.0.nupkg" hash="979939a5151179f40ab6883ea12cfbc4"/><file name="jquery.easyswitch.js" hash="9262c7cd4cd062a7b40d6e6ca65e3471"/><file name="jquery.steps-1.1.0.zip" hash="f446d606df167069be7718434b11ff55"/><file name="jquery.steps.js" hash="5a38905c075292e628c3e9453875b65d"/><file name="jquery.steps.min.js" hash="4c5e9f4e84d32b7df69af7420b355e03"/></dir><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-1.11.1.min.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-1.9.1.min.js" hash="663628f795cb62444143fde1ebdf2b5b"/><file name="jquery.cookie-1.3.1.js" hash="e5937111b7dc83385e3f4c7b91af7a80"/><file name="jquery.easyswitch.js" hash="70b67fe638e45f2b0f4ba978a4baa785"/><file name="modernizr-2.6.2.min.js" hash="42306a279a9e831515347ae319181cd1"/><file name="priceslider.js" hash="94827683d2169636ed208b023624cfb4"/></dir><dir name="less"><file name="animated.less" hash="08baef05e05301cabc91599a54921081"/><file name="bordered-pulled.less" hash="898f90e40876883214bbd121b0c20e9f"/><file name="core.less" hash="fb4efe4ae63737706875bbbfc7b7e9af"/><file name="fixed-width.less" hash="5e07ec001f8d21bd279c12ee542813f7"/><file name="font-awesome.less" hash="f53235946c37e394a6cd6d92f84587a8"/><file name="icons.less" hash="3c3bb8fbcd54a6b66a41137d5e9e8a33"/><file name="larger.less" hash="8cb65280c0f889daf72626c21a7c8628"/><file name="list.less" hash="975571323cf880a4a30601998236b027"/><file name="mixins.less" hash="fbb1f2f1ab96ba020c7f14208aac72b8"/><file name="path.less" hash="a8c41460c42a4fe9e98550f00c8b3f19"/><file name="rotated-flipped.less" hash="a8476cdc50c264abd11ff59d6a9dd025"/><file name="screen-reader.less" hash="0f881617264587bef0df6ce92253ecea"/><file name="stacked.less" hash="518e2b2d263982d2caa1e6514b4b4eac"/><file name="variables.less" hash="45fa411bbd22ff8467e027318a88a557"/></dir><file name="loader_new.jpg" hash="e02968245a670ef65a06411a442e557a"/><dir name="scss"><file name="_animated.scss" hash="39ff4f359a7b81d6585075715f41e5dc"/><file name="_bordered-pulled.scss" hash="4cad0df17bf40327feae33fa9a6c6ba2"/><file name="_core.scss" hash="ef059a98cf9de6ca5b77ee6850771cf0"/><file name="_fixed-width.scss" hash="9277ab6964a434d499873687b00be906"/><file name="_icons.scss" hash="fdffb08bc3d85c7427d8697f268fb072"/><file name="_larger.scss" hash="e95931566f6fc6ad5685c4fa9802e206"/><file name="_list.scss" hash="7107e80b053928271d5fcf422dc29490"/><file name="_mixins.scss" hash="aa2b8f32b403733713d8885f14ab86cc"/><file name="_path.scss" hash="ab5a9e8388563e097b5ce835601f01d2"/><file name="_rotated-flipped.scss" hash="9f5d4bc6fadea89328d2aac26574a9d8"/><file name="_screen-reader.scss" hash="8907bd7dbf4799e8120bda5568d76fea"/><file name="_stacked.scss" hash="5594237226aedfbca2fa1c7f4604c214"/><file name="_variables.scss" hash="783d4422626a7f27fa8f513de3ad4795"/><file name="font-awesome.scss" hash="ace7fb9336021f92b1cf68a10d5f452c"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="shell"><file name="createInstance.php" hash="b4b3a9ae320946be6bdf09a0a8ec2205"/><file name="abstracts.php" hash="e92717fb78260959ef9de93f63b80fb2"/><file name="countryLanguadge.php" hash="0f6cdd3496a6b9f4122af672044f11f2"/><file name="defaultAttribute.php" hash="5722718990361cb1c0c4c4e1d8fdc510"/></dir><dir name="js"><dir name="munoz"><dir name="build"><file name="jQuery.Steps.1.1.0.nupkg" hash="979939a5151179f40ab6883ea12cfbc4"/><file name="jquery.easyswitch.js" hash="9262c7cd4cd062a7b40d6e6ca65e3471"/><file name="jquery.steps-1.1.0.zip" hash="f446d606df167069be7718434b11ff55"/><file name="jquery.steps.js" hash="5a38905c075292e628c3e9453875b65d"/><file name="jquery.steps.min.js" hash="4c5e9f4e84d32b7df69af7420b355e03"/></dir><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-1.11.1.min.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-1.9.1.min.js" hash="663628f795cb62444143fde1ebdf2b5b"/><file name="jquery.cookie-1.3.1.js" hash="e5937111b7dc83385e3f4c7b91af7a80"/><file name="jquery.easyswitch.js" hash="70b67fe638e45f2b0f4ba978a4baa785"/><dir name="js"><dir name="build"><file name="jQuery.Steps.1.1.0.nupkg" hash="979939a5151179f40ab6883ea12cfbc4"/><file name="jquery.easyswitch.js" hash="9262c7cd4cd062a7b40d6e6ca65e3471"/><file name="jquery.steps-1.1.0.zip" hash="f446d606df167069be7718434b11ff55"/><file name="jquery.steps.js" hash="5a38905c075292e628c3e9453875b65d"/><file name="jquery.steps.min.js" hash="4c5e9f4e84d32b7df69af7420b355e03"/></dir><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-1.11.1.min.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-1.9.1.min.js" hash="663628f795cb62444143fde1ebdf2b5b"/><file name="jquery.cookie-1.3.1.js" hash="e5937111b7dc83385e3f4c7b91af7a80"/><file name="jquery.easyswitch.js" hash="70b67fe638e45f2b0f4ba978a4baa785"/><file name="modernizr-2.6.2.min.js" hash="42306a279a9e831515347ae319181cd1"/><file name="priceslider.js" hash="94827683d2169636ed208b023624cfb4"/></dir><file name="modernizr-2.6.2.min.js" hash="42306a279a9e831515347ae319181cd1"/><file name="priceslider.js" hash="94827683d2169636ed208b023624cfb4"/></dir></dir></target><target name="magelib"><dir name="rollbar"><file name="Level.php" hash="fbe1e94a42be5a3a45b24350b176ccf4"/><file name="rollbar.php" hash="462cec30ca3fb320dd8360b2f03d9da4"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
29
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>clever_adwords</name>
4
+ <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
21
  &lt;h2&gt;</description>
22
  <notes>Fixed minor bugs</notes>
23
  <authors><author><name>Rodrigo</name><user>Rodrigo</user><email>rodrigo@cleverppc.com</email></author></authors>
24
+ <date>2016-08-30</date>
25
+ <time>13:07:30</time>
26
+ <contents><target name="magelocal"><dir name="Rodrigo"><dir name="Munoz"><dir name="Block"><dir name="Adminhtml"><file name="Form.php" hash="54444c96513238d9c562c540f9d94916"/></dir></dir><dir name="Helper"><file name="Data.php" hash="fc1bcf8c0fb907db2a545ca518af1fcf"/></dir><dir name="Model"><file name="Keyword.php" hash="f0e4ff03e65f91ff5b24e3246e9e3636"/><dir name="Mysql4"><dir name="Keyword"><file name="Collection.php" hash="5e74a7fc484cb68f003d8d843fad7852"/></dir><file name="Keyword.php" hash="b3ff64494c92d5ca070ebf0a33d2c072"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExcelsheetController.php" hash="0fb1074059edf54c21413cb215175ff4"/><file name="IndexController.php" hash="fc934054dc9f8667892f7005e86a4b62"/></dir><file name="IndexController.php" hash="fa73f9ae7feb2e3fa80edea3e8774838"/></dir><dir name="etc"><file name="adminhtml.xml" hash="cdf47fa749068b411c2704fda8eb4444"/><file name="config.xml" hash="516d1ae5dcdf5cb9ce5bdba33c540a1c"/><file name="system.xml" hash="b1eec31001ae641320cc79f86a62f760"/></dir><dir name="sql"><dir name="keyword_setup"><file name="mysql4-install-0.1.0.php" hash="854409a2d6bff834005798d4d0368f54"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rodrigo_Munoz.xml" hash="6b1a61c409f48a95f87c61d678a26a42"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="munoz.xml" hash="5855ebab13f8e3da65c4fe4e9a3f1e2c"/></dir><dir name="template"><dir name="munoz"><file name="accurate.phtml" hash="68b76695cc680381d808c0c82fa54a18"/><file name="dashboard.phtml" hash="771ef9cedfed14f9cd500e1010ff6a34"/><file name="form.phtml" hash="8cd9e5f3009cb70449b597ae0e71d9e6"/><file name="step1.phtml" hash="538a3e757cba14cb58185459fb4fd976"/><file name="step2.phtml" hash="3fca6072ed0de6face5a14f5868b57ab"/><file name="step3.phtml" hash="851a245ca5f910653644fcbe2ef27d41"/><file name="step4.phtml" hash="ed94768698daf4e4333624f5ed980402"/><file name="step5.phtml" hash="016382faed88f6a64456d5997a3036aa"/><file name="switch.phtml" hash="0b4affaa8e4e9bfb78d1ed36a6ae1c8f"/><file name="waiting.phtml" hash="81cc9b8b1f4a6d76e8c84a59713c8f2c"/><file name="welcome.phtml" hash="956926f7fa15775f0755f59533f2dbe9"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir><dir name="template"><dir name="munoz"><dir name="google"><dir name="adwords"><file name="conversion.phtml" hash="fcea58042d20c6f8c7b3d0b845f99134"/><file name="remarket_tag.phtml" hash="69d3c79cc68eebd3f79455e32576c0db"/></dir></dir></dir></dir></dir><dir name="layout"><file name="ro.xml" hash="ad1086f90d433a59d51823be9110ecee"/></dir></dir></dir></dir></target><target name="magemedia"><dir name="munoz"><file name="Selecci&#xF3;n_007.png" hash="a7f34f0918bd15ad6e5fe3c103433d58"/><file name="ads_tips.png" hash="555cc05f3b14b7cfb089cb6bf0fe4900"/><file name="adwords-logo.png" hash="fbfcea42be8bdc62b1ca559dc72bbd5e"/><file name="adwords-screen.png" hash="6261a10c000b75b2b7b6e22307a4e5e5"/><file name="adwords-symbol.png" hash="90a1ce04aa7bc5e82594677d2b7aa119"/><file name="age.png" hash="fb7b4011e56345875426191d470cb9c1"/><file name="checked_rmkt.png" hash="2136fb7110ae7fe6fa64f170c036451f"/><file name="computer.png" hash="614895299f0ff062326222284969f66b"/><file name="devices.png" hash="7f0ea3c3260ee54fe266f2c13ae6704b"/><file name="female.png" hash="95ee4dcaef28e8422e0f4966253d6c2c"/><file name="gender.png" hash="96fe85bd81be701de76bec1236b26226"/><file name="ico1.png" hash="deea6977b369c8a252db6c7ad70b13c9"/><file name="ico2.png" hash="258381acb1c2829660fe78916fa7f7b1"/><file name="ico4.png" hash="df8e0052bea21c4fdcac45cbb6b11f00"/><file name="ico5.png" hash="fd197c3807a51238958d83b1986ac47a"/><file name="imgpsh_fullsize.png" hash="a9de1d69724f0cd96727045ea9403992"/><file name="keywords.png" hash="075655566b7b7abe2cf36d12f1aa6ca9"/><file name="logo.png" hash="55c45b86a18f3c94e1dbd70af8db2487"/><file name="male.png" hash="c71923fdae30561fb1cb7d3a3db10809"/><file name="mobile.png" hash="9a0c157149bdccf33b92e556e4442cc3"/><file name="old-adwords-screen.png" hash="cef9f147366c521f4e089d049128a21c"/><file name="rockstar.png" hash="6d88b35fbeba82088f8969215aca88a3"/><file name="wait.png" hash="946052e085a5c60fc71f3c716fb806c1"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="munoz"><dir name="css"><file name="ad-icon.jpg" hash="b87496c052b306a94eabf5af3544a717"/><file name="adwords-symbol.png" hash="90a1ce04aa7bc5e82594677d2b7aa119"/><file name="font-awesome.css" hash="b652e3b759188ceaf79182f2fe72ea64"/><file name="font-awesome.min.css" hash="4083f5d376eb849a458cc790b53ba080"/><file name="imgpsh_fullsize.png" hash="a9de1d69724f0cd96727045ea9403992"/><file name="jquery-ui.css" hash="b50192cf9c90fe83462ce9a7bcdd29c7"/><file name="jquery.steps.css" hash="5a25f593fe74b7d73a3c2a4212ac6612"/><file name="main.css" hash="aa03751cf9078dc47675f907e22bd2a5"/><file name="progress-bar.png" hash="bd5b9782b845486917de1b1e9fc2c631"/><file name="simple_container_bg.gif" hash="56f1ac91169eb4896b8c91384fc8bf15"/><file name="styles.css" hash="102a0ff89ef27e400b9df25de82e053e"/></dir><dir name="fonts"><file name="FontAwesome.otf" hash="5dc41d8fe329a22fa1ee9225571c843e"/><file name="fontawesome-webfont.eot" hash="25a32416abee198dd821b0b17a198a8f"/><file name="fontawesome-webfont.svg" hash="d7c639084f684d66a1bc66855d193ed8"/><file name="fontawesome-webfont.ttf" hash="1dc35d25e61d819a9c357074014867ab"/><file name="fontawesome-webfont.woff" hash="c8ddf1e5e5bf3682bc7bebf30f394148"/><file name="fontawesome-webfont.woff2" hash="e6cf7c6ec7c2d6f670ae9d762604cb0b"/></dir><dir name="images"><file name="ajax-loader-tr.gif" hash="1ae32bc8232ff2527c627e5b38eb319a"/><file name="delete_dust.png" hash="948ef1640b50d09d385597f967e6ebc1"/><file name="elbow-end-minus-nl.gif" hash="6dc08c43109cc6a365bd0270f05e2f1c"/><file name="elbow-end-minus.gif" hash="3dbdb88a9297fe5631e832f046b0350b"/><file name="elbow-end-plus-nl.gif" hash="6dc08c43109cc6a365bd0270f05e2f1c"/><file name="elbow-end-plus.gif" hash="5470e5712a9742ba666c26cb429baaeb"/><file name="elbow-end.gif" hash="63fe879440e2784e0cc0d316ce017745"/><file name="elbow-line.gif" hash="b316a39455304e20e01dbc437f57fd32"/><file name="elbow-minus-nl.gif" hash="0e3129bff70475c8f7f297e0e59d1608"/><file name="elbow-minus.gif" hash="e7b18ff6800e65c6e171bbb2a911762e"/><file name="elbow-plus-nl.gif" hash="78a8f737941fa658f1e770258a3791cd"/><file name="elbow-plus.gif" hash="b02cb264df55aef2105b1b245d075e56"/><file name="elbow.gif" hash="b6bd0e0237e3cd413fa2dac27701c724"/><file name="elbow_minus.png" hash="3fc01d7af6d0f10fb6ea321f85cfc4ce"/><file name="elbow_plus.png" hash="1deaa077bfe1c95f161e323aae1dc989"/><file name="folder-open.gif" hash="e3cd196406d4857dc0c926807f16c409"/><file name="folder.gif" hash="03eb26c42137ac792609822862ef4d0f"/><file name="keywords.png" hash="075655566b7b7abe2cf36d12f1aa6ca9"/><file name="leaf.gif" hash="e3cd196406d4857dc0c926807f16c409"/><file name="loading.gif" hash="00ef871b291bc03a497d608a5bd8ec99"/><file name="loading.png" hash="be5a561a53b5efe2e464f5acb811e90e"/><file name="s.gif" hash="df3e567d6f16d040326c7a0ea29a4f41"/><file name="simple_container_bg.gif" hash="56f1ac91169eb4896b8c91384fc8bf15"/><file name="styles.css" hash="73525c4881f2048bf59a594c61de3e09"/></dir><dir name="js"><dir name="build"><file name="jQuery.Steps.1.1.0.nupkg" hash="979939a5151179f40ab6883ea12cfbc4"/><file name="jquery.easyswitch.js" hash="9262c7cd4cd062a7b40d6e6ca65e3471"/><file name="jquery.steps-1.1.0.zip" hash="f446d606df167069be7718434b11ff55"/><file name="jquery.steps.js" hash="5a38905c075292e628c3e9453875b65d"/><file name="jquery.steps.min.js" hash="4c5e9f4e84d32b7df69af7420b355e03"/></dir><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-1.11.1.min.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-1.9.1.min.js" hash="663628f795cb62444143fde1ebdf2b5b"/><file name="jquery.cookie-1.3.1.js" hash="e5937111b7dc83385e3f4c7b91af7a80"/><file name="jquery.easyswitch.js" hash="70b67fe638e45f2b0f4ba978a4baa785"/><file name="modernizr-2.6.2.min.js" hash="42306a279a9e831515347ae319181cd1"/><file name="priceslider.js" hash="94827683d2169636ed208b023624cfb4"/></dir><dir name="less"><file name="animated.less" hash="08baef05e05301cabc91599a54921081"/><file name="bordered-pulled.less" hash="898f90e40876883214bbd121b0c20e9f"/><file name="core.less" hash="fb4efe4ae63737706875bbbfc7b7e9af"/><file name="fixed-width.less" hash="5e07ec001f8d21bd279c12ee542813f7"/><file name="font-awesome.less" hash="f53235946c37e394a6cd6d92f84587a8"/><file name="icons.less" hash="3c3bb8fbcd54a6b66a41137d5e9e8a33"/><file name="larger.less" hash="8cb65280c0f889daf72626c21a7c8628"/><file name="list.less" hash="975571323cf880a4a30601998236b027"/><file name="mixins.less" hash="fbb1f2f1ab96ba020c7f14208aac72b8"/><file name="path.less" hash="a8c41460c42a4fe9e98550f00c8b3f19"/><file name="rotated-flipped.less" hash="a8476cdc50c264abd11ff59d6a9dd025"/><file name="screen-reader.less" hash="0f881617264587bef0df6ce92253ecea"/><file name="stacked.less" hash="518e2b2d263982d2caa1e6514b4b4eac"/><file name="variables.less" hash="45fa411bbd22ff8467e027318a88a557"/></dir><file name="loader_new.jpg" hash="e02968245a670ef65a06411a442e557a"/><dir name="scss"><file name="_animated.scss" hash="39ff4f359a7b81d6585075715f41e5dc"/><file name="_bordered-pulled.scss" hash="4cad0df17bf40327feae33fa9a6c6ba2"/><file name="_core.scss" hash="ef059a98cf9de6ca5b77ee6850771cf0"/><file name="_fixed-width.scss" hash="9277ab6964a434d499873687b00be906"/><file name="_icons.scss" hash="fdffb08bc3d85c7427d8697f268fb072"/><file name="_larger.scss" hash="e95931566f6fc6ad5685c4fa9802e206"/><file name="_list.scss" hash="7107e80b053928271d5fcf422dc29490"/><file name="_mixins.scss" hash="aa2b8f32b403733713d8885f14ab86cc"/><file name="_path.scss" hash="ab5a9e8388563e097b5ce835601f01d2"/><file name="_rotated-flipped.scss" hash="9f5d4bc6fadea89328d2aac26574a9d8"/><file name="_screen-reader.scss" hash="8907bd7dbf4799e8120bda5568d76fea"/><file name="_stacked.scss" hash="5594237226aedfbca2fa1c7f4604c214"/><file name="_variables.scss" hash="783d4422626a7f27fa8f513de3ad4795"/><file name="font-awesome.scss" hash="ace7fb9336021f92b1cf68a10d5f452c"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="shell"><file name="createInstance.php" hash="4707ebd18bf21ac91ddc681005775573"/><file name="abstracts.php" hash="e92717fb78260959ef9de93f63b80fb2"/><file name="countryLanguadge.php" hash="0f6cdd3496a6b9f4122af672044f11f2"/><file name="defaultAttribute.php" hash="5722718990361cb1c0c4c4e1d8fdc510"/></dir><dir name="js"><dir name="munoz"><dir name="build"><file name="jQuery.Steps.1.1.0.nupkg" hash="979939a5151179f40ab6883ea12cfbc4"/><file name="jquery.easyswitch.js" hash="9262c7cd4cd062a7b40d6e6ca65e3471"/><file name="jquery.steps-1.1.0.zip" hash="f446d606df167069be7718434b11ff55"/><file name="jquery.steps.js" hash="5a38905c075292e628c3e9453875b65d"/><file name="jquery.steps.min.js" hash="4c5e9f4e84d32b7df69af7420b355e03"/></dir><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-1.11.1.min.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-1.9.1.min.js" hash="663628f795cb62444143fde1ebdf2b5b"/><file name="jquery.cookie-1.3.1.js" hash="e5937111b7dc83385e3f4c7b91af7a80"/><file name="jquery.easyswitch.js" hash="70b67fe638e45f2b0f4ba978a4baa785"/><dir name="js"><dir name="build"><file name="jQuery.Steps.1.1.0.nupkg" hash="979939a5151179f40ab6883ea12cfbc4"/><file name="jquery.easyswitch.js" hash="9262c7cd4cd062a7b40d6e6ca65e3471"/><file name="jquery.steps-1.1.0.zip" hash="f446d606df167069be7718434b11ff55"/><file name="jquery.steps.js" hash="5a38905c075292e628c3e9453875b65d"/><file name="jquery.steps.min.js" hash="4c5e9f4e84d32b7df69af7420b355e03"/></dir><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="jquery-1.11.1.min.js" hash="8101d596b2b8fa35fe3a634ea342d7c3"/><file name="jquery-1.9.1.min.js" hash="663628f795cb62444143fde1ebdf2b5b"/><file name="jquery.cookie-1.3.1.js" hash="e5937111b7dc83385e3f4c7b91af7a80"/><file name="jquery.easyswitch.js" hash="70b67fe638e45f2b0f4ba978a4baa785"/><file name="modernizr-2.6.2.min.js" hash="42306a279a9e831515347ae319181cd1"/><file name="priceslider.js" hash="94827683d2169636ed208b023624cfb4"/></dir><file name="modernizr-2.6.2.min.js" hash="42306a279a9e831515347ae319181cd1"/><file name="priceslider.js" hash="94827683d2169636ed208b023624cfb4"/></dir></dir></target><target name="magelib"><dir name="rollbar"><file name="Level.php" hash="fbe1e94a42be5a3a45b24350b176ccf4"/><file name="rollbar.php" hash="462cec30ca3fb320dd8360b2f03d9da4"/></dir></target></contents>
27
  <compatible/>
28
  <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
29
  </package>
shell/createInstance.php CHANGED
@@ -10,9 +10,9 @@
10
  /**
11
  * send category product and all information in API
12
  */
13
-
14
  require_once 'app/Mage.php';
15
- require_once 'countryLanguadge.php';
 
16
  require_once 'shell/abstracts.php';
17
  require_once 'shell/defaultAttribute.php';
18
  class Rodrigo_Shell_MyApi extends Mage_Shell_Abstract
@@ -31,43 +31,37 @@ class Rodrigo_Shell_MyApi extends Mage_Shell_Abstract
31
  const create_ecommerce_info='http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_info';
32
 
33
  public function __construct($wholekeyword) {
34
-
35
  parent::__construct();
36
-
37
  require_once 'lib/rollbar/rollbar.php';
38
- $config = array(
39
- // required
40
- 'access_token' => '2ebc59c9d3b641f3b5a57f8746b5ee69',
41
- // optional - environment name. any string will do.
42
- 'environment' => 'production',
43
- // optional - path to directory your code is in. used for linking stack traces.
44
- 'root' => __DIR__
45
- );
46
- Rollbar::init($config);
47
-
48
-
49
-
50
- try {
51
- $this->setSteps();
52
- } catch (Exception $e) {
53
- Rollbar::report_exception($e);
54
- }
55
-
56
- try {
57
- $stat_time_api=$this->stat_time_api();
58
- } catch (Exception $e) {
59
- Rollbar::report_exception($e);
60
- }
61
-
62
  $store_creat_date='';
63
  $xml = simplexml_load_file('app/etc/local.xml');
64
  if(isset($xml->global->install->date)) {
65
  $store_creat_date= (string)$xml->global->install->date;
66
- }
67
- $now = Mage::getModel('core/date')->timestamp(time());
68
  $countries='';
69
  $Allprodcut=$this->getProductById($wholekeyword['checkecCat'],$wholekeyword['unselectCat']);
70
-
71
  $Allcategory=$this->getCategory($wholekeyword['checkecCat'],$wholekeyword['unselectCat']);
72
  $budget=$wholekeyword['budget'];
73
  if($wholekeyword['countries'])
@@ -78,89 +72,67 @@ class Rodrigo_Shell_MyApi extends Mage_Shell_Abstract
78
  $countries=Mage::getStoreConfig('general/country/default');
79
  }
80
  $count=$this->sendCountry($countries);
81
-
82
  $category =$this->getCategoryKeywords(); // get Category keyword
83
  $tips=$this->getAddTips(); // get Added Tip keyword
84
  $order=$this->getOrders(); // get orders
85
  $admin=$this->getAdminDetail();
86
-
87
- try {
88
- $this->setSteps();
89
- } catch (Exception $e) {
90
- Rollbar::report_exception($e);
91
- }
92
-
93
- try {
94
- $setFirstData= $this->setDataInFirstApi($Allcategory,$order,$admin,$tips,$category,$budget,$countries,$store_creat_date);
95
- } catch (Exception $e) {
96
- Rollbar::report_exception($e);
97
- }
98
- try {
99
- $rellProductColl=$this->rellProductColl($Allprodcut); // set the prodcut category in api'
100
- } catch (Exception $e) {
101
- Rollbar::report_exception($e);
102
- }
103
-
104
- try {
105
- $this->ad_tips();
106
- } catch (Exception $e) {
107
- Rollbar::report_exception($e);
108
- }
109
-
110
- try {
111
- $this->keywords();
112
- } catch (Exception $e) {
113
- Rollbar::report_exception($e);
114
- }
115
-
116
- try {
117
- $this->orderApi();
118
- } catch (Exception $e) {
119
- Rollbar::report_exception($e);
120
- }
121
-
122
- try {
123
- $dim_coll= $this->setDataDimColl();
124
- } catch (Exception $e) {
125
- Rollbar::report_exception($e);
126
- }
127
-
128
- try {
129
- $dimOption=$this->dimOption(); // set the prodcut option in api
130
- } catch (Exception $e) {
131
- Rollbar::report_exception($e);
132
- }
133
-
134
-
135
- try {
136
- $this->rel_prod_opt($Allprodcut);
137
- } catch (Exception $e) {
138
- Rollbar::report_exception($e);
139
- }
140
-
141
- try {
142
- $this->nameApi();
143
- } catch (Exception $e) {
144
- Rollbar::report_exception($e);
145
- }
146
-
147
- try {
148
- $this->saveStaus();
149
- } catch (Exception $e) {
150
- Rollbar::report_exception($e);
151
- }
152
- try {
153
- $this->end_time_api();
154
- } catch (Exception $e) {
155
- Rollbar::report_exception($e);
156
- }
157
-
158
- // $this->rel_prod_coll($Allprodcut);
159
- //$this->setSteps();
160
- set_time_limit(0);
161
-
162
  // Time limit to infinity
163
-
164
  // Get command line argument named "argname"
165
  // Accepts multiple values (comma separated)
166
  if($this->getArg('argname')) {
@@ -173,7 +145,6 @@ class Rodrigo_Shell_MyApi extends Mage_Shell_Abstract
173
  );
174
  }
175
  }
176
-
177
  // Shell script point of entry
178
  public function run() {
179
 
@@ -194,448 +165,372 @@ class Rodrigo_Shell_MyApi extends Mage_Shell_Abstract
194
  USAGE;
195
 
196
  }
197
-
198
-
199
  /*************************************/
200
  # fetching total complete orders count
201
  /*************************************/
202
- public function getTotalorders(){
203
-
204
- $time = time();
205
- $to = date('Y-m-d H:i:s', $time);
206
- $lastTime = $time - 86400; // 60*60*24*30
207
- $from = date('Y-m-d H:i:s', $lastTime);
208
- $order_items = Mage::getResourceModel('sales/order_item_collection')
209
- ->addAttributeToSelect('order_id')
210
- ->addAttributeToSelect('created_at')
211
- ->addFieldToFilter('created_at', array(
212
- 'from' => strtotime('-30 day', time()),
213
- 'to' => time(),
214
- 'datetime' => true
215
- ))
216
- ->load();
217
- return count($order_items);
218
-
219
-
220
-
221
- }
222
  /*************************************/
223
  # fetching category keywords saved
224
  # by user
225
  /*************************************/
226
- public function getCategoryKeywords(){
227
- $collection =Mage::getModel('munoz/keyword')->getCollection();
228
- $collection->addFieldToFilter('keyword_type','category');
229
- return $collection;
230
- }
231
  /*************************************/
232
  # fetching tips saved by user
233
  /*************************************/
234
- public function getAddTips(){ // fetching tips saved by user
235
- $keyword =Mage::getModel('munoz/keyword')->getCollection();
236
- $keyword->addFieldToFilter('keyword_type','calltoaction');
237
- return $keyword;
238
- }
239
  /*************************************/
240
  # fetching orders
241
  /*************************************/
242
- public function getOrders(){
243
- $orders = Mage::getModel('sales/order')->getCollection()
244
- ->addFieldToFilter('status', 'complete');
245
- return $orders;
246
- }
 
247
  /*************************************/
248
  # fetching Admin Detail
249
  /*************************************/
250
- public function getAdminDetail(){
251
- $userArray = Mage::getSingleton('admin/session')->getData();
252
  // get individual data
253
- return $user = Mage::getSingleton('admin/session');
254
- }
255
  /*************************************/
256
  # fetching category selected by users
257
  /*************************************/
258
- public function getCategory($check, $unselect){
259
- $cate=array();
260
- $all_cat = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter()
261
- ->addAttributeToFilter('is_active', 1)
262
- ->addAttributeToSort('position', 'desc');
263
- if($check){
264
- $all_cat->addIdFilter($check);
265
- }
266
- if($unselect){
267
- $all= Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter()
268
- ->addAttributeToFilter('is_active', 1)
269
- ->addAttributeToSort('position', 'desc');
270
- foreach($all as $select_cat){
271
- array_push($cate,$select_cat->getId());
272
- }
273
- $final_cat = array_diff($cate, $unselect);
274
- $all_cat->addIdFilter($final_cat);
275
- $preId=$final_cat;
276
- }
277
- return $all_cat;
278
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /*************************************/
280
  # fetching product selected categories
281
  /*************************************/
282
- public function getProductById($check, $unselect){
283
- $cate=array();
284
- $all_cat = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter()
285
- ->addAttributeToFilter('is_active', 1)
286
- ->addAttributeToSort('position', 'desc');
287
- if($check){
288
- $all_cat->addIdFilter($check);
289
- }
290
- if($unselect){
291
- $all= Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter()
292
- ->addAttributeToFilter('is_active', 1)
293
- ->addAttributeToSort('position', 'desc');
294
- foreach($all as $select_cat){
295
- array_push($cate,$select_cat->getId());
296
- }
297
- $final_cat = array_diff($cate, $unselect);
298
- $all_cat->addIdFilter($final_cat);
299
- $preId=$final_cat;
300
- }
301
- return $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->load();
302
- }
303
-
304
  /*************************************/
305
  # fetching all 2 level category
306
  /*************************************/
307
- public function getAllLevelCat(){
308
- $categories = Mage::getModel('catalog/category')->getCollection()
309
- ->addAttributeToSelect('*')//or you can just add some attributes
310
- ->addAttributeToFilter('level', 2);//2 is actually the first level
311
  return $categories;
312
- }
313
-
314
  /*************************************/
315
  # fetching children category by id
316
  /*************************************/
317
- public function getTreeCat($id){
318
- return $children = Mage::getModel('catalog/category')->load($id)->getChildrenCategories();
319
- }
320
-
321
  /*************************************/
322
  # fetching custom attribute
323
  /*************************************/
324
- public function AttributeOptionArray()
325
- {
326
- // $attributes = Mage::getModel('catalog/product')->getAttributes();
327
- //$attributeArray = array();
328
- //
329
- //foreach($attributes as $a){
330
- // foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {
331
- // $attributeArray[$attributeName] = $attributeName;
332
- // }
333
- // break;
334
- //}
335
-
336
-
337
- return $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
338
- // return $attributeArray;
339
-
340
-
341
-
342
- //return $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
343
- }
344
  /*************************************/
345
  # fetching attribute value by
346
  #attribute code
347
  /*************************************/
348
- public function getAtrValue($code){
349
- $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product',$code);
350
- $collection =Mage::getResourceModel('eav/entity_attribute_option_collection')
351
- ->setPositionOrder('asc')
352
- ->setAttributeFilter($attributeId)
353
- ->setStoreFilter(0)
354
- ->load();
355
- return $collection = $collection->toOptionArray();
356
- }
357
  /*************************************/
358
  # fetching product tag custmer and admin
359
  /*************************************/
360
- public function TagProduct(){
361
- $tag_model= Mage::getModel('tag/tag');
362
- $tag_collection= $tag_model->getResourceCollection()->load();
363
-
364
- return $mytags=$tag_collection->getItems();
365
- }
366
  /*************************************/
367
  # fetching product by tag id
368
  /*************************************/
369
 
370
- public function getProductIdByTag($tagId){
371
- $collection = Mage::getResourceModel('tag/product_collection') ->addTagFilter($tagId);
372
- foreach($collection->getData() as $prd)
373
- {
374
- return $prd['entity_id'];
375
- }
376
-
377
  }
 
378
  /*************************************/
379
  # fetching all category
380
  /*************************************/
381
- function getTreeCategories($parentId, $isChild){
382
- $allCats = Mage::getModel('catalog/category')->getCollection()
383
- ->addAttributeToSelect('*')
384
- ->addAttributeToFilter('is_active','1')
385
- ->addAttributeToFilter('include_in_menu','1')
386
- ->addAttributeToFilter('parent_id',array('eq' => $parentId));
387
- return $allCats;
388
-
389
- }
390
-
391
  /*************************************/
392
  # fetching product rellational category
393
  /*************************************/
394
- public function getRelationalCat($productIds){
395
- $cat =Mage::getModel('catalog/category')->load($productIds);
396
- return $cat->getId();
397
-
398
- }
399
  /*************************************/
400
  # fetching product aatribute
401
  #by product id
402
  /*************************************/
403
 
404
- public function getProductAtribute($productId){
405
- $attr_array=array();
406
- $product = Mage::getModel('catalog/product')->load($productId);
407
- //$attributes = $product->getAttributes();
408
- $count=1;
409
- foreach($this->prd_atr_code as $attrcode){
410
- $attribute_value = $product->getData($attrcode);
411
- if(!$attribute_value){
412
- $attribute_value='null';
413
- }
414
- array_push($attr_array,array('value'=>$attribute_value,'label'=>'opt'.$count.'_id','pid'=>$productId));
415
- $count++;
416
- }
417
- return $attr_array;
418
  }
 
 
419
  /*************************************/
420
  # fetching product stock
421
  #by product id
422
  /*************************************/
423
- public function getPorductStock($product_id){
424
- $model = Mage::getModel('catalog/product');
425
- $_product = $model->load($product_id);
426
- return $stocklevel = (int)Mage::getModel('cataloginventory/stock_item') ->loadByProduct($_product)->getQty();
427
- }
428
  /*************************************/
429
  # fetching product ids by category id
430
  /*************************************/
431
- public function getProductIds($catid){
432
- $category = new Mage_Catalog_Model_Category();
433
- $category->load($catid); //My category id is 6
434
- $prodCollection = $category->getProductCollection();
435
- foreach ($prodCollection as $product) {
436
- $prdIds[] = $product->getId(); //Array to store all the product ids
437
- }
438
- return $prdIds;
439
  }
 
 
440
  /**********************************/
441
  # First API send basic information
442
  # product categorry relations
443
  /*********************************/
444
 
445
  public function setDataInFirstApi($Allcategory,$order,$admin,$tips,$category,$budget,$countries,$created){
446
- $stores =array();
447
- foreach(Mage::app()->getStores() as $store) {
448
- array_push($stores,$store->getName().',');
449
- }
450
- $all_store =implode(" ",$stores);
451
- $info['id']='';
452
- $info['clientId']=$this->_getClient_id();
453
- //$info['store_name']= rtrim($all_store, ",");
454
- $info['name_ascii']='';
455
- $info['info_type']='';
456
- $info['owner']=$admin->getUser()->getFirstname() .' '.$admin->getUser()->getLastname();
457
- $info['email']=$admin->getUser()->getEmail();
458
- $info['phone']=Mage::getStoreConfig('general/store_information/phone');
459
- $info['domain']=$_SERVER['HTTP_HOST'];
460
- $info['main_language']=Mage::app()->getLocale()->getLocaleCode();
461
- // $info['countries']=$countries;
462
-
463
- $info['total_oders']=$this->getTotalorders();
464
- $info['currency']=Mage::app()->getStore()->getCurrentCurrencyCode();
465
- $info['adwordsId']='';
466
- $info['budget']=$budget;
467
- $info['camp_by_default']='1';
468
-
469
- // $info['categories']=$cat_name_array;
470
- // $info['CategoryId']=$cat_id_array;
471
- $info['country']=Mage::getStoreConfig('general/country/default');;
472
- $info['city']=Mage::getStoreConfig('general/store_information/address');
473
- $info['province']='';
474
- $info['city']='';
475
- $info['zip']='';
476
- $info['latitude']='';
477
- $info['longitude']='';
478
-
479
- $info['iana_timezone']=Mage::getStoreConfig('general/locale/timezone');
480
- // $info['logo_url']=Mage::getStoreConfig('design/header/logo_src');
481
- $info['gender']='';
482
- $info['device']='';
483
-
484
- $info['age']='';
485
-
486
- $info['platform']='Magento';
487
- $info['created_at']=$created;
488
- //$info['installed_at']=$created;
489
-
490
-
491
  $params= array('info'=>json_encode($info));
492
  $this->_postCurl(self::create_ecommerce_info ,$params);
493
 
494
  }
495
-
496
  /***********************/
497
  # Second Api send Dim_prod
498
  # product categorry relations
499
  /***********************/
500
-
501
  public function setDataDimColl(){
502
  $cat_id=array();
503
- $treeacat_id=array();
504
-
505
  for( $catLevel=1; $catLevel <= 5; $catLevel++ ){ // loop for
506
- if($catLevel >1){ // second dim_coll
507
- $treeacat_id=array();
508
- // $treeacat_id = null;
509
- $i=0;
510
- if(!empty($cat_id)){
511
- // echo "<pre>";
512
- // print_r($cat_id);
513
- foreach($cat_id as $treeCat){
514
- $all_Tree_cat = $this->getTreeCat($treeCat);
515
- foreach($all_Tree_cat as $Cat_Tree){
516
- array_push($treeacat_id,$Cat_Tree->getId());
517
- $dim_colls[$i]['id'] ='';
518
- $dim_colls[$i]['clientId']=$this->_getClient_id();
519
- $dim_colls[$i]['product_ids']=$this->getProductIds($Cat_Tree->getId());
520
- $dim_colls[$i]['collId']= $Cat_Tree->getId();
521
- $dim_colls[$i]['coll_name']=$Cat_Tree->getName();
522
- $dim_colls[$i]['published']= $Cat_Tree->getIsActive();
523
- $dim_colls[$i]['main_image']=$Cat_Tree->getThumbnail();
524
- $dim_colls[$i]['coll_url']=$Cat_Tree->getUrl();
525
- $dim_colls[$i]['parent_id']=$this->_getParentId($Cat_Tree->getId());
526
- $dim_colls[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
527
-
528
- $i++;
529
- }
530
- $params= array('dim_coll'.$catLevel=>json_encode($dim_colls));
531
-
532
- }
533
-
534
- //echo "http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_coll".$catLevel;
535
- $ch = curl_init();
536
- curl_setopt($ch, CURLOPT_URL, "http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_coll".$catLevel);
537
- //return the transfer as a string
538
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
539
- curl_setopt($ch, CURLOPT_POST, true);
540
- // curl_setopt($ch, CURLOPT_HTTPGET, 1);
541
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
542
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
543
- curl_setopt($ch,CURLOPT_TIMEOUT,400);
544
- $output = curl_exec($ch);
545
- curl_close($ch);
546
- $json_a =json_decode($output,true);
547
- $dim_colls=null;
548
-
549
- }
550
- $cat_id=$treeacat_id;
551
- // api six, seven ,eight, nine
552
-
553
-
554
- }// end catlavel
555
-
556
-
557
- else{
558
- $all_cat = $this->getAllLevelCat();
559
- if(count($all_cat) >0){
560
- $j=0;
561
- foreach ($all_cat as $category_first_level){
562
- $dim_coll[$j]['id']='';
563
- $dim_coll[$j]['clientId']=$this->_getClient_id();
564
- $dim_coll[$j]['coll_level'] ='1';
565
- $dim_coll[$j]['collId']= $category_first_level->getId();
566
- $dim_coll[$j]['product_ids']= $this->getProductIds($category_first_level->getId());
567
- $dim_coll[$j]['coll_name']=$category_first_level->getName();
568
- $dim_coll[$j]['coll_url']=$category_first_level->getUrl();
569
- $dim_coll[$j]['published']= $category_first_level->getIsActive();
570
- $dim_coll[$j]['main_image']=$category_first_level->getThumbnail();
571
- $dim_coll[$j]['parent_id']='0';
572
- $dim_coll[$j]['lang']=Mage::app()->getLocale()->getLocaleCode();
573
- array_push($cat_id,$category_first_level->getId());
574
- $j++;
575
-
576
- } // end foreach
577
- } // end if
578
-
579
- $params= array('dim_coll1'=>json_encode($dim_coll));
580
- $this->_postCurl('manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_coll1' ,$params);
581
-
582
- }// end else
583
-
584
- } // end main foreach loop
585
  }
586
-
587
  /***********************/
588
  # Third API
589
  # product option relations
590
  /***********************/
591
  public function dimOption(){
592
-
593
- $count=1;
594
-
595
- $product_attribute =$this->AttributeOptionArray();
596
- if(count($product_attribute) >0){
597
-
598
- foreach($product_attribute as $prdAtr){
599
- if(!in_array($prdAtr->getAttributecode(),getDefaultAttribute())){
600
- $attributeValue=$this->getAtrValue($prdAtr->getAttributecode());
601
- if(count($attributeValue) > 0){
602
- if($count < 11){
603
- $i=0;
604
- array_push($this->prd_atr_code, $prdAtr->getAttributecode());
605
- foreach($attributeValue as $option){
606
- $dimProduct[$i]['id']='';
607
- $dimProduct[$i]['clientId']=$this->_getClient_id();
608
- $dimProduct[$i]['optId']=$option['value'];
609
- $dimProduct[$i]['opt_name']=$option['label'];
610
- $dimProduct[$i]['opt_url']='';
611
- $dimProduct[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
612
- $i++;
613
-
614
- }
615
- $params= array('dim_opt'.$count=>json_encode($dimProduct));
616
- // echo "http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_opt".$count;
617
- $ch = curl_init();
618
- curl_setopt($ch, CURLOPT_URL, "http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_opt".$count);
619
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
620
- curl_setopt($ch, CURLOPT_POST, true);
621
-
622
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
623
- $output = curl_exec($ch);
624
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
625
- curl_setopt($ch,CURLOPT_TIMEOUT,0);
626
- // close curl resource to free up system resources
627
- curl_close($ch);
628
- $json_a =json_decode($output,true);
629
- $count++;
630
-
631
-
632
-
633
- }// end for each
634
-
635
- }
636
- } // end In_array
637
- }// end foreach
638
- } // end count
639
 
640
 
641
  }
@@ -646,126 +541,107 @@ public function dimOption(){
646
  # product name relations
647
  /***********************/
648
  public function rellProductColl($Allprodcut){
649
- $i=0;
650
- $prd_name=array();
651
- foreach ($Allprodcut as $product) {
652
-
653
-
654
- if (!in_array($product->getName(), $prd_name)) {
655
- $dim_prod[$i]['id']='';
656
- $dim_prod[$i]['clientId']=$this->_getClient_id();
657
- $dim_prod[$i]['prodId']=$product->getId();
658
- $dim_prod[$i]['prod_name']=$product->getName();
659
- $dim_prod[$i]['prod_url']=$product->getProductUrl();
660
- $dim_prod[$i]['prod_price']=$product->getPrice();
661
- $dim_prod[$i]['barcode']='';
662
- $dim_prod[$i]['sku']=$product->getSku();
663
- $dim_prod[$i]['meta']=$product->getMetaKeywords();
664
- $dim_prod[$i]['published']=$product->getStatus();
665
- $dim_prod[$i]['inv']='';
666
- $dim_prod[$i]['inv_num']=$this->getPorductStock($product->getId());
667
- $dim_prod[$i]['updated']=$product->getUpdatedAt();
668
- $dim_prod[$i]['main_image']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' .$product->getImage();
669
- $dim_prod[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
670
- array_push($prd_name,$product->getName());
671
- $i++;
672
- }
673
- }
674
-
675
  $params= array('dim_prod'=>json_encode($dim_prod));
676
-
677
- $this->_postCurl(self::create_ecommerce_dim_prod ,$params);
678
  }
679
-
680
  /***********************/
681
  # product categorry relations
682
  /***********************/
683
  public function rel_prod_coll($Allprodcut){
684
- $i=0;
685
- if(count($Allprodcut) >0){ // product category collections
686
-
687
- foreach($Allprodcut as $rellAtionPro){
688
-
689
- if(count($rellAtionPro->getCategoryIds()) >0){
690
- $coll_id=1;
691
- foreach ($rellAtionPro->getCategoryIds() as $rellCatIds){
692
- $rel_prod_coll[$i]['id']='';
693
- $rel_prod_coll[$i]['clientId']=$this->_getClient_id();
694
- $rel_prod_coll[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
695
- $rel_prod_coll[$i]['prodId']=$rellAtionPro->getId();
696
- $rel_prod_coll[$i]['coll'.$coll_id.'Id']=$this->getRelationalCat($rellCatIds);
697
- $coll_id++;
698
- }
699
-
700
- }
701
- $i++;
702
- }
703
-
704
- } // end product categorry collections
705
- $params= array('rel_prod_coll'=>json_encode(array_values($rel_prod_coll)));
706
- $this->_postCurl(self::create_ecommerce_rel_prod_coll ,$params);
707
-
708
  }
709
-
710
  /***********************/
711
  # product categorry relations
712
  /***********************/
713
  public function rel_prod_opt($Allprodcut){
714
- if(count($Allprodcut) >0){ // prodcut option
715
- $k=0;
716
- $prdt_name=array();
717
- foreach($Allprodcut as $rellAttrProdcut){
718
- if (!in_array($rellAttrProdcut->getName(), $prdt_name)) {
719
-
720
- $rellProAtr =$this->getProductAtribute($rellAttrProdcut->getId());
721
- if(count($rellProAtr) >0){
722
- $attrCol=1;
723
- foreach($rellProAtr as $atrFetch){
724
- $rel_prod_opt[$k]['id']='';
725
- $rel_prod_opt[$k]['clientId']=$this->_getClient_id();
726
- $rel_prod_opt[$k]['lang']=Mage::app()->getLocale()->getLocaleCode();
727
- $rel_prod_opt[$k]['prodId']=$rellAttrProdcut->getId();
728
- $rel_prod_opt[$k]['opt'.$attrCol.'Id']=$atrFetch['value'];
729
- $attrCol++;
730
-
731
- }// end foreach
732
- }
733
-
734
- }else{
735
-
736
- $rellProAtr =$this->getProductAtribute($rellAttrProdcut->getId());
737
- if(count($rellProAtr) >0){
738
- $attrCol=1;
739
- foreach($rellProAtr as $atrFetch){
740
- $rel_prod_opt[$k]['id']='';
741
- $rel_prod_opt[$k]['clientId']=$this->_getClient_id();
742
- $rel_prod_opt[$k]['lang']=Mage::app()->getLocale()->getLocaleCode();
743
- $rel_prod_opt[$k]['prodId']= end($prdt_name);
744
- $rel_prod_opt[$k]['opt'.$attrCol.'Id']=$atrFetch['value'];
745
- $attrCol++;
746
-
747
- }// end foreach
748
- }
749
-
750
- }
751
- array_push($prdt_name,$rellAttrProdcut->getName(),$rellAttrProdcut->getId());
752
- // end foreach
753
- $k++;
754
-
755
- }
756
-
757
- } //end prodcut option
758
-
759
-
760
-
761
- $rell_pro_opts= array('rel_prod_opt'=>json_encode(array_values($rel_prod_opt)));
762
- $rel =$this->_postCurl(self::create_ecommerce_rel_prod_opt ,$rell_pro_opts);
763
-
764
-
765
-
766
-
767
-
768
-
769
  }
770
  /***********************/
771
  # second API send name
@@ -774,19 +650,18 @@ public function nameApi(){
774
  $m=0;
775
  $rel_prod_name[0]['Id']='';
776
  $rel_prod_name[0]['clientId']=$this->_getClient_id();
777
-
778
  for($i=1; $i<6; $i++){
779
  $rel_prod_name[0]['coll'.$i.'_id']='';
780
  }
781
 
782
- $j=1;
783
  foreach($this->prd_atr_code as $prdatrr){
784
  $rel_prod_name[0]['opt'.$j.'_id']=$prdatrr;
785
  $j++;
786
  }
787
- $rel_prod_name[0]['lang']=Mage::app()->getLocale()->getLocaleCode();
788
- $name= array('name'=>json_encode(array_values($rel_prod_name)));
789
- $this->_postCurl(self::create_ecommerce_name ,$name);
790
 
791
  }
792
 
@@ -802,8 +677,8 @@ foreach($this->getAddTips() As $tips){
802
  $ad_tip[$j]['lang']=Mage::app()->getLocale()->getLocaleCode();
803
  $j++;
804
  }
805
- $ad_tips= array('ad_tip'=>json_encode($ad_tip));
806
- $this->_postCurl(self::create_ecommerce_ad_tip ,$ad_tips);
807
 
808
 
809
  }
@@ -822,8 +697,8 @@ foreach($this->getCategoryKeywords() as $kewwords){
822
  $EcommerceKeyword[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
823
  $i++;
824
  }
825
- $params= array('keyword'=>json_encode($EcommerceKeyword));
826
- $this->_postCurl(self::create_ecommerce_keyword ,$params);
827
 
828
  }
829
  /***********************/
@@ -831,7 +706,8 @@ foreach($this->getCategoryKeywords() as $kewwords){
831
  /***********************/
832
  public function orderApi(){
833
  $k=0;
834
- foreach($this->getOrders() as $orders){
 
835
  $Order[$k]['id']='';
836
  $Order[$k]['clientId']=$this->_getClient_id();
837
  $Order[$k]['productId']=$orders->getEntityId();
@@ -839,71 +715,79 @@ public function orderApi(){
839
  $Order[$k]['order_quantity']=$orders->getTotalQtyOrdered();
840
  $Order[$k]['order_price']=$orders->getTotalPaid();
841
  $k++;
 
842
  }
843
- $params= array('order'=>json_encode($Order));
844
- $this->_postCurl(self::create_ecommerce_order ,$params);
845
 
846
 
847
  }
848
  public function saveStaus(){
849
  $collection =Mage::getModel('munoz/keyword')->getCollection();
850
- $collection->addFieldToFilter('keyword_title','complete');
851
- if(count($collection)>0){
852
- $res= Mage::getModel('munoz/keyword')->load('complete','keyword_title');
853
- $res->setKeywordTitle('complete');
854
-
855
- $res->setCreatedAt(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
856
- }
857
- else{
858
- $res =Mage::getModel('munoz/keyword');
859
- $res->setKeywordTitle('complete');
860
- $res->setCreatedAt(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
861
- }
862
- try
863
- {
864
- $result = $res->save();
865
- }
866
- catch(Exception $e)
867
- {
868
- $error=$e;
869
- }
870
  }
871
  public function setSteps(){
872
  $cleint_id=$this->_getClient_id();
873
- $url="http://manager.cleverppc.com/api/ecommerce/v1/last_step_status?client_token=".$cleint_id."&last_step=5&waiting=1";
874
- $data = file_get_contents($url);
875
- $json_a=json_decode($data,true);
876
-
877
- // print_r($json_a);
878
  }
879
 
880
  public function stat_time_api(){
881
  $cleint_id=$this->_getClient_id();
882
  $url=self::check_finish_process_time."?client_token=".$cleint_id."&start=1";
883
  $data = file_get_contents($url);
884
- $json_a=json_decode($data,true);
885
-
886
  }
887
-
888
-
889
  public function sendCountry($country_code){
890
- $selected_country = explode(",", $country_code);
891
- $i=0;
892
  foreach($selected_country as $countries){
893
  $countryName = Mage::getModel('directory/country')->loadByCode($countries)->getName();
894
  $country[$i]['id']='';
895
  $country[$i]['clientId']=$this->_getClient_id();
896
- $country[$i]['ctry_iso_2']=country_code_to_locale($countries);
897
  $country[$i]['ctry_name']= $countryName;
898
  $country[$i]['ctry_GgId']='';
899
-
900
  $i++;
901
  }
902
- // api six, seven ,eight, nine
903
- $params= array('country'.$catLevel=>json_encode($country));
904
- $this->_postCurl(self::create_ecommerce_country ,$params);
905
 
906
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
907
  // curl function /////////
908
  public function _postCurl($url , $params){
909
  $ch = curl_init();
@@ -916,44 +800,32 @@ public function _postCurl($url , $params){
916
  // $output contains the output string
917
  $output = curl_exec($ch);
918
  curl_close($ch);
919
-
920
- return $json_a =json_decode($output,true);
921
-
922
-
923
- }
924
-
925
 
926
- public function _getClient_id() {
927
- $url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
928
- $disallowed = array('http://', 'https://');
929
- foreach($disallowed as $d) {
930
- if(strpos($url, $d) === 0) {
931
- $u =str_replace($d, '', $url);
932
- $url =str_replace('/', '', $u);
933
- return md5($url);
934
- }
935
- }
936
  return md5($url);
 
 
 
 
 
 
 
 
 
 
 
 
 
937
  }
938
-
939
-
940
- public function _getParentId($ids){
941
- if ($ids){
942
- $topParent = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($ids);
943
- }
944
- else{
945
- $topParent = null;//it means you are in one catalog root.
946
- }
947
- //echo "<pre>";
948
- //print_r($topParent);
949
-
950
- return $topParent['parent_id'];
951
-
952
-
953
- }
954
  // end curl ///////
955
-
956
-
957
  public function end_time_api(){
958
  $cleint_id=$this->_getClient_id();
959
  $url=self::check_finish_process_time."?client_token=".$cleint_id."&stop=1";
@@ -961,8 +833,6 @@ public function end_time_api(){
961
  $json_a=json_decode($data,true);
962
 
963
  }
964
-
965
-
966
  }
967
  $wholekeyword=$this->getRequest()->getParams();
968
  $shell = new Rodrigo_Shell_MyApi($wholekeyword);
10
  /**
11
  * send category product and all information in API
12
  */
 
13
  require_once 'app/Mage.php';
14
+ $app = Mage::app('admin');
15
+ umask(0);
16
  require_once 'shell/abstracts.php';
17
  require_once 'shell/defaultAttribute.php';
18
  class Rodrigo_Shell_MyApi extends Mage_Shell_Abstract
31
  const create_ecommerce_info='http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_info';
32
 
33
  public function __construct($wholekeyword) {
 
34
  parent::__construct();
 
35
  require_once 'lib/rollbar/rollbar.php';
36
+ $config = array(
37
+ // required
38
+ 'access_token' => '2ebc59c9d3b641f3b5a57f8746b5ee69',
39
+ // optional - environment name. any string will do.
40
+ 'environment' => 'production',
41
+ // optional - path to directory your code is in. used for linking stack traces.
42
+ 'root' => __DIR__
43
+ );
44
+ Rollbar::init($config);
45
+ ignore_user_abort(true);
46
+ set_time_limit(0);
47
+ try {
48
+ $stat_time_api=$this->stat_time_api();
49
+ } catch (Exception $e) {
50
+ Rollbar::report_exception($e);
51
+ }
52
+ try {
53
+ $step=$this->setSteps();
54
+ } catch (Exception $e) {
55
+ Rollbar::report_exception($e);
56
+ }
 
 
 
57
  $store_creat_date='';
58
  $xml = simplexml_load_file('app/etc/local.xml');
59
  if(isset($xml->global->install->date)) {
60
  $store_creat_date= (string)$xml->global->install->date;
61
+ }
62
+ $now = Mage::getModel('core/date')->timestamp(time());
63
  $countries='';
64
  $Allprodcut=$this->getProductById($wholekeyword['checkecCat'],$wholekeyword['unselectCat']);
 
65
  $Allcategory=$this->getCategory($wholekeyword['checkecCat'],$wholekeyword['unselectCat']);
66
  $budget=$wholekeyword['budget'];
67
  if($wholekeyword['countries'])
72
  $countries=Mage::getStoreConfig('general/country/default');
73
  }
74
  $count=$this->sendCountry($countries);
 
75
  $category =$this->getCategoryKeywords(); // get Category keyword
76
  $tips=$this->getAddTips(); // get Added Tip keyword
77
  $order=$this->getOrders(); // get orders
78
  $admin=$this->getAdminDetail();
79
+ try {
80
+ $setFirstData= $this->setDataInFirstApi($Allcategory,$order,$admin,$tips,$category,$budget,$countries,$store_creat_date);
81
+ } catch (Exception $e) {
82
+ Rollbar::report_exception($e);
83
+ }
84
+ try {
85
+ $this->ad_tips();
86
+ } catch (Exception $e) {
87
+ Rollbar::report_exception($e);
88
+ }
89
+ try {
90
+ $this->keywords();
91
+ } catch (Exception $e) {
92
+ Rollbar::report_exception($e);
93
+ }
94
+ try {
95
+ $this->orderApi();
96
+ } catch (Exception $e) {
97
+ Rollbar::report_exception($e);
98
+ }
99
+ try {
100
+ $this->nameApi();
101
+ } catch (Exception $e) {
102
+ Rollbar::report_exception($e);
103
+ }
104
+ try {
105
+ $dimOption=$this->dimOption(); // set the prodcut option in api
106
+ } catch (Exception $e) {
107
+ Rollbar::report_exception($e);
108
+ }
109
+ try {
110
+ $this->rel_prod_opt($Allprodcut);
111
+ } catch (Exception $e) {
112
+ Rollbar::report_exception($e);
113
+ }
114
+ try {
115
+ $dim_coll= $this->setDataDimColl();
116
+ } catch (Exception $e) {
117
+ Rollbar::report_exception($e);
118
+ }
119
+ try {
120
+ $rellProductColl=$this->rellProductColl($Allprodcut); // set the prodcut category in api'
121
+ } catch (Exception $e) {
122
+ Rollbar::report_exception($e);
123
+ }
124
+ try {
125
+ $this->end_time_api();
126
+ } catch (Exception $e) {
127
+ Rollbar::report_exception($e);
128
+ }
129
+ try {
130
+ $this->saveStaus();
131
+ }catch (Exception $e) {
132
+ Rollbar::report_exception($e);
133
+ }
134
+ ini_set('max_execution_time', 3000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  // Time limit to infinity
 
136
  // Get command line argument named "argname"
137
  // Accepts multiple values (comma separated)
138
  if($this->getArg('argname')) {
145
  );
146
  }
147
  }
 
148
  // Shell script point of entry
149
  public function run() {
150
 
165
  USAGE;
166
 
167
  }
 
 
168
  /*************************************/
169
  # fetching total complete orders count
170
  /*************************************/
171
+ public function getTotalorders(){
172
+ $time = time();
173
+ $to = date('Y-m-d H:i:s', $time);
174
+ $lastTime = $time - 86400; // 60*60*24*30
175
+ $from = date('Y-m-d H:i:s', $lastTime);
176
+ $order_items = Mage::getResourceModel('sales/order_item_collection')
177
+ ->addAttributeToSelect('order_id')
178
+ ->addAttributeToSelect('created_at')
179
+ ->addFieldToFilter('created_at', array(
180
+ 'from' => strtotime('-30 day', time()),
181
+ 'to' => time(),
182
+ 'datetime' => true
183
+ ))
184
+ ->load();
185
+ return count($order_items);
186
+ }
 
 
 
 
187
  /*************************************/
188
  # fetching category keywords saved
189
  # by user
190
  /*************************************/
191
+ public function getCategoryKeywords(){
192
+ $collection =Mage::getModel('munoz/keyword')->getCollection();
193
+ $collection->addFieldToFilter('keyword_type','category');
194
+ return $collection;
195
+ }
196
  /*************************************/
197
  # fetching tips saved by user
198
  /*************************************/
199
+ public function getAddTips(){ // fetching tips saved by user
200
+ $keyword =Mage::getModel('munoz/keyword')->getCollection();
201
+ $keyword->addFieldToFilter('keyword_type','calltoaction');
202
+ return $keyword;
203
+ }
204
  /*************************************/
205
  # fetching orders
206
  /*************************************/
207
+ public function getOrders(){
208
+ $collection = Mage::getModel('sales/order')->getCollection()
209
+ ->addFieldToFilter('status', 'complete');
210
+ $collection->getSelect()->order('entity_id DESC')->limit(50);
211
+ return $collection;
212
+ }
213
  /*************************************/
214
  # fetching Admin Detail
215
  /*************************************/
216
+ public function getAdminDetail(){
217
+ $userArray = Mage::getSingleton('admin/session')->getData();
218
  // get individual data
219
+ return $user = Mage::getSingleton('admin/session');
220
+ }
221
  /*************************************/
222
  # fetching category selected by users
223
  /*************************************/
224
+ public function getCategory($check, $unselect){
225
+ $cate=array();
226
+ $all_cat = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter()
227
+ ->addAttributeToFilter('is_active', 1)
228
+ ->addAttributeToSort('position', 'desc');
229
+ if($check){
230
+ $all_cat->addIdFilter($check);
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  }
232
+ if($unselect){
233
+ $all= Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter()
234
+ ->addAttributeToFilter('is_active', 1)
235
+ ->addAttributeToSort('position', 'desc');
236
+ foreach($all as $select_cat){
237
+ array_push($cate,$select_cat->getId());
238
+ }
239
+ $final_cat = array_diff($cate, $unselect);
240
+ $all_cat->addIdFilter($final_cat);
241
+ $preId=$final_cat;
242
+ }
243
+ return $all_cat;
244
+ }
245
  /*************************************/
246
  # fetching product selected categories
247
  /*************************************/
248
+ public function getProductById($check, $unselect){
249
+ set_time_limit(600);
250
+ return $collection = Mage::getModel('catalog/product')
251
+ ->getCollection()
252
+ ->addAttributeToFilter('status', array('eq' => 1))
253
+ //->setPageSize(20)
254
+ ->addAttributeToSelect(array('name','price'))
255
+ ->joinField('qty',
256
+ 'cataloginventory/stock_item',
257
+ 'qty',
258
+ 'product_id=entity_id',
259
+ '{{table}}.stock_id=1',
260
+ 'left'
261
+ )->addAttributeToFilter('qty', array('gt' => 0));
262
+ }
 
 
 
 
 
 
 
263
  /*************************************/
264
  # fetching all 2 level category
265
  /*************************************/
266
+ public function getAllLevelCat(){
267
+ $categories = Mage::getModel('catalog/category')->getCollection()
268
+ ->addAttributeToSelect('*')//or you can just add some attributes
269
+ ->addAttributeToFilter('level', 2);//2 is actually the first level
270
  return $categories;
271
+ }
 
272
  /*************************************/
273
  # fetching children category by id
274
  /*************************************/
275
+ public function getTreeCat($id){
276
+ return $children = Mage::getModel('catalog/category')->load($id)->getChildrenCategories();
277
+ }
 
278
  /*************************************/
279
  # fetching custom attribute
280
  /*************************************/
281
+ public function AttributeOptionArray()
282
+ {
283
+ return $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
284
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  /*************************************/
286
  # fetching attribute value by
287
  #attribute code
288
  /*************************************/
289
+ public function getAtrValue($code){
290
+ $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product',$code);
291
+ $collection =Mage::getResourceModel('eav/entity_attribute_option_collection')
292
+ ->setPositionOrder('asc')
293
+ ->setAttributeFilter($attributeId)
294
+ ->setStoreFilter(0)
295
+ ->load();
296
+ return $collection = $collection->toOptionArray();
297
+ }
298
  /*************************************/
299
  # fetching product tag custmer and admin
300
  /*************************************/
301
+ public function TagProduct(){
302
+ $tag_model= Mage::getModel('tag/tag');
303
+ $tag_collection= $tag_model->getResourceCollection()->load();
304
+ return $mytags=$tag_collection->getItems();
305
+ }
 
306
  /*************************************/
307
  # fetching product by tag id
308
  /*************************************/
309
 
310
+ public function getProductIdByTag($tagId){
311
+ $collection = Mage::getResourceModel('tag/product_collection') ->addTagFilter($tagId);
312
+ foreach($collection->getData() as $prd)
313
+ {
314
+ return $prd['entity_id'];
 
 
315
  }
316
+ }
317
  /*************************************/
318
  # fetching all category
319
  /*************************************/
320
+ function getTreeCategories($parentId, $isChild){
321
+ $allCats = Mage::getModel('catalog/category')->getCollection()
322
+ ->addAttributeToSelect('*')
323
+ ->addAttributeToFilter('is_active','1')
324
+ ->addAttributeToFilter('include_in_menu','1')
325
+ ->addAttributeToFilter('parent_id',array('eq' => $parentId));
326
+ return $allCats;
327
+ }
 
 
328
  /*************************************/
329
  # fetching product rellational category
330
  /*************************************/
331
+ public function getRelationalCat($productIds){
332
+ $cat =Mage::getModel('catalog/category')->load($productIds);
333
+ return $cat->getId();
334
+
335
+ }
336
  /*************************************/
337
  # fetching product aatribute
338
  #by product id
339
  /*************************************/
340
 
341
+ public function getProductAtribute($productId){
342
+ $attr_array=array();
343
+ $product = Mage::getModel('catalog/product')->load($productId);
344
+ //$attributes = $product->getAttributes();
345
+ $count=1;
346
+ foreach($this->prd_atr_code as $attrcode){
347
+ $attribute_value = $product->getData($attrcode);
348
+ if(!$attribute_value){
349
+ $attribute_value='null';
350
+ }
351
+ array_push($attr_array,array('value'=>$attribute_value,'label'=>'opt'.$count.'_id','pid'=>$productId));
352
+ $count++;
 
 
353
  }
354
+ return $attr_array;
355
+ }
356
  /*************************************/
357
  # fetching product stock
358
  #by product id
359
  /*************************************/
360
+ public function getPorductStock($product_id){
361
+ $model = Mage::getModel('catalog/product');
362
+ $_product = $model->load($product_id);
363
+ return $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
364
+ }
365
  /*************************************/
366
  # fetching product ids by category id
367
  /*************************************/
368
+ public function getProductIds($catid){
369
+ $category = new Mage_Catalog_Model_Category();
370
+ $category->load($catid); //My category id is 6
371
+ $prodCollection = $category->getProductCollection();
372
+ foreach ($prodCollection as $product) {
373
+ $prdIds[] = $product->getId(); //Array to store all the product ids
 
 
374
  }
375
+ return $prdIds;
376
+ }
377
  /**********************************/
378
  # First API send basic information
379
  # product categorry relations
380
  /*********************************/
381
 
382
  public function setDataInFirstApi($Allcategory,$order,$admin,$tips,$category,$budget,$countries,$created){
383
+ $stores =array();
384
+ foreach(Mage::app()->getStores() as $store) {
385
+ array_push($stores,$store->getName().',');
386
+ }
387
+ $all_store =implode(" ",$stores);
388
+ $info['id']='';
389
+ $info['clientId']=$this->_getClient_id();
390
+ $info['name_ascii']='';
391
+ $info['info_type']='';
392
+ $info['owner']=$admin->getUser()->getFirstname() .' '.$admin->getUser()->getLastname();
393
+ $info['email']=$admin->getUser()->getEmail();
394
+ $info['phone']=Mage::getStoreConfig('general/store_information/phone');
395
+ $info['domain']=$_SERVER['HTTP_HOST'];
396
+ $info['main_language']=Mage::app()->getLocale()->getLocaleCode();
397
+ $info['currency']=Mage::app()->getStore()->getCurrentCurrencyCode();
398
+ $info['adwordsId']='';
399
+ $info['budget']=$budget;
400
+ $info['camp_by_default']='1';
401
+ $info['country']=Mage::getStoreConfig('general/country/default');;
402
+ $info['city']=Mage::getStoreConfig('general/store_information/address');
403
+ $info['province']='';
404
+ $info['city']='';
405
+ $info['zip']='';
406
+ $info['latitude']='';
407
+ $info['longitude']='';
408
+ $info['iana_timezone']=Mage::getStoreConfig('general/locale/timezone');
409
+ $info['gender']='';
410
+ $info['device']='';
411
+ $info['age']='';
412
+ $info['platform']='Magento';
413
+ $info['created_at']=$created;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  $params= array('info'=>json_encode($info));
415
  $this->_postCurl(self::create_ecommerce_info ,$params);
416
 
417
  }
 
418
  /***********************/
419
  # Second Api send Dim_prod
420
  # product categorry relations
421
  /***********************/
 
422
  public function setDataDimColl(){
423
  $cat_id=array();
424
+ $treeacat_id=array();
 
425
  for( $catLevel=1; $catLevel <= 5; $catLevel++ ){ // loop for
426
+ if($catLevel >1){ // second dim_coll
427
+ $treeacat_id=array();
428
+ $i=0;
429
+ if(!empty($cat_id)){
430
+ foreach($cat_id as $treeCat){
431
+ $all_Tree_cat = $this->getTreeCat($treeCat);
432
+ foreach($all_Tree_cat as $Cat_Tree){
433
+ array_push($treeacat_id,$Cat_Tree->getId());
434
+ $dim_colls[$i]['id'] ='';
435
+ $dim_colls[$i]['clientId']=$this->_getClient_id();
436
+ $dim_colls[$i]['product_ids']=$this->getProductIds($Cat_Tree->getId());
437
+ $dim_colls[$i]['collId']= $Cat_Tree->getId();
438
+ $dim_colls[$i]['coll_name']=$Cat_Tree->getName();
439
+ $dim_colls[$i]['published']= $Cat_Tree->getIsActive();
440
+ $dim_colls[$i]['main_image']=$Cat_Tree->getThumbnail();
441
+ $dim_colls[$i]['coll_url']=$Cat_Tree->getUrl();
442
+ $dim_colls[$i]['parent_id']=$this->_getParentId($Cat_Tree->getId());
443
+ $dim_colls[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
444
+ $i++;
445
+ }
446
+ $params= array('dim_coll'.$catLevel=>json_encode($dim_colls));
447
+ }
448
+ $ch = curl_init();
449
+ curl_setopt($ch, CURLOPT_URL, "http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_coll".$catLevel);
450
+ //return the transfer as a string
451
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
452
+ curl_setopt($ch, CURLOPT_POST, true);
453
+ // curl_setopt($ch, CURLOPT_HTTPGET, 1);
454
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
455
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
456
+ curl_setopt($ch,CURLOPT_TIMEOUT,400);
457
+ $output = curl_exec($ch);
458
+ curl_close($ch);
459
+ $json_a =json_decode($output,true);
460
+ $dim_colls=null;
461
+ }
462
+ $cat_id=$treeacat_id;
463
+ // api six, seven ,eight, nine
464
+ }// end catlavel
465
+ else{
466
+ $all_cat = $this->getAllLevelCat();
467
+ if(count($all_cat) >0){
468
+ $j=0;
469
+ foreach ($all_cat as $category_first_level){
470
+ $dim_coll[$j]['id']='';
471
+ $dim_coll[$j]['clientId']=$this->_getClient_id();
472
+ $dim_coll[$j]['coll_level'] ='1';
473
+ $dim_coll[$j]['collId']= $category_first_level->getId();
474
+ $dim_coll[$j]['product_ids']= $this->getProductIds($category_first_level->getId());
475
+ $dim_coll[$j]['coll_name']=$category_first_level->getName();
476
+ $dim_coll[$j]['coll_url']=$category_first_level->getUrl();
477
+ $dim_coll[$j]['published']= $category_first_level->getIsActive();
478
+ $dim_coll[$j]['main_image']=$category_first_level->getThumbnail();
479
+ $dim_coll[$j]['parent_id']='0';
480
+ $dim_coll[$j]['lang']=Mage::app()->getLocale()->getLocaleCode();
481
+ array_push($cat_id,$category_first_level->getId());
482
+ $j++;
483
+ } // end foreach
484
+ } // end if
485
+ $params= array('dim_coll1'=>json_encode($dim_coll));
486
+ $this->_postCurl('http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_coll1' ,$params);
487
+ }// end else
488
+ } // end main foreach loop
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  }
 
490
  /***********************/
491
  # Third API
492
  # product option relations
493
  /***********************/
494
  public function dimOption(){
495
+ $count=1;
496
+ $product_attribute =$this->AttributeOptionArray();
497
+ if(count($product_attribute) >0){
498
+ foreach($product_attribute as $prdAtr){
499
+ if(!in_array($prdAtr->getAttributecode(),getDefaultAttribute())){
500
+ $attributeValue=$this->getAtrValue($prdAtr->getAttributecode());
501
+ if(count($attributeValue) > 0){
502
+ if($count < 11){
503
+ $i=0;
504
+ array_push($this->prd_atr_code, $prdAtr->getAttributecode());
505
+ foreach($attributeValue as $option){
506
+ $dimProduct[$i]['id']='';
507
+ $dimProduct[$i]['clientId']=$this->_getClient_id();
508
+ $dimProduct[$i]['optId']=$option['value'];
509
+ $dimProduct[$i]['opt_name']=$option['label'];
510
+ $dimProduct[$i]['opt_url']='';
511
+ $dimProduct[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
512
+ $i++;
513
+ }
514
+ $params= array('dim_opt'.$count=>json_encode($dimProduct));
515
+ $ch = curl_init();
516
+ curl_setopt($ch, CURLOPT_URL, "http://manager.cleverppc.com/api/ecommerce/v1/create_ecommerce_dim_opt".$count);
517
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
518
+ curl_setopt($ch, CURLOPT_POST, true);
519
+
520
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
521
+ $output = curl_exec($ch);
522
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
523
+ curl_setopt($ch,CURLOPT_TIMEOUT,0);
524
+ // close curl resource to free up system resources
525
+ curl_close($ch);
526
+ $json_a =json_decode($output,true);
527
+ $count++;
528
+ $dimProduct=null;
529
+ }// end for each
530
+ }
531
+ } // end In_array
532
+ }// end foreach
533
+ } // end count
 
 
 
 
 
 
 
 
534
 
535
 
536
  }
541
  # product name relations
542
  /***********************/
543
  public function rellProductColl($Allprodcut){
544
+ // set_time_limit(600);
545
+ $i=0;
546
+ $prd_name=array();
547
+ foreach ($Allprodcut as $product) {
548
+ //if(($product->getName() > 0) && ($product->getQty() >0)){
549
+ if (!in_array($product->getName(), $prd_name)) {
550
+ $dim_prod[$i]['id']='';
551
+ $dim_prod[$i]['clientId']=$this->_getClient_id();
552
+ $dim_prod[$i]['prodId']=$product->getId();
553
+ $dim_prod[$i]['prod_name']=$product->getName();
554
+ $dim_prod[$i]['prod_url']=$product->getProductUrl();
555
+ $dim_prod[$i]['prod_price']=$product->getPrice();
556
+ $dim_prod[$i]['barcode']='';
557
+ $dim_prod[$i]['sku']=$product->getSku();
558
+ $dim_prod[$i]['meta']=$product->getMetaKeyword();
559
+ $dim_prod[$i]['published']=$product->getStatus();
560
+ $dim_prod[$i]['inv']='';
561
+ $dim_prod[$i]['inv_num']=$product->getQty();
562
+ $dim_prod[$i]['updated']=$product->getUpdatedAt();
563
+ $dim_prod[$i]['main_image']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' .$product->getImage();
564
+ $dim_prod[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
565
+ array_push($prd_name,$product->getName());
566
+ $i++;
567
+ }
568
+ }
569
+ // }
570
  $params= array('dim_prod'=>json_encode($dim_prod));
571
+ $this->_postCurl(self::create_ecommerce_dim_prod ,$params);
 
572
  }
 
573
  /***********************/
574
  # product categorry relations
575
  /***********************/
576
  public function rel_prod_coll($Allprodcut){
577
+ $i=0;
578
+ if(count($Allprodcut) >0){ // product category collections
579
+ foreach($Allprodcut as $rellAtionPro){
580
+ if(count($rellAtionPro->getCategoryIds()) >0){
581
+ $coll_id=1;
582
+ foreach ($rellAtionPro->getCategoryIds() as $rellCatIds){
583
+ $rel_prod_coll[$i]['id']='';
584
+ $rel_prod_coll[$i]['clientId']=$this->_getClient_id();
585
+ $rel_prod_coll[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
586
+ $rel_prod_coll[$i]['prodId']=$rellAtionPro->getId();
587
+ $rel_prod_coll[$i]['coll'.$coll_id.'Id']=$this->getRelationalCat($rellCatIds);
588
+ $coll_id++;
589
+ }
590
+
591
+ }
592
+ $i++;
593
+ }
594
+ } // end product categorry collections
595
+ $params= array('rel_prod_coll'=>json_encode(array_values($rel_prod_coll)));
596
+ $this->_postCurl(self::create_ecommerce_rel_prod_coll ,$params);
597
+
 
 
 
598
  }
 
599
  /***********************/
600
  # product categorry relations
601
  /***********************/
602
  public function rel_prod_opt($Allprodcut){
603
+ if(count($Allprodcut) >0){ // prodcut option
604
+ $k=0;
605
+ $prdt_name=array();
606
+ foreach($Allprodcut as $rellAttrProdcut){
607
+ if (!in_array($rellAttrProdcut->getName(), $prdt_name)) {
608
+ $rellProAtr =$this->getProductAtribute($rellAttrProdcut->getId());
609
+ if(count($rellProAtr) >0){
610
+ $attrCol=1;
611
+ foreach($rellProAtr as $atrFetch){
612
+ $rel_prod_opt[$k]['id']='';
613
+ $rel_prod_opt[$k]['clientId']=$this->_getClient_id();
614
+ $rel_prod_opt[$k]['lang']=Mage::app()->getLocale()->getLocaleCode();
615
+ $rel_prod_opt[$k]['prodId']=$rellAttrProdcut->getId();
616
+ $rel_prod_opt[$k]['opt'.$attrCol.'Id']=$atrFetch['value'];
617
+ $attrCol++;
618
+ }// end foreach
619
+ }
620
+
621
+ }else{
622
+ $rellProAtr =$this->getProductAtribute($rellAttrProdcut->getId());
623
+ if(count($rellProAtr) >0){
624
+ $attrCol=1;
625
+ foreach($rellProAtr as $atrFetch){
626
+ $rel_prod_opt[$k]['id']='';
627
+ $rel_prod_opt[$k]['clientId']=$this->_getClient_id();
628
+ $rel_prod_opt[$k]['lang']=Mage::app()->getLocale()->getLocaleCode();
629
+ $rel_prod_opt[$k]['prodId']= end($prdt_name);
630
+ $rel_prod_opt[$k]['opt'.$attrCol.'Id']=$atrFetch['value'];
631
+ $attrCol++;
632
+ }// end foreach
633
+ }
634
+
635
+ }
636
+ array_push($prdt_name,$rellAttrProdcut->getName(),$rellAttrProdcut->getId());
637
+ // end foreach
638
+ $k++;
639
+
640
+ }
641
+
642
+ } //end prodcut option
643
+ $rell_pro_opts= array('rel_prod_opt'=>json_encode(array_values($rel_prod_opt)));
644
+ $rel =$this->_postCurl(self::create_ecommerce_rel_prod_opt ,$rell_pro_opts);
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  }
646
  /***********************/
647
  # second API send name
650
  $m=0;
651
  $rel_prod_name[0]['Id']='';
652
  $rel_prod_name[0]['clientId']=$this->_getClient_id();
 
653
  for($i=1; $i<6; $i++){
654
  $rel_prod_name[0]['coll'.$i.'_id']='';
655
  }
656
 
657
+ $j=1;
658
  foreach($this->prd_atr_code as $prdatrr){
659
  $rel_prod_name[0]['opt'.$j.'_id']=$prdatrr;
660
  $j++;
661
  }
662
+ $rel_prod_name[0]['lang']=Mage::app()->getLocale()->getLocaleCode();
663
+ $name= array('name'=>json_encode(array_values($rel_prod_name)));
664
+ $this->_postCurl(self::create_ecommerce_name ,$name);
665
 
666
  }
667
 
677
  $ad_tip[$j]['lang']=Mage::app()->getLocale()->getLocaleCode();
678
  $j++;
679
  }
680
+ $ad_tips= array('ad_tip'=>json_encode($ad_tip));
681
+ $this->_postCurl(self::create_ecommerce_ad_tip ,$ad_tips);
682
 
683
 
684
  }
697
  $EcommerceKeyword[$i]['lang']=Mage::app()->getLocale()->getLocaleCode();
698
  $i++;
699
  }
700
+ $params= array('keyword'=>json_encode($EcommerceKeyword));
701
+ $this->_postCurl(self::create_ecommerce_keyword ,$params);
702
 
703
  }
704
  /***********************/
706
  /***********************/
707
  public function orderApi(){
708
  $k=0;
709
+ $order =$this->getOrders();
710
+ foreach( $order as $orders){
711
  $Order[$k]['id']='';
712
  $Order[$k]['clientId']=$this->_getClient_id();
713
  $Order[$k]['productId']=$orders->getEntityId();
715
  $Order[$k]['order_quantity']=$orders->getTotalQtyOrdered();
716
  $Order[$k]['order_price']=$orders->getTotalPaid();
717
  $k++;
718
+
719
  }
720
+ $params= array('order'=>json_encode($Order));
721
+ $this->_postCurl(self::create_ecommerce_order ,$params);
722
 
723
 
724
  }
725
  public function saveStaus(){
726
  $collection =Mage::getModel('munoz/keyword')->getCollection();
727
+ $collection->addFieldToFilter('keyword_title','complete');
728
+ if(count($collection)>0){
729
+ $res= Mage::getModel('munoz/keyword')->load('complete','keyword_title');
730
+ $res->setKeywordTitle('complete');
731
+
732
+ $res->setCreatedAt(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
733
+ }
734
+ else{
735
+ $res =Mage::getModel('munoz/keyword');
736
+ $res->setKeywordTitle('complete');
737
+ $res->setCreatedAt(date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())));
738
+ }
739
+ try
740
+ {
741
+ $result = $res->save();
742
+ }
743
+ catch(Exception $e)
744
+ {
745
+ $error=$e;
746
+ }
747
  }
748
  public function setSteps(){
749
  $cleint_id=$this->_getClient_id();
750
+ $url="http://manager.cleverppc.com/api/ecommerce/v1/last_step_status?client_token=".$cleint_id."&last_step=5&waiting=1";
751
+ $data = file_get_contents($url);
752
+ $json_a=json_decode($data,true);
 
 
753
  }
754
 
755
  public function stat_time_api(){
756
  $cleint_id=$this->_getClient_id();
757
  $url=self::check_finish_process_time."?client_token=".$cleint_id."&start=1";
758
  $data = file_get_contents($url);
759
+ $json_a=json_decode($data,true);
 
760
  }
 
 
761
  public function sendCountry($country_code){
762
+ $selected_country = explode(",", $country_code);
763
+ $i=0;
764
  foreach($selected_country as $countries){
765
  $countryName = Mage::getModel('directory/country')->loadByCode($countries)->getName();
766
  $country[$i]['id']='';
767
  $country[$i]['clientId']=$this->_getClient_id();
768
+ $country[$i]['ctry_iso_2']=$this->_IsoCountryCode($countryName,$countries);
769
  $country[$i]['ctry_name']= $countryName;
770
  $country[$i]['ctry_GgId']='';
 
771
  $i++;
772
  }
773
+ $params= array('country'=>json_encode($country));
774
+ $this->_postCurl(self::create_ecommerce_country ,$params);
 
775
 
776
  }
777
+ public function _IsoCountryCode($countryName,$countries){
778
+ $allLanguages = Mage::app()->getLocale()->getOptionLocales();
779
+ foreach($allLanguages as $key=>$value){
780
+ $ct=explode('(',$value['label']);
781
+ if (in_array($countryName.")", $ct)) {
782
+ if($value['value']){
783
+ return $value['value'];
784
+ }
785
+ else{
786
+ return $countries;
787
+ }
788
+ }
789
+ }
790
+ }
791
  // curl function /////////
792
  public function _postCurl($url , $params){
793
  $ch = curl_init();
800
  // $output contains the output string
801
  $output = curl_exec($ch);
802
  curl_close($ch);
803
+ return $json_a =json_decode($output,true);
804
+ }
 
 
 
 
805
 
806
+ public function _getClient_id() {
807
+ $url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
808
+ $disallowed = array('http://', 'https://');
809
+ foreach($disallowed as $d) {
810
+ if(strpos($url, $d) === 0) {
811
+ $u =str_replace($d, '', $url);
812
+ $url =str_replace('/', '', $u);
 
 
 
813
  return md5($url);
814
+ }
815
+ }
816
+ return md5($url);
817
+ }
818
+
819
+ public function _getParentId($ids){
820
+ if ($ids){
821
+ $topParent = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($ids);
822
+ }
823
+ else{
824
+ $topParent = null;//it means you are in one catalog root.
825
+ }
826
+ return $topParent['parent_id'];
827
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
828
  // end curl ///////
 
 
829
  public function end_time_api(){
830
  $cleint_id=$this->_getClient_id();
831
  $url=self::check_finish_process_time."?client_token=".$cleint_id."&stop=1";
833
  $json_a=json_decode($data,true);
834
 
835
  }
 
 
836
  }
837
  $wholekeyword=$this->getRequest()->getParams();
838
  $shell = new Rodrigo_Shell_MyApi($wholekeyword);