Grid column does not work on Server - php

I want to add a column in order grid whose value come from another block.
The code I used in Grid.php are as given below :
$this->addColumn('sum_total', array(
'header' => Mage::helper('sales')->__('G.T.Used'),
'column_css_class' => 'a-right',
'type' => 'currency',
'currency' => 'base_currency_code',
'renderer' => 'Marketplace_Mpshippingmanager_Block_Adminhtml_Sumtotal'
));
Here is the code used in block :
class Marketplace_Mpshippingmanager_Block_Adminhtml_Sumtotal extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function input_render(Varien_Object $row)
{
//echo '$'.(float)($row['base_subtotal']-$row['base_grand_total']);
printf("$%.2f", ($row['base_subtotal'] - $row['base_grand_total']));
}
}
It work on localhost but make problem on server.
why?
If some one help is more appreciable.

Is localhost windows? Server Linux? I can't say for certain but I ran into this earlier in the week turned out Windows is case insensitive and Linux is case sensitive. The Varien Autoloader which parses all classnames and strings was throwing in '\' where I didn't want them and magento could not find my files.
I do not know if this helps but, it was so similar to my problem I figured I would put in my 2 cents. Here was my thread with the problem explained by a much smarter person. https://stackoverflow.com/questions/30085012/magento-mass-action-grid-does-not-update

Related

Returning Three Dimensional Associative Arrays with PHP

I suppose I am a noob with PHP so apologies if I sound dumb, but, I do have a troubling dilemma, I have spent the last six hours plus scouring Google for any hints and found none so here I am on the SO forum looking for some 'pointers' in the right direction.
I have an issue with returning 3DAA's from a function in a class to other parts of my code and no matter what I try I'm getting a null value back, according to the error log anyway, but when I run this code separately from the framework, in a single file using the same declarations it miraculously starts working and echos the specified part of the array to the screen wahey, but I don't know why it suddenly works nor why it won't work in the framework and supplies a null value.
I was wondering if anyone out there has experienced such weird errors with returning 3DAA's and if so, how they got around it. If you want to see the code ask and I'll post it.
<?php
class Core {
public function GetConfiguration() {
$configuration = array(
"cobalt" => array(
"name" => 'Cobalt',
"version" => '1.0.7',
"directory" => array(
"root" => 'application',
"modules" => 'application/modules',
"html" => 'application/html'
)
),
"application" => array(
"name" => 'Cardinal Technologies',
"version" => '1.0.2',
"server" => 'http://localhost',
"seo" => array(
"copyright" => 'Ida Boustead',
"description" => 'Welcome to Cardinal Technologies, here at Cardinal Technologies we pride ourselves in providing the best possible customer service whether you need a repair or upgrade for a computer, android phone or tablet, even alarms and CCTV',
"keywords" => 'computer repair,computer upgrade,computer upgrades,android phone repair,phone repair,android tablet repair,tablet repair,alarms,cctv,network installation,network install',
"robots" => 'index,follow'
)
)
);
return $configuration;
}
public function LoadModule($module) {
require_once 'application/modules/' . $module . '.class.php';
}
}
?>
Hope this helps.
I'm calling it like this.
require_once 'application/Core.class.php';
$core = new Core();
$configuration = $core->GetConfiguration();
and getting an array value like this.
$dir = $configuration['cobalt']['directory']['html'];
the prior is a snippet from a larger file but this is what relates to that function.
I get PHP Notice: Undefined variable: dir in the log which is what led me to believe the function was the problem.
If I echo $dir it echos application/html which is what it's supposed to, but it is not usable for anything other than echo which is pointless to me as I need that value to make other parts of the framework work.
Right it was me being a dumb dumb, I put the declarations in the wrong place, outside of the class and it did not like it.
I moved them to inside of each function that stalled the code and it fixed that issue. Thanks anyway.

Drupal 8.1.1 - Migrate 3400 INSERT (from sql) to custom content type

I need migrate 3400 rows from phpMyAdmin export to a custom content type over Drupal 8.
I tried to do with migration modules but, for example Migrate Plus and Migrate Tools are not compatible with my version of Drupal (8.1.1)
I wanted to import records using a PHP script.
I have tried many things but in many cases I said "undefined function" (by using, for example, entity_create) and more evidence I've done.
Example 1:
$new_page_values = array();
$new_page_values['type'] = 'my_content_type';
$new_page_values['title'] = "Titulo";
$new_page_values['path'] = "Path";
$new_page = entity_create('node', $new_page_values);
$new_page->save();
Example 2
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$node = \Drupal\node\Entity\Node::create(array(
'type' => 'article',
'title' => 'The title',
'langcode' => $language,
'uid' => 1,
'status' => 1,
'body' => array('The body text'),
'field_date' => array("2000-01-30"),
//'field_fields' => array('Custom values'), // Add your custon field values like this
));
$node->save();
Example 3:
db_insert('example_entity')
->fields(array(
'type' => $entity->getEntityTypeId(),
'id' => $entity->id(),
'created' => REQUEST_TIME,
'updated' => REQUEST_TIME,
))
->execute();
I'm trying to run a .php file from the server console (php updateData.php)
Thanks and regards.
Javier, the migration in D8 is still a WIP.
My advise:
install the latest Drupal 8.1,
install the latest modules for migrate_tools, migrate_plus, migrate_source_csv and migrate_source_json. Preferably the latest beta-versions.
change your phpAdmin output to a csv-file.
Perhaps you need to create your custom entity. Migrate_tools has 2 examples for the migration. It also contains a csv example. The migration-process should seamlessly import your stuff.
Tips: YAML-files are extremely sensitive for grammatics such as spaces. And you shouldn't have to identify an external/migration database. But remember, what ever worked yesterday, today may be different. I am working on my migration for the last 6 months.
Migration process is a completely different story then the D7 one.
Edited: install Drush 8. Use Composer for the easy way. Drush is needed to run the migration script from commandline, manifest is obsolete.
Edited 2: IMO the best explanation for and why using the D8 migration.
Look at this site https://blog.liip.ch/archive/2016/05/04/using-the-new-drupal-8-migration-api-module.html. Your wish to use your own PHP seems mainly because you can't seem to use D8's migration?

