Skip to content

Instantly share code, notes, and snippets.

@nevvermind
nevvermind / ext_eav.php
Last active Apr 7, 2021
Saving an EAV Product attribute via the extensions mechanism
View ext_eav.php
<?php
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepo */
$productRepo = $objManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
/** @var \Magento\Catalog\Api\Data\ProductInterface $productData */
$product = $productRepo->get('some_sku');
/** @var \Magento\Catalog\Api\Data\ProductExtensionInterface $ext */
$ext = $product->getExtensionAttributes();
@nevvermind
nevvermind / gist:adab3c10437b8fd89f8b1a5056f4d00a
Created Apr 9, 2019 — forked from yesvods/gist:51af798dd1e7058625f4
Merge Arrays in one with ES6 Array spread
View gist:adab3c10437b8fd89f8b1a5056f4d00a
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
View PluginManager.php
<?php
public function loadRepository(RepositoryInterface $repo)
{
foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */
if ($package instanceof AliasPackage) {
continue;
}
switch ($package->getType()) {