Jump to content

Any PhPFreaks here that also know magento? Extend Data helper


HenkDeVries

Recommended Posts

Hope that there are some people around that can help me, I just started php so I am already saying sorry :-)

I created a license check for my custom magento module. It's all working fine when I test it but now I need to integrate it with my  module. 

One part needs to go in to the DataHelper the other in my frontend template file. 

 

I have checked some examples and what they do is extend the helper file and then get the variable in the frontend template file with $X= $this->helper('X')->X();

Code for in my frontend temlate file (just to test if it's working)

if ( $var === false ) {
   echo '<img style="float: center;height:300px;width:auto;" src="http://clipartist.info/Art/April/al_with_red_flag_cybergedeon_al_with_red_flag-999px.png" alt="">';
}

Working license check

function checkLicense($key, $url = null) {
	static $wsdl = 'x';

	if ($url == null) {
		$url = $_SERVER['HTTP_HOST'];
	}
	$clientOptions = array(
			'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
			//'trace'=> 1, // when the service b0rks, enable the tracing, for easier debugging
	);
	$client = new SoapClient($wsdl, $clientOptions);
	$params = array(
			'LicenseKey' => $key,
			'URL' => $url,
	);
	$checkLicenseResponse = $client->CheckLicense($params);
	return !empty($checkLicenseResponse->IsValid) && $checkLicenseResponse->IsValid === true;
}

$licensekey = Mage::getStoreConfig('SDOCP_options/module/enable_serial'); 
$url = '';
$var = checkLicense($licensekey, $url);

Custom Module Helper

<?php

class Magextension_Sdocp_Helper_Data extends Mage_Core_Helper_Abstract
{
	public function checkIsEnabled()
	{
		$flag	=	Mage::getStoreConfig('SDOCP_options/module/enabled'); 
		return $flag;
	}
	
	public function checkOutOfStockEnabled()
	{
		$flag	=	Mage::getStoreConfig('SDOCP_options/product_page/show_out_of_stock_product'); 
		return $flag;
	}
	
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.