PHP Sagepay iframe integration

I want to make my website payments via sagepay. The problem is I am not able to locate all the things in the PHPKit they provide. The version of the kit is 3.0 and I want to configure iframe integration but when I open the test method there is this piece of code
$view = new HelperView('server/low_profile');
$view->setData(array(
'env' => $this->sagepayConfig->getEnv(),
'vendorName' => $this->sagepayConfig->getVendorName(),
'integrationType' => $this->integrationType,
'request' => HelperCommon::getStore('txData'),
));
$view->render();
I want to locate those keys 'env', 'vendorName', 'integrationType', 'requests' and see how to put them to use in my system. I see this syntax in a lo of places
public function setSagepayConfig(SagepaySettings $sagepayConfig)
{
$this->sagepayConfig = $sagepayConfig;
}
But I don't know what SagepaySettings means and how to trace it. Can you tell me where can I find SagepaySettings, or what does this mean. Is it a class or method or attribute, because I cannot find it in all the files as any of those.
It's a class in \lib\classes\settings.php

Using Mango within a unit test in Kohana

So I'm switching our application to use Mango rather than the built in ORM within Kohana. I've switched over all the necessary application code to work as expected, but when our CI server runs through our unit tests, I get a "Class 'Mango' not found" error.
Tests provided are dumbed down, but the style I use in the UnitTest is exactly the same way I use them in a regular GET request. It works when I do a GET, but the unit test fails. Now hopefully unrelated, I cannot reproduce this locally, but can't ever get the unit test to work on our CI server.
My guess is that I'm not loading the module properly, but like I said, it works correctly in the application and only my unit tests are failing (with FATAL ERRORs).
application/classes/Model/User.php
class Model_User extends Mango {
protected $_fields = array(
'user_id' => array('type' => 'string', 'required'=>TRUE),
'first_name' => array('type' => 'string', 'required'=>TRUE),
'last_name' => array('type' => 'string', 'required'=>TRUE),
);
}
application/tests/UserTest.php
Class UserTest extends Unittest_TestCase
{
public function testUserCreation()
{
$user_data = array(
"user_id" => "1234asdf",
"first_name" => "Test",
"last_name" => "User",
);
$new_user = Mango::factory("User", $user_data);
$this->assertEquals($user_data, $new_user->as_array());
}
}
EDIT: Here's a link to the Mango module I've brought in: https://github.com/Wouterrr/MangoDB
If anyone stumbles upon this via google, I solved the issue. It appears as though our applications nginx config handles capitalizations more nicely than the CLI. Upon changing "Mango" to "mango" I saw the error message change to not finding it's parent class (for the same casing reasons). While I imagine I could have just changed all the casing, Kohana has a function for casing issues, so in application/bootstrap.php, you just have to run both of the following:
spl_autoload_register(array('Kohana', 'auto_load'));
spl_autoload_register(array('Kohana', 'auto_load_lowercase'));

Add LDAP entry to Active Directory via ext/ldap

Using ext/ldap I'm trying to add entries to an Active Directory. As long as I only use one single structural objectClass everything works as expected, but as soon as I try to add an entry with a second auxiliary objectClass, the server reports an error:
Server is unwilling to perform; 00002040: SvcErr: DSID-030F0AA0,
problem 5003 (WILL_NOT_PERFORM), data
0
The following code works:
ldap_add($ldap, 'OU=Test,OU=Test,DC=domain,DC=example,DC=local', array(
'ou' => 'Test',
'objectClass' => 'organizationalUnit',
'l' => 'location'
));
This doesn't:
ldap_add($ldap, 'OU=Test,OU=Test,DC=domain,DC=example,DC=local', array(
'ou' => 'Test',
'associatedDomain' => 'domain',
'objectClass' => array('organizationalUnit', 'domainRelatedObject'),
'l' => 'location'
));
The same happens if I try to add an auxiliary objectClass to an existing entry:
ldap_mod_add($ldap, 'OU=Test,OU=Test,DC=domain,DC=example,DC=local', array(
'associatedDomain' => 'domain',
'objectClass' => 'domainRelatedObject'
));
The corresponding error message is essentially the same
Server is unwilling to perform;
00002040: SvcErr: DSID-030508F8,
problem 5003 (WILL_NOT_PERFORM), data
0
As all other updating and adding operations work, I think the problem must be related to the objectClass attribute.
As I've not enough experience with Active Directories (I'm used to OpenLDAP):
Are there any known issues with objectClasses in Active Directory? Am I missing something here? Are there any restrictions that disallow adding e.g. domainRelatedObject to an organizationalUnit? What the heck 's going on here ;-)?
Just in case you're wondering: the domainRelatedObject is present in the Active Directory schema.
I just found that, in order to add dynamic (per-instance) aux classes, the forest functional level of the domain must be 2003.
You may not have permission to set the objectClass attribute. See whether you can attach the auxiliary class after creation, through ADSI Edit. If you can't, fix the permissions first (check the Properties tab in the Advanced view of Security settings)
I could attach this specific class right now, onto a organizationalUnit object, as a domain admin; so in principle, this is possible.

Categories