Magento displays errors in server after upgrade - magento

I upgraded my magento site .the upgrading completed without errors.
But when i loading site in browser i got duplicate entry errors ,So i clear the database and again take the url in browser.But now i got this error:
Mage_Eav_Exception Object
(
[_messages:protected] => Array
(
)
[message:protected] => Maximum length of attribute code must be less then 30 symbols
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/magento_upgrade/app/Mage.php
[line:protected] => 579
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Eav/Model/Entity/Attribute.php
[line] => 158
[function] => exception
[class] => Mage
[type] => ::
[args] => Array
(
[0] => Mage_Eav
[1] => Maximum length of attribute code must be less then 30 symbols
)
)
[1] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/Abstract.php
[line] => 316
[function] => _beforeSave
[class] => Mage_Eav_Model_Entity_Attribute
[type] => ->
[args] => Array
(
)
)
[2] => Array
(
[file] => /var/www/magento_upgrade/app/code/community/Biebersdorf/CustomerOrderComment/sql/customerordercomment_setup/mysql4-install-0.0.3.php
[line] => 49
[function] => save
[class] => Mage_Core_Model_Abstract
[type] => ->
[args] => Array
(
)
)
[3] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/Resource/Setup.php
[line] => 624
[args] => Array
(
[0] => /var/www/magento_upgrade/app/code/community/Biebersdorf/CustomerOrderComment/sql/customerordercomment_setup/mysql4-install-0.0.3.php
)
[function] => include
)
[4] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/Resource/Setup.php
[line] => 421
[function] => _modifyResourceDb
[class] => Mage_Core_Model_Resource_Setup
[type] => ->
[args] => Array
(
[0] => install
[1] =>
[2] => 0.1.3
)
)
[5] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/Resource/Setup.php
[line] => 327
[function] => _installResourceDb
[class] => Mage_Core_Model_Resource_Setup
[type] => ->
[args] => Array
(
[0] => 0.1.3
)
)
[6] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/Resource/Setup.php
[line] => 235
[function] => applyUpdates
[class] => Mage_Core_Model_Resource_Setup
[type] => ->
[args] => Array
(
)
)
[7] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/App.php
[line] => 417
[function] => applyAllUpdates
[class] => Mage_Core_Model_Resource_Setup
[type] => ::
[args] => Array
(
)
)
[8] => Array
(
[file] => /var/www/magento_upgrade/app/code/core/Mage/Core/Model/App.php
[line] => 343
[function] => _initModules
[class] => Mage_Core_Model_App
[type] => ->
[args] => Array
(
)
)
[9] => Array
(
[file] => /var/www/magento_upgrade/app/Mage.php
[line] => 683
[function] => run
[class] => Mage_Core_Model_App
[type] => ->
[args] => Array
(
[0] => Array
(
[scope_code] =>
[scope_type] => store
[options] => Array
(
)
)
)
)
[10] => Array
(
[file] => /var/www/magento_upgrade/index.php
[line] => 87
[function] => run
[class] => Mage
[type] => ::
[args] => Array
(
[0] =>
[1] => store
)
)
)
[previous:Exception:private] =>
)
How can i solve this?
Or what i do here?

somewhere between the actual version of your Magento install and the one you're trying to upgrade to, Magento put a limit to the characters of the sku of the EAV attributes.
The error you have is because one of your attribute have more then 30 characters in his SKU.
One thing you can do is to override Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH and make it big enough so that the upgrade go on.
HTH

And for clarity, the full path to the file you want to edit is...
your-project/app/code/core/Mage/Eav/Model/Entity/Attribute.php CONST
ATTRIBUTE_CODE_MAX_LENGTH = 30;
put the CONST ATTRIBUTE_CODE_MAX_LENGTH = 30; to 60
Stolen from: Bijal Bhavsar

Related

Laravel group collection and sort by the biggest value

