Skip to content

Instantly share code, notes, and snippets.

View brankoajzele's full-sized avatar

Branko Ajzele brankoajzele

View GitHub Profile
@brankoajzele
brankoajzele / gist:4473397
Created January 7, 2013 08:45
Fiskalizacija - Zaštitni kod
<?php
public function getZastKod($fiscalInvoice, $store, $invoice = null)
{
if ($invoice === null) {
$invoice = Mage::getModel('sales/order_invoice');
$invoice->load($fiscalInvoice->getInvoiceEntityId());
}
$cert = Mage::getModel('inchoo_fiskalizacija/cert');
@brankoajzele
brankoajzele / gist:4473378
Created January 7, 2013 08:38
Fiskalizacija - RacunZahtjev
<?php
public function generateRacunZahtjevXML($fiscalInvoice, $invoice, $store, $storniraj = false)
{
$helper = $this;
$grandTotal = floatval($invoice->getGrandTotal());
$PDV = $grandTotal * ($helper->getRacunPdvPorezStopa($store) / 100); /* Replace 25 with config option */
$ns = 'tns';
@brankoajzele
brankoajzele / gist:2793287
Created May 26, 2012 10:25
GIT ignore for Magento extensions (ignore all except extension files and directories)
*
!.gitignore
!app/
!app/code/
!app/code/community/
!app/code/community/MyCompany/
!app/code/community/MyCompany/Extension/
!app/code/community/MyCompany/Extension/*
@brankoajzele
brankoajzele / gist:2781404
Created May 24, 2012 12:56
Programatically create Magento order with tablerate shipping
<?php
require_once 'app/Mage.php';
Mage::app();
$quote = Mage::getModel('sales/quote')
->setStoreId(Mage::app()->getStore('default')->getId());
$product = Mage::getModel('catalog/product')->load(6); /* 6 => Some product ID */
@brankoajzele
brankoajzele / gist:2375887
Created April 13, 2012 11:05
Auto Adjust For Api Usage
public function apiautoadjustAction()
{
$username = $this->getRequest()->getParam('username', null);
$password = $this->getRequest()->getParam('password', null);
$response = new Varien_Object();
if ($username && $password) {
$user = Mage::getModel('admin/user')
->loadByUsername($username);
@brankoajzele
brankoajzele / gist:2375376
Created April 13, 2012 09:20
Automate Magento Connect Install Action
<?php
/**
* @author Branko Ajzele <[email protected], http://foggyline.net>
*/
public function automateMagentoConnectInstallAction($username, $password, $website, $packages)
{
/*
$username = 'MAGENTO-ADMIN-USER';
@brankoajzele
brankoajzele / gist:2366798
Created April 12, 2012 11:52
Example API call for Inchoo_Logviewer
$params = array();
$params['limitPage']['page'] = 1;
$params['limitPage']['rowCount'] = 200;
$params['order']['column'] = 'log_id';
$params['order']['direction'] = 'ASC';
$params['where']['condition'] = 'priority_name = "DEBUG"';
@brankoajzele
brankoajzele / gist:1956753
Created March 2, 2012 08:25
Magento, Fake your online customer number :)
//START Fake your online customer number
$countLimit = 200;
$fakedCount = $countLimit;
$countSelect = Mage::getModel('log/visitor_online')
->prepare()
->getCollection()
->getSelectCountSql();
$count = $countSelect->getAdapter()->fetchOne($countSelect);
<frontend>
<events>
<websiterestriction_frontend>
<observers>
<privon_websiterestriction_frontend>
<class>xxxxxxx/observer</class>
<method>allowFacebookApiThroughRestriction</method>
</privon_websiterestriction_frontend>
</observers>
</websiterestriction_frontend>
<a href="#" onclick="sendFacebookInvite();">Facebook Invite</a>
<script type="text/javascript">
//<![CDATA[
function sendFacebookInvite() {
FB.ui({
method: 'apprequests',
message: 'Pozivamo vas da se pridruzite __NAZIV_WEB_SITEA__.'}
);
}