Tag Archives: Magento 2

Data fixture

A data fixture is a PHP script that sets data you want to reuse in your test. The script can be defined in a separate file or as a local test case method.

Use data fixtures to prepare a database for tests. The Integration Testing Framework (ITF) reverts the database to its initial state automatically. To set up a date fixture, use the @magentoDataFixture annotation.

Customer Attributes

Customer attributes provide the information that is required to support the order, fulfillment, and customer management processes. Because your business is unique, you might need fields in addition to those provided by the system. You can add custom attributes to the Account Information, Address Book, and Billing Information sections of the customer’s account. Customer address attributes can also be used in the Billing Information section during checkout, or when guests register for an account.

https://docs.magento.com/user-guide/v2.3/stores/attributes-customer.html

 

Payment Method Facade

Payment facade it is an instance of Payment Adapter configured with virtual types and allows to process payment actions between Magento Sales Management and payment processor.

Add the dependency injection (DI) configuration for payment method facade in your %Vendor_Module%/etc/di.xml.

https://devdocs.magento.com/guides/v2.3/payments-integrations/base-integration/facade-configuration.html

Content Staging

Content staging gives your business team the ability to easily create, preview, and schedule a wide range of content updates for your store directly from the Admin. For example, rather than thinking in terms of a static page, consider a page to be a collection of different elements that can be turned on or off based on a schedule. You can use content staging to create a page that changes automatically throughout the year on schedule.

Content staging is a feature that allows creating, previewing, and scheduling content updates for your store
directly from the Admin . You can use content staging to create campaigns that include changes to products,
categories, pages, blocks, widgets, price rules, and more.

magento 2 unable to unserialize value

Open the file \vendor\magento\framework\Serialize\Serializer\json.php and replace the function unserialize() with the below

public function unserialize($string) {
/* Added the following if clause to resolve the issue */
if($this->is_serialized($string)){
$string = $this->serialize($string);
}
$result = json_decode($string, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException('Unable to unserialize value.');
}
return $result;
}

Also add the following function as well

function is_serialized($value, &$result = null) {
// Bit of a give away this one
if (!is_string($value))
{
return false;
}
// Serialized false, return true. unserialize() returns false on an
// invalid string or it could return false if the string is serialized
// false, eliminate that possibility.
if ($value === 'b:0;')
{
$result = false;
return true;
}
$length = strlen($value);
$end = '';
switch ($value[0])
{
case 's':
if ($value[$length - 2] !== '"')
{
return false;
}
case 'b':
case 'i':
case 'd':
// This looks odd but it is quicker than isset()ing
$end .= ';';
case 'a':
case 'O':
$end .= '}';
if ($value[1] !== ':')
{
return false;
}
switch ($value[2])
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
break;
default:
return false;
}
case 'N':
$end .= ';';
if ($value[$length - 1] !== $end[0])
{
return false;
}
break;
default:
return false;
}
if (($result = @unserialize($value)) === false)
{
$result = null;
return false;
}
return true;
}

Magento 2: setup upgrade error “We can’t find the role for the user you wanted”

open the file
vendor/magento/module-authorization/Model/Acl/AclRetriever.php and replaced the below code

if (!$role) {
throw new AuthorizationException(
__('We can\'t find the role for the user you wanted.')
);
}
$allowedResources = $this->getAllowedResourcesByRole($role->getId());

with

if (!$role) {
$allowedResources = array();
}

and revert it on sucess.