I have a Laravel collection with values, which I want to group by 'type' and sort by the biggest 'probability'. Here is how my collection looks like:
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => Array
(
[type] => correct-score
[name] => 1-1
[probability] => 10.599257670442
[probability_odd] => 10.142219704667
[odd] =>
[value_bet] => 0
[prognose_type_id] => 12
[value_bet_diff] => -10.142219704667
)
[1] => Array
(
[type] => 3-way
[name] => 1
[probability] => 52.459602877727
[probability_odd] => 2.0491958402842
[prognose_type_id] => 1
[odd] => 2.48
[value_bet_diff] => 0.4308041597158
)
[2] => Array
(
[type] => 3-way
[name] => 2
[probability] => 24.682032371379
[probability_odd] => 4.3553949845985
[prognose_type_id] => 1
[odd] => 2.66
[value_bet_diff] => -1.6953949845985
)
[3] => Array
(
[type] => 3-way
[name] => X
[probability] => 22.857984044926
[probability_odd] => 4.7029519221256
[prognose_type_id] => 1
[odd] => 3.7
[value_bet_diff] => -1.0029519221256
)
[4] => Array
(
[type] => double-chance
[name] => 1X
[probability] => 37.658793461327
[probability_odd] => 2.8545789739758
[prognose_type_id] => 4
[odd] => 1.49
[value_bet_diff] => -1.3645789739758
)
[5] => Array
(
[type] => double-chance
[name] => X2
[probability] => 23.770008208152
[probability_odd] => 4.5225058005294
[prognose_type_id] => 4
[odd] => 1.55
[value_bet_diff] => -2.9725058005294
)
[6] => Array
(
[type] => double-chance
[name] => 12
[probability] => 38.570817624553
[probability_odd] => 2.7870811826288
[prognose_type_id] => 4
[odd] => 1.29
[value_bet_diff] => -1.4970811826288
)
[7] => Array
(
[type] => both-to-score
[name] => yes
[probability] => 58.505776168275
[probability_odd] => 1.8374254140447
[prognose_type_id] => 8
[odd] =>
[value_bet_diff] => -1.8374254140447
)
I want to achieve as result something like that:
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => Array
(
[type] => correct-score
[name] => 1-1
[probability] => 10.599257670442
[probability_odd] => 10.142219704667
[odd] =>
[value_bet] => 0
[prognose_type_id] => 12
[value_bet_diff] => -10.142219704667
)
[1] => Array
(
[type] => 3-way
[name] => 1
[probability] => 52.459602877727
[probability_odd] => 2.0491958402842
[prognose_type_id] => 1
[odd] => 2.48
[value_bet_diff] => 0.4308041597158
)
[6] => Array
(
[type] => double-chance
[name] => 12
[probability] => 38.570817624553
[probability_odd] => 2.7870811826288
[prognose_type_id] => 4
[odd] => 1.29
[value_bet_diff] => -1.4970811826288
)
[7] => Array
(
[type] => both-to-score
[name] => yes
[probability] => 58.505776168275
[probability_odd] => 1.8374254140447
[prognose_type_id] => 8
[odd] =>
[value_bet_diff] => -1.8374254140447
)
Haven't been able to find similar solutions, so I finally decided to try here. Can you please help me?
Thanks in advance!
I think below can work;
$collection->sortByDesc('probability')->groupBy('type');
Sort by probability than group by type;
Probably better to do this in Eloquent, but as you have presented this as a collections problem;
assuming your collection is called $items
$sorted = $items->groupBy('type')
->map(function($group){
return $group->sortByDesc('probability')->take(1);
})
->flatten(1);
The most short:
$items = $collections
->sortByDesc('probability')
->unique('type');

How read pubdate field using willvincent/feeds plugin?

