Skip to content

Instantly share code, notes, and snippets.

@nevvermind
nevvermind / ext_eav.php
Last active April 7, 2021 09:57
Saving an EAV Product attribute via the extensions mechanism
<?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 April 9, 2019 07:30 — forked from yesvods/gist:51af798dd1e7058625f4
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
<?php
public function loadRepository(RepositoryInterface $repo)
{
foreach ($repo->getPackages() as $package) { /** @var PackageInterface $package */
if ($package instanceof AliasPackage) {
continue;
}
switch ($package->getType()) {