I use https://github.com/willvincent/feeds for reading rss and with all field I also need to get pubDate field.
iI did not find a method for it(I looked also in source app/library/AppRssImport.php file ) and I made some debugging, so methods
echo '<pre>$RssItem->data[\'child\']::'.print_r($RssItem->data['child'],true).'</pre>';
dd($RssItem->data['child']);
has next output:
$RssItem->data['child']::Array
(
[] => Array
(
[title] => Array
(
[0] => Array
(
[data] => Man died 'in agony' after stroke amid ambulance delays
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[description] => Array
(
[0] => Array
(
[data] => Michelle Lane has PTSD and flashbacks of her husband screaming in pain as they went to hospital by car.
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[link] => Array
(
[0] => Array
(
[data] => https://www.bbc.co.uk/news/uk-england-nottinghamshire-46795776
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[guid] => Array
(
[0] => Array
(
[data] => https://www.bbc.co.uk/news/uk-england-nottinghamshire-46795776
[attribs] => Array
(
[] => Array
(
[isPermaLink] => true
)
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[pubDate] => Array
(
[0] => Array
(
[data] => Thu, 10 Jan 2019 10:02:22 GMT
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
)
[http://search.yahoo.com/mrss/] => Array
(
[thumbnail] => Array
(
[0] => Array
(
[data] =>
[attribs] => Array
(
[] => Array
(
[width] => 1024
[height] => 576
[url] => http://c.files.bbci.co.uk/15CE0/production/_105121398_michelle-tony.jpg
)
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
)
)
and https://imgur.com/a/wTmd9cV
I tried to read value of pubDate field, but failed. This structure was rather strange for me...
Which is right decision ?
You can use the get_date() method to grab the value of pubDate?
https://github.com/willvincent/feeds this plugin is only a wrapper around SimplePie php extension. You can look into SimplePie documentation for all other available methods. http://simplepie.org/api/class-SimplePie_Item.html.
A usable code might be like this. I used laravel, so the first line of grabbing the feed might be different.
$feed = Feeds::make('https://www.example.com/feed/');
$items = $feed->get_items();
foreach( $items as $key => $item ) {
$title = $item->get_title();
$guid = $item->get_id();
$pub_date = $item->get_date();
}

i got this array from laravel controller now how to print this in laravel blade. because here is an array and inside this there is another array

Array (
[0] => Array ( [JobId] => 5990027 [DeliveryDate] => 2018-07-18T13:42:54)
[1] => Array ( [JobId] => 5990042 [DeliveryDate] => 2018-07-18T12:51:53.483 )
[2] => Array ( [JobId] => 5990043 [DeliveryDate] => 2018-07-18T12:51:53.51 )
[3] => Array ( [JobId] => 5990060 [DeliveryDate] => 2018-07-18T12:56:11 )
[4] => Array ( [JobId] => 5990101 [DeliveryDate] => 2018-07-18T13:05:57 )
[5] => Array ( [JobId] => 5990102 [DeliveryDate] => 2018-07-18T13:08:42 )
[6] => Array ( [JobId] => 5990109 [DeliveryDate] => 2018-07-18T13:05:12 )
[7] => Array ( [JobId] => 5990115 [DeliveryDate] => 2018-07-18T13:07:54 )
[8] => Array ( [JobId] => 5990116 [DeliveryDate] => 2018-07-18T13:05:31 )
[9] => Array ( [JobId] => 5990117 [DeliveryDate] => 2018-07-18T13:04:59 )
[10] => Array ( [JobId] => 5990118 [DeliveryDate] => 2018-07-18T13:07:18 )
)
You'll want to read up on loops in Blade templates. Here's the official documentation. Perhaps foreach will do what you want, then just loop through them and follow the examples to see how you can reference that particular element as output.

How to convert from newsoap to xml using simplexelement,simple_to_string

error_reporting(0);
session_start();
$link=$_POST['Host'];
$_SESSION['Host']=$link;
$client = new SoapClient("http://".$link."/api/soap/?wsdl");
/*api credentials*/
$apiuser=$_POST['User'];
$_SESSION['User']=$apiuser;
$apikey =$_POST['Key'];
$_SESSION['Key']=$apikey;
/*Action to be made */
$action =$_POST['Catalog'];
$_SESSION['Catalog']=$action;
/*Error trapping if in case number will be input*/
if(ctype_alpha(!$action))
{
die('Incorrect format');
}
else
{
$sess_id= $client->login($apiuser, $apikey);
/api login/
echo"Total Active list Product:".(count($client->call($sess_id, $action)));
echo"";
print_r($result=$client->call($sess_id,$action));
echo"";
}
?>
Array
(
[0] => Array
(
[product_id] => 1
[sku] => ROx12345
[name] => acer netbook
[set] => 4
[type] => simple
[category_ids] => Array
(
)
[website_ids] => Array
(
[0] => 1
)
)
[1] => Array
(
[product_id] => 2
[sku] => Cats1234
[name] => starbucks mug
[set] => 4
[type] => simple
[category_ids] => Array
(
)
[website_ids] => Array
(
[0] => 1
)
)
[2] => Array
(
[product_id] => 3
[sku] => samsung2141
[name] => samsung 3110
[set] => 4
[type] => grouped
[category_ids] => Array
(
)
[website_ids] => Array
(
[0] => 1
)
)

Magento solr search - how to add custom field to product search index

I have enterprise magento 1.10 and I need to add custom field to solr index in order to to have better search results. This custom field should contain category names for indexed product.
I need to know which part of magento I need to amend. I modified method Enterprise_Search_Model_Resource_Index::_getCatalogCategoryData which actualy produces some category related data but my new field doesnt appear in message to sorl.
Have I miss something?
Also I have some notes here, maybe it would someone help http://docs.nostresscommerce.com:8090/pages/viewpage.action?pageId=2490371
My output of rewrited Enterprise_Search_Model_Resource_Index::_getCatalogCategoryData, and I need category_name_level_* in solr.
[result] => Array
(
[12227] => Array
(
[#categories] => Array
(
[0] => 2
[3] => 3235
[7] => 2765
[10] => 6672
)
[#show_in_categories] => Array
(
[1] => 6671
[2] => 6670
[4] => 3224
[5] => 3199
[6] => 3191
[8] => 2761
[9] => 2760
)
[#position_category_2] => 1
[#position_category_6671] => 120000
[#position_category_6670] => 120000
[#position_category_3235] => 0
[#position_category_3224] => 150000
[#position_category_3199] => 150000
[#position_category_3191] => 120000
[#position_category_2765] => 1
[#position_category_2761] => 250001
[#position_category_2760] => 250001
[#position_category_6672] => 0
[#visibility] => 4
[#category_name_level_1] => Array
(
[0] => BCC Root Category
)
[#category_name_level_4] => Array
(
[0] => Huishouden
[1] => Top wasmachines
[2] => Accessoires wasmachine
)
[#category_name_level_3] => Array
(
[0] => Beste Koop Shop
[1] => Top
[2] => Wasmachine
)
[#category_name_level_2] => Array
(
[0] => Acties
[1] => Speciale informatie pagina's
[2] => Huishouden
)
[#category_name_level_5] => Array
(
[0] => Wasmachines
)
)
)
Thanks a lot,
Jaro.
I found a solution
class Xyz_Solrsearch_Model_Resource_Engine extends Enterprise_Search_Model_Resource_Engine {
public function __construct()
{
$this->_advancedDynamicIndexFields[] = '#category_name_level_';
parent::__construct();
}
}

